diff options
| author | Akshay Nair <phenax5@gmail.com> | 2025-03-09 19:47:50 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2025-03-09 19:47:50 +0530 |
| commit | 61f99089288138989cf244d174882aa5088b738b (patch) | |
| tree | ea1202b098b92e85b16e670d1c3ea1b86fcaef58 /src/CommandInput.cpp | |
| parent | 1e2302be2b47fbeb340db7482ed8476c829a7f66 (diff) | |
| download | null-browser-61f99089288138989cf244d174882aa5088b738b.tar.gz null-browser-61f99089288138989cf244d174882aa5088b738b.zip | |
Refactor directory structure
Diffstat (limited to 'src/CommandInput.cpp')
| -rw-r--r-- | src/CommandInput.cpp | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/src/CommandInput.cpp b/src/CommandInput.cpp deleted file mode 100644 index d553d19..0000000 --- a/src/CommandInput.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include <QHBoxLayout> -#include <QKeyEvent> -#include <QLineEdit> -#include <QVBoxLayout> -#include <QWidget> -#include <QWindow> -#include <iostream> - -#include "CommandInput.hpp" - -CommandInput::CommandInput(QString defaultInput, QWidget *parentNode) - : QWidget(parentNode) { - setContentsMargins(0, 0, 0, 0); - setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - setStyleSheet("background-color: #000; color: #fff; border-radius: 0;"); - - auto layout = new QVBoxLayout(this); - layout->setContentsMargins(0, 0, 0, 0); - input = new QLineEdit(defaultInput, this); - input->setFocusPolicy(Qt::StrongFocus); - layout->addWidget(input); - setFixedHeight(input->sizeHint().height()); -} - -void CommandInput::emitSubmit() { emit submitted(getInputCommand()); } - -void CommandInput::keyPressEvent(QKeyEvent *event) { - auto combo = event->keyCombination(); - auto ctrlL = combo.key() == Qt::Key_L && - combo.keyboardModifiers().testFlag(Qt::ControlModifier); - auto esc = combo.key() == Qt::Key_Escape; - auto enter = combo.key() == Qt::Key_Return || combo.key() == Qt::Key_Enter; - - if (esc || ctrlL) - emit cancelled(); - else if (enter) - emitSubmit(); -} - -void CommandInput::setInputText(QString text) { input->setText(text); } - -bool CommandInput::isInputFocussed() { return input->hasFocus(); } - -void CommandInput::setInputFocus(bool focussed) { - if (focussed) - input->setFocus(Qt::PopupFocusReason); - else - input->clearFocus(); -} - -QString CommandInput::getInputCommand() { return input->text(); } |
