aboutsummaryrefslogtreecommitdiff
path: root/src/CommandInput.cpp
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2025-03-08 18:16:51 +0530
committerAkshay Nair <phenax5@gmail.com>2025-03-08 18:16:51 +0530
commitb7ac4dc7a20c624a343c946c5decd1b84eab2b82 (patch)
tree6e7efa381546244da8942ec023d94db634b73948 /src/CommandInput.cpp
parentecd3ccde166910e3667b7b1a064e9c6db52d1646 (diff)
downloadnull-browser-b7ac4dc7a20c624a343c946c5decd1b84eab2b82.tar.gz
null-browser-b7ac4dc7a20c624a343c946c5decd1b84eab2b82.zip
Basic single view browser with url input
Diffstat (limited to 'src/CommandInput.cpp')
-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();
+}