diff options
| author | Akshay Nair <phenax5@gmail.com> | 2025-03-08 20:28:10 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2025-03-08 20:29:03 +0530 |
| commit | 6d3ee55638164df6521a60b6392a26f855d5f924 (patch) | |
| tree | 18448793cbb971e76cbaeb7b9d2159ee2ab5d3b6 /src/CommandInput.cpp | |
| parent | b7ac4dc7a20c624a343c946c5decd1b84eab2b82 (diff) | |
| download | null-browser-6d3ee55638164df6521a60b6392a26f855d5f924.tar.gz null-browser-6d3ee55638164df6521a60b6392a26f855d5f924.zip | |
Add test setup + spec for command input
Diffstat (limited to 'src/CommandInput.cpp')
| -rw-r--r-- | src/CommandInput.cpp | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/CommandInput.cpp b/src/CommandInput.cpp index b168536..cf7346c 100644 --- a/src/CommandInput.cpp +++ b/src/CommandInput.cpp @@ -1,16 +1,9 @@ -#include <QApplication> -#include <QDialog> #include <QKeyEvent> -#include <QLabel> #include <QLineEdit> -#include <QObject> #include <QVBoxLayout> -#include <QWebEnginePage> -#include <QWebEngineView> #include <QWidget> #include <QWindow> #include <iostream> -#include <lua.hpp> #include "CommandInput.hpp" @@ -27,13 +20,14 @@ CommandInput::CommandInput(QString defaultInput, QWidget *parentNode) layout->setContentsMargins(0, 0, 0, 0); input = new QLineEdit(defaultInput, this); input->setContentsMargins(0, 0, 0, 0); + input->setFocusPolicy(Qt::StrongFocus); layout->addWidget(input); } void CommandInput::keyPressEvent(QKeyEvent *event) { auto combo = event->keyCombination(); if (combo.key() == Qt::Key_Return) { - emit submitted(input->text()); + emit submitted(getInputCommand()); } } @@ -41,7 +35,9 @@ bool CommandInput::isInputFocussed() { return input->hasFocus(); } void CommandInput::setInputFocus(bool focussed) { if (focussed) - input->setFocus(); + input->setFocus(Qt::PopupFocusReason); else input->clearFocus(); } + +QString CommandInput::getInputCommand() { return input->text(); } |
