aboutsummaryrefslogtreecommitdiff
path: root/src/CommandInput.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/CommandInput.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/CommandInput.cpp b/src/CommandInput.cpp
new file mode 100644
index 0000000..b168536
--- /dev/null
+++ b/src/CommandInput.cpp
@@ -0,0 +1,47 @@
+#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"
+
+CommandInput::CommandInput(QString defaultInput, QWidget *parentNode)
+ : QFrame(parentNode) {
+ setContentsMargins(0, 0, 0, 0);
+ // setFrameRect(QRect(0, 0, parentWidget()->width(), 50));
+ setFixedWidth(parentWidget()->width());
+ setFrameShadow(QFrame::Shadow::Raised);
+ setFrameShape(QFrame::Box);
+ setStyleSheet("background-color: #333; color: #fff;");
+
+ auto layout = new QVBoxLayout(this);
+ layout->setContentsMargins(0, 0, 0, 0);
+ input = new QLineEdit(defaultInput, this);
+ input->setContentsMargins(0, 0, 0, 0);
+ layout->addWidget(input);
+}
+
+void CommandInput::keyPressEvent(QKeyEvent *event) {
+ auto combo = event->keyCombination();
+ if (combo.key() == Qt::Key_Return) {
+ emit submitted(input->text());
+ }
+}
+
+bool CommandInput::isInputFocussed() { return input->hasFocus(); }
+
+void CommandInput::setInputFocus(bool focussed) {
+ if (focussed)
+ input->setFocus();
+ else
+ input->clearFocus();
+}