diff options
| author | Akshay Nair <phenax5@gmail.com> | 2025-03-08 18:16:51 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2025-03-08 18:16:51 +0530 |
| commit | b7ac4dc7a20c624a343c946c5decd1b84eab2b82 (patch) | |
| tree | 6e7efa381546244da8942ec023d94db634b73948 /src/MainWindow.cpp | |
| parent | ecd3ccde166910e3667b7b1a064e9c6db52d1646 (diff) | |
| download | null-browser-b7ac4dc7a20c624a343c946c5decd1b84eab2b82.tar.gz null-browser-b7ac4dc7a20c624a343c946c5decd1b84eab2b82.zip | |
Basic single view browser with url input
Diffstat (limited to 'src/MainWindow.cpp')
| -rw-r--r-- | src/MainWindow.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp new file mode 100644 index 0000000..660d731 --- /dev/null +++ b/src/MainWindow.cpp @@ -0,0 +1,44 @@ +#include <QKeyEvent> +#include <QVBoxLayout> +#include <QWebEngineView> +#include <iostream> +#include <lua.hpp> + +#include "CommandInput.hpp" +#include "MainWindow.hpp" + +MainWindow::MainWindow() { + setStyleSheet("background-color: #000; color: #fff;"); + // layout = new QVBoxLayout(this); + // layout->setContentsMargins(0, 0, 0, 0); + + web = new QWebEngineView(this); + web->setGeometry(200, 10, 500, 500); + web->setUrl(QUrl("https://ediblemonad.dev")); + + urlInputUI = new CommandInput(web->url().toString(), this); + urlInputUI->setHidden(true); + connect(urlInputUI, &CommandInput::submitted, this, + &MainWindow::evaluateCommand); +} + +void MainWindow::evaluateCommand(QString command) { + web->setUrl(command); + urlInputUI->setInputFocus(false); + urlInputUI->setHidden(true); +} + +void MainWindow::keyPressEvent(QKeyEvent *event) { + auto combo = event->keyCombination(); + if (combo.key() == Qt::Key_L && + combo.keyboardModifiers().testFlag(Qt::ControlModifier)) { + toggleURLInput(); + } +} + +void MainWindow::toggleURLInput() { + auto hidden = urlInputUI->isHidden(); + auto shouldShow = hidden; + urlInputUI->setHidden(!shouldShow); + urlInputUI->setInputFocus(shouldShow); +} |
