From 6b1d49e607da16853d1a0f460dbe756538e4790c Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Sun, 9 Mar 2025 22:09:09 +0530 Subject: Add lua integration for command input (web.open, web.tabopen) --- src/widgets/MainWindow.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src/widgets/MainWindow.cpp') diff --git a/src/widgets/MainWindow.cpp b/src/widgets/MainWindow.cpp index e660e52..14f6aa7 100644 --- a/src/widgets/MainWindow.cpp +++ b/src/widgets/MainWindow.cpp @@ -23,7 +23,7 @@ MainWindow::MainWindow() { layout->addWidget(browserManager); // Command input - commandInput = new CommandInput(browserManager->currentUrl().toString()); + commandInput = new CommandInput; hideURLInput(); commandInput->move(0, 0); connect(commandInput, &CommandInput::submitted, this, @@ -31,6 +31,13 @@ MainWindow::MainWindow() { connect(commandInput, &CommandInput::cancelled, this, &MainWindow::hideURLInput); layout->addWidget(commandInput); + + // Lua runtime + luaRuntime = LuaRuntime::instance(); + connect(luaRuntime, &LuaRuntime::urlOpenned, this, + [this](QString url, OpenType openType) { + this->browserManager->openUrl(QUrl(url), openType); + }); } void MainWindow::hideURLInput() { @@ -46,8 +53,14 @@ void MainWindow::showURLInput() { } void MainWindow::evaluateCommand(QString command) { - if (!command.isEmpty()) - browserManager->setCurrentUrl(command); + if (!command.isEmpty()) { + // TODO: Temporary hack + if (command.startsWith("lua ")) { + luaRuntime->evaluate(command.slice(4).toStdString().c_str()); + } else { + browserManager->setCurrentUrl(command); + } + } hideURLInput(); } -- cgit v1.3.1