diff options
| author | Akshay Nair <phenax5@gmail.com> | 2025-03-12 20:47:57 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2025-03-12 21:06:52 +0530 |
| commit | 05ae8976a8e1ab5411058de244c4e2fcc87ec369 (patch) | |
| tree | cb3661ed66b9aeb6b78818228d4ec4785dbf27e1 | |
| parent | d46cf6e12452261c6aaf498dddf8e1176d349d6e (diff) | |
| download | null-browser-05ae8976a8e1ab5411058de244c4e2fcc87ec369.tar.gz null-browser-05ae8976a8e1ab5411058de244c4e2fcc87ec369.zip | |
Refactor MainWindow into InputMediator
| -rw-r--r-- | TODO.org | 2 | ||||
| -rw-r--r-- | include/InputMediator.hpp | 60 | ||||
| -rw-r--r-- | include/completion/CommandsModel.hpp | 4 | ||||
| -rw-r--r-- | include/utils.hpp | 5 | ||||
| -rw-r--r-- | include/widgets/InputLine.hpp | 11 | ||||
| -rw-r--r-- | include/widgets/MainWindow.hpp | 39 | ||||
| -rw-r--r-- | spec/InputLineSpec.cpp | 14 | ||||
| -rw-r--r-- | spec/InputMediatorSpec.cpp | 162 | ||||
| -rw-r--r-- | src/CommandParser.cpp | 4 | ||||
| -rw-r--r-- | src/InputMediator.cpp | 97 | ||||
| -rw-r--r-- | src/widgets/InputLine.cpp | 15 | ||||
| -rw-r--r-- | src/widgets/MainWindow.cpp | 109 |
12 files changed, 363 insertions, 159 deletions
@@ -5,10 +5,10 @@ - [X] Simpler shell-ey/vimscript-ey language for command input - [X] Command completion - [X] Command/URL input executor +- [X] Refactor MainWindow - [ ] Buffer list/search - [ ] Modal keys - [ ] Tab history navigation -- [ ] Refactor MainWindow - [ ] Press tab/shift-tab for next/prev in completion - [ ] Enter in completion should run cmd diff --git a/include/InputMediator.hpp b/include/InputMediator.hpp new file mode 100644 index 0000000..660d39f --- /dev/null +++ b/include/InputMediator.hpp @@ -0,0 +1,60 @@ +#pragma once + +#include <QWidget> +#include <QtCore> + +#include "LuaRuntime.hpp" +#include "utils.hpp" +#include "widgets/InputLine.hpp" +#include "widgets/WebViewStack.hpp" + +class EvaluationType { +public: + EvaluationType() {} + virtual ~EvaluationType() = default; +}; +class NoopEval : public EvaluationType {}; + +class InputMediator : public QObject { + Q_OBJECT + +public: + InputMediator(InputLine *inputLine, WebViewStack *webViewStack, + LuaRuntime *luaRuntime); + + void showURLInput(QString url = "", OpenType openType = OpenType::OpenUrl); + void showCommandInput(QString command = ""); + void hideInputLine(); + + DELEGATE(webViewStack, openUrl, openUrl) + DELEGATE(webViewStack, currentUrl, currentUrl) + DELEGATE(webViewStack, next, nextWebView) + DELEGATE(webViewStack, previous, previousWebView) + DELEGATE(webViewStack, closeCurrent, closeCurrentWebView) + DELEGATE(inputLine, getInputText, getInputText) + +private: + void showInputLine(); + void evaluateCommand(QString command); + void setEvaluationType(EvaluationType *); + +private slots: + void onInputSubmit(QString input); + +private: + InputLine *inputLine; + WebViewStack *webViewStack; + LuaRuntime *luaRuntime; + EvaluationType *currentEvaluationType = new NoopEval(); +}; + +class UrlEval : public EvaluationType { +public: + UrlEval(OpenType type) : EvaluationType(), openType(type) {} + OpenType type() { return openType; } + +private: + OpenType openType; +}; + +class CommandEval : public EvaluationType {}; diff --git a/include/completion/CommandsModel.hpp b/include/completion/CommandsModel.hpp index 6cb25f9..28836fe 100644 --- a/include/completion/CommandsModel.hpp +++ b/include/completion/CommandsModel.hpp @@ -12,8 +12,8 @@ struct Command { const QList<Command> commands = { {.name = "open", .description = "Open a url in the current tab"}, {.name = "tabopen", .description = "Open a url in a new tab"}, - {.name = "bnext", .description = "Go to next tab"}, - {.name = "bprev", .description = "Go to previous tab"}, + {.name = "tabnext", .description = "Go to next tab"}, + {.name = "tabbprev", .description = "Go to previous tab"}, }; class CommandsModel : public QAbstractListModel { diff --git a/include/utils.hpp b/include/utils.hpp new file mode 100644 index 0000000..65667f7 --- /dev/null +++ b/include/utils.hpp @@ -0,0 +1,5 @@ + +#define DELEGATE(OBJ, METHOD, METHOD_AS) \ + template <typename... Args> decltype(auto) METHOD_AS(Args &&...args) { \ + return OBJ->METHOD(std::forward<Args>(args)...); \ + } diff --git a/include/widgets/InputLine.hpp b/include/widgets/InputLine.hpp index 1d98c9a..07b6e92 100644 --- a/include/widgets/InputLine.hpp +++ b/include/widgets/InputLine.hpp @@ -7,6 +7,7 @@ #include <QtCore> #include "completion/Adapter.hpp" +#include "utils.hpp" class InputLine : public QWidget { Q_OBJECT @@ -15,13 +16,15 @@ public: InputLine(QString defaultInput = "", QWidget *parentNode = nullptr); void setInputFocus(bool focussed); bool isInputFocussed(); - QString getInputCommand(); - void setInputText(QString text); void setAdapter(Adapter *adapter); - Adapter *adapter(); + + DELEGATE(input, hasFocus, isInputFocussed) + DELEGATE(input, setText, setInputText) + DELEGATE(input, text, getInputText) + DELEGATE(adapterInstance, prompt, prompt) signals: - void submitted(QString command); + void submitted(QString text); void cancelled(); protected: diff --git a/include/widgets/MainWindow.hpp b/include/widgets/MainWindow.hpp index 99a3895..f77ed60 100644 --- a/include/widgets/MainWindow.hpp +++ b/include/widgets/MainWindow.hpp @@ -5,16 +5,7 @@ #include <QStackedLayout> #include <QWebEngineView> -#include "LuaRuntime.hpp" -#include "widgets/InputLine.hpp" -#include "widgets/WebViewStack.hpp" - -class EvaluationType { -public: - EvaluationType() {} - virtual ~EvaluationType() = default; -}; -class NoopEval : public EvaluationType {}; +#include "InputMediator.hpp" class MainWindow : public QMainWindow { public: @@ -22,33 +13,7 @@ public: private: void keyPressEvent(QKeyEvent *event) override; - void onInputSubmit(QString input); - - void evaluateCommand(QString command); - - void hideInputLine(); - void showInputLine(); - void showURLInput(QString url, OpenType openType); - void showCommandInput(QString command = ""); - - void setEvaluationType(EvaluationType *); private: - WebViewStack *webViewStack; - InputLine *inputLine; - LuaRuntime *luaRuntime; - QStackedLayout *layout; - - EvaluationType *currentEvaluationType = new NoopEval(); + InputMediator *inputMediator; }; - -class UrlEval : public EvaluationType { -public: - UrlEval(OpenType type) : EvaluationType(), openType(type) {} - OpenType type() { return openType; } - -private: - OpenType openType; -}; - -class CommandEval : public EvaluationType {}; diff --git a/spec/InputLineSpec.cpp b/spec/InputLineSpec.cpp index e4eb9a5..9a3115a 100644 --- a/spec/InputLineSpec.cpp +++ b/spec/InputLineSpec.cpp @@ -1,5 +1,4 @@ #include "testUtils.h" - #include "widgets/InputLine.hpp" class InputLineSpec : public QObject { @@ -11,35 +10,34 @@ private slots: it("sets the initial input text") { InputLine inputWidget("Initial content", new QWidget()); - QCOMPARE(inputWidget.getInputCommand(), QString("Initial content")); + QCOMPARE(inputWidget.getInputText(), QString("Initial content")); } } void testInputUpdate() { context("when user types in input"); - it("updates input command") { + it("updates input text") { InputLine inputWidget("Initial content", new QWidget()); auto input = inputWidget.findChild<QLineEdit *>(); QTest::keyClicks(input, " updated"); - QCOMPARE(inputWidget.getInputCommand(), - QString("Initial content updated")); + QCOMPARE(inputWidget.getInputText(), QString("Initial content updated")); } context("when setInputText is called"); - it("sets input command") { + it("sets input text") { InputLine inputWidget("Initial content", new QWidget()); inputWidget.setInputText("New content"); - QCOMPARE(inputWidget.getInputCommand(), QString("New content")); + QCOMPARE(inputWidget.getInputText(), QString("New content")); } } void testSubmitSignalOnReturnKey() { context("when user hits return key"); - it("emits the submitted signal with the input command") { + it("emits the submitted signal with the input text") { InputLine inputWidget("Initial content", new QWidget()); QSignalSpy submitSignal(&inputWidget, &InputLine::submitted); diff --git a/spec/InputMediatorSpec.cpp b/spec/InputMediatorSpec.cpp new file mode 100644 index 0000000..464e156 --- /dev/null +++ b/spec/InputMediatorSpec.cpp @@ -0,0 +1,162 @@ +#include "InputMediator.hpp" +#include "LuaRuntime.hpp" +#include "testUtils.h" +#include "widgets/InputLine.hpp" +#include "widgets/WebViewStack.hpp" + +class InputMediatorSpec : public QObject { + Q_OBJECT + +private slots: + void testInputTypes() { + context("when showCommandInput is called"); + it("shows url input with default command") { + auto inputLine = InputLine(); + auto webViewStack = WebViewStack(); + auto luaRuntime = LuaRuntime::instance(); + InputMediator inputMediator(&inputLine, &webViewStack, luaRuntime); + QCOMPARE(inputLine.isHidden(), true); + + inputMediator.showCommandInput("open"); + + QCOMPARE(inputLine.isHidden(), false); + QCOMPARE(inputLine.prompt(), "[exec]"); + QCOMPARE(inputLine.getInputText(), "open"); + } + + context("when showURLInput is called"); + it("shows url input with default url") { + auto inputLine = InputLine(); + auto webViewStack = WebViewStack(); + auto luaRuntime = LuaRuntime::instance(); + InputMediator inputMediator(&inputLine, &webViewStack, luaRuntime); + QCOMPARE(inputLine.isHidden(), true); + + inputMediator.showURLInput("http://a.com"); + + QCOMPARE(inputLine.isHidden(), false); + QCOMPARE(inputLine.prompt(), "[url]"); + QCOMPARE(inputLine.getInputText(), "http://a.com"); + } + } + + void testCommandEvaluationOpen() { + context("when command open is executed"); + context("- without args"); + it("opens url input") { + auto inputLine = InputLine(); + auto webViewStack = WebViewStack(); + auto luaRuntime = LuaRuntime::instance(); + InputMediator inputMediator(&inputLine, &webViewStack, luaRuntime); + + inputMediator.showCommandInput(); + emit inputLine.submitted("open"); + + QCOMPARE(inputLine.prompt(), "[url]"); + } + + context("when command open is executed"); + context("- with url as an arg"); + it("opens url in current tab") { + auto inputLine = InputLine(); + auto webViewStack = WebViewStack(); + auto luaRuntime = LuaRuntime::instance(); + InputMediator inputMediator(&inputLine, &webViewStack, luaRuntime); + + inputMediator.showCommandInput(); + emit inputLine.submitted("open http://a.com"); + + std::vector<QUrl> urls = {QUrl("http://a.com")}; + QCOMPARE(webViewStack.urls(), urls); + QCOMPARE(webViewStack.currentWebViewIndex(), 0); + } + } + + void testCommandEvaluationTabOpen() { + context("when command tabopen is run"); + context("- without args"); + it("opens url in a new tab") { + auto inputLine = InputLine(); + auto webViewStack = WebViewStack(); + auto luaRuntime = LuaRuntime::instance(); + InputMediator inputMediator(&inputLine, &webViewStack, luaRuntime); + + inputMediator.showCommandInput(); + emit inputLine.submitted("tabopen"); + + QCOMPARE(inputLine.prompt(), "[url]"); + } + + context("when command tabopen is executed"); + context("- with url as an arg"); + it("opens url in a new tab") { + auto inputLine = InputLine(); + auto webViewStack = WebViewStack(); + auto luaRuntime = LuaRuntime::instance(); + InputMediator inputMediator(&inputLine, &webViewStack, luaRuntime); + + inputMediator.showCommandInput(); + emit inputLine.submitted("tabopen http://a.com"); + + std::vector<QUrl> urls = {QUrl(WebViewStack::NewtabURL), + QUrl("http://a.com")}; + QCOMPARE(webViewStack.urls(), urls); + QCOMPARE(webViewStack.currentWebViewIndex(), 1); + } + } + + void testCommandEvaluationTabNextPrev() { + context("when command tabnext is executed"); + it("jumps to next tab") { + auto inputLine = InputLine(); + auto webViewStack = WebViewStack(); + auto luaRuntime = LuaRuntime::instance(); + InputMediator inputMediator(&inputLine, &webViewStack, luaRuntime); + webViewStack.openUrl(QUrl("https://a1.com"), OpenType::OpenUrl); + webViewStack.openUrl(QUrl("https://a2.com"), OpenType::OpenUrlInTab); + webViewStack.openUrl(QUrl("https://a2.com"), OpenType::OpenUrlInBgTab); + QCOMPARE(webViewStack.currentWebViewIndex(), 1); + + inputMediator.showCommandInput(); + emit inputLine.submitted("tabnext"); + + QCOMPARE(webViewStack.currentWebViewIndex(), 2); + } + + context("when command tabprev is executed"); + it("jumps to previous tab") { + auto inputLine = InputLine(); + auto webViewStack = WebViewStack(); + auto luaRuntime = LuaRuntime::instance(); + InputMediator inputMediator(&inputLine, &webViewStack, luaRuntime); + webViewStack.openUrl(QUrl("https://a1.com"), OpenType::OpenUrl); + webViewStack.openUrl(QUrl("https://a2.com"), OpenType::OpenUrlInTab); + webViewStack.openUrl(QUrl("https://a2.com"), OpenType::OpenUrlInBgTab); + QCOMPARE(webViewStack.currentWebViewIndex(), 1); + + inputMediator.showCommandInput(); + emit inputLine.submitted("tabprev"); + + QCOMPARE(webViewStack.currentWebViewIndex(), 0); + } + } + + void testHideInputLine() { + context("when hideInputLine is called"); + it("hides input") { + auto inputLine = InputLine(); + auto webViewStack = WebViewStack(); + auto luaRuntime = LuaRuntime::instance(); + InputMediator inputMediator(&inputLine, &webViewStack, luaRuntime); + inputMediator.showURLInput(); + QCOMPARE(inputLine.isHidden(), false); + + inputMediator.hideInputLine(); + + QCOMPARE(inputLine.isHidden(), true); + } + } +}; + +QTEST_REGISTER(InputMediatorSpec) +#include "InputMediatorSpec.moc" diff --git a/src/CommandParser.cpp b/src/CommandParser.cpp index 8f83575..773d37c 100644 --- a/src/CommandParser.cpp +++ b/src/CommandParser.cpp @@ -26,9 +26,9 @@ CommandType CommandParser::toCommandType(QString cmd) { return Open; if (cmd == "tabopen") return TabOpen; - if (cmd == "bn" || cmd == "bnext") + if (cmd == "tn" || cmd == "tabnext") return TabNext; - if (cmd == "bp" || cmd == "bprevious") + if (cmd == "tp" || cmd == "tabprev") return TabPrev; return Noop; diff --git a/src/InputMediator.cpp b/src/InputMediator.cpp new file mode 100644 index 0000000..8bcadd0 --- /dev/null +++ b/src/InputMediator.cpp @@ -0,0 +1,97 @@ +#include <QWidget> +#include <QtCore> + +#include "CommandParser.hpp" +#include "InputMediator.hpp" +#include "LuaRuntime.hpp" +#include "completion/CommandsAdapter.hpp" +#include "completion/UrlAdapter.hpp" +#include "widgets/WebViewStack.hpp" + +InputMediator::InputMediator(InputLine *inputLine, WebViewStack *webViewStack, + LuaRuntime *luaRuntime) + : QObject(), inputLine(inputLine), webViewStack(webViewStack), + luaRuntime(luaRuntime) { + // Inputline + inputLine->setHidden(true); + connect(inputLine, &InputLine::submitted, this, + &InputMediator::onInputSubmit); + connect(inputLine, &InputLine::cancelled, this, + &InputMediator::hideInputLine); + + // Lua runtime + connect(luaRuntime, &LuaRuntime::urlOpened, webViewStack, + &WebViewStack::openUrl); +} + +void InputMediator::onInputSubmit(QString input) { + hideInputLine(); + + if (dynamic_cast<CommandEval *>(currentEvaluationType)) + return evaluateCommand(input); + + if (auto urlEval = dynamic_cast<UrlEval *>(currentEvaluationType)) + return webViewStack->openUrl(input, urlEval->type()); +} + +void InputMediator::hideInputLine() { + inputLine->setInputFocus(false); + inputLine->setHidden(true); +} + +void InputMediator::showInputLine() { + inputLine->setHidden(false); + inputLine->raise(); + inputLine->setInputFocus(true); +} + +void InputMediator::showCommandInput(QString cmd) { + setEvaluationType(new CommandEval()); + inputLine->setAdapter(new CommandsAdapter); + inputLine->setInputText(cmd); + showInputLine(); +} + +void InputMediator::setEvaluationType(EvaluationType *evalType) { + if (currentEvaluationType) + delete currentEvaluationType; + currentEvaluationType = evalType; +} + +void InputMediator::showURLInput(QString url, OpenType openType) { + setEvaluationType(new UrlEval(openType)); + inputLine->setAdapter(new UrlAdapter); + inputLine->setInputText(url); + showInputLine(); +} + +void InputMediator::evaluateCommand(QString command) { + CommandParser parser; + auto cmd = parser.parse(command); + + switch (cmd.command) { + case CommandType::LuaEval: + luaRuntime->evaluate(cmd.argsString); + break; + case CommandType::Open: + if (cmd.argsString.trimmed().isEmpty()) + showURLInput("", OpenType::OpenUrl); + else + webViewStack->openUrl(cmd.argsString, OpenType::OpenUrl); + break; + case CommandType::TabOpen: + if (cmd.argsString.trimmed().isEmpty()) + showURLInput("", OpenType::OpenUrlInTab); + else + webViewStack->openUrl(cmd.argsString, OpenType::OpenUrlInTab); + break; + case CommandType::TabNext: + webViewStack->next(); + break; + case CommandType::TabPrev: + webViewStack->previous(); + break; + case CommandType::Noop: + break; + } +} diff --git a/src/widgets/InputLine.cpp b/src/widgets/InputLine.cpp index 5edfe17..130732c 100644 --- a/src/widgets/InputLine.cpp +++ b/src/widgets/InputLine.cpp @@ -20,14 +20,15 @@ const char *rootStyles = R"( )"; const char *promptStyles = R"( - background-color: #aaa; - color: #555; + background-color: #222; + color: #fff; padding: 0 2px; )"; InputLine::InputLine(QString defaultInput, QWidget *parentNode) : QWidget(parentNode) { setContentsMargins(0, 0, 0, 0); + move(0, 0); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); setStyleSheet(rootStyles); @@ -54,8 +55,6 @@ InputLine::InputLine(QString defaultInput, QWidget *parentNode) setAdapter(new CommandsAdapter()); } -Adapter *InputLine::adapter() { return adapterInstance; } - void InputLine::setAdapter(Adapter *adapter) { if (this->adapterInstance) delete this->adapterInstance; @@ -64,7 +63,7 @@ void InputLine::setAdapter(Adapter *adapter) { input->setCompleter(adapter->completer()); } -void InputLine::emitSubmit() { emit submitted(getInputCommand()); } +void InputLine::emitSubmit() { emit submitted(getInputText()); } void InputLine::keyPressEvent(QKeyEvent *event) { auto combo = event->keyCombination(); @@ -79,15 +78,9 @@ void InputLine::keyPressEvent(QKeyEvent *event) { emitSubmit(); } -void InputLine::setInputText(QString text) { input->setText(text); } - -bool InputLine::isInputFocussed() { return input->hasFocus(); } - void InputLine::setInputFocus(bool focussed) { if (focussed) input->setFocus(Qt::PopupFocusReason); else input->clearFocus(); } - -QString InputLine::getInputCommand() { return input->text(); } diff --git a/src/widgets/MainWindow.cpp b/src/widgets/MainWindow.cpp index 2d936aa..632869f 100644 --- a/src/widgets/MainWindow.cpp +++ b/src/widgets/MainWindow.cpp @@ -4,9 +4,7 @@ #include <QWebEngineView> #include <QtCore/qnamespace.h> -#include "CommandParser.hpp" -#include "completion/CommandsAdapter.hpp" -#include "completion/UrlAdapter.hpp" +#include "InputMediator.hpp" #include "widgets/InputLine.hpp" #include "widgets/MainWindow.hpp" #include "widgets/WebViewStack.hpp" @@ -16,123 +14,46 @@ MainWindow::MainWindow() { setCentralWidget(new QWidget()); // Root stacked layout - layout = new QStackedLayout(); + auto layout = new QStackedLayout(); layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); layout->setStackingMode(QStackedLayout::StackAll); centralWidget()->setLayout(layout); // Web engine - webViewStack = new WebViewStack(new QWebEngineProfile("web-browser")); + auto webViewStack = new WebViewStack(new QWebEngineProfile("web-browser")); layout->addWidget(webViewStack); // Command input - inputLine = new InputLine; - inputLine->setHidden(true); - inputLine->move(0, 0); - connect(inputLine, &InputLine::submitted, this, &MainWindow::onInputSubmit); - connect(inputLine, &InputLine::cancelled, this, &MainWindow::hideInputLine); + auto inputLine = new InputLine; layout->addWidget(inputLine); - // Lua runtime - luaRuntime = LuaRuntime::instance(); - connect(luaRuntime, &LuaRuntime::urlOpened, this, - [this](QString url, OpenType openType) { - webViewStack->openUrl(QUrl(url), openType); - }); -} - -void MainWindow::hideInputLine() { - inputLine->setInputFocus(false); - inputLine->setHidden(true); -} - -void MainWindow::showInputLine() { - inputLine->setHidden(false); - layout->setCurrentWidget(inputLine); - inputLine->setInputFocus(true); -} - -void MainWindow::showURLInput(QString url, OpenType openType) { - setEvaluationType(new UrlEval(openType)); - inputLine->setAdapter(new UrlAdapter); - inputLine->setInputText(url); - showInputLine(); -} - -void MainWindow::showCommandInput(QString cmd) { - setEvaluationType(new CommandEval()); - inputLine->setAdapter(new CommandsAdapter); - inputLine->setInputText(cmd); - showInputLine(); -} -void MainWindow::setEvaluationType(EvaluationType *evalType) { - if (currentEvaluationType) - delete currentEvaluationType; - currentEvaluationType = evalType; -} - -void MainWindow::onInputSubmit(QString input) { - hideInputLine(); - - if (dynamic_cast<CommandEval *>(currentEvaluationType)) { - evaluateCommand(input); - } else if (auto urlEval = dynamic_cast<UrlEval *>(currentEvaluationType)) { - webViewStack->openUrl(input, urlEval->type()); - } -} - -void MainWindow::evaluateCommand(QString command) { - CommandParser parser; - auto cmd = parser.parse(command); - - switch (cmd.command) { - case CommandType::LuaEval: - luaRuntime->evaluate(cmd.argsString); - break; - case CommandType::Open: - if (cmd.argsString.trimmed().isEmpty()) - showURLInput("", OpenType::OpenUrl); - else - webViewStack->openUrl(cmd.argsString, OpenType::OpenUrl); - break; - case CommandType::TabOpen: - if (cmd.argsString.trimmed().isEmpty()) - showURLInput("", OpenType::OpenUrlInTab); - else - webViewStack->openUrl(cmd.argsString, OpenType::OpenUrlInTab); - break; - case CommandType::TabNext: - webViewStack->next(); - break; - case CommandType::TabPrev: - webViewStack->previous(); - break; - case CommandType::Noop: - break; - } + inputMediator = + new InputMediator(inputLine, webViewStack, LuaRuntime::instance()); } void MainWindow::keyPressEvent(QKeyEvent *event) { auto combo = event->keyCombination(); + if (combo.key() == Qt::Key_L && combo.keyboardModifiers().testFlag(Qt::ControlModifier)) { - showURLInput(webViewStack->currentUrl().toString(), OpenType::OpenUrl); + inputMediator->showURLInput(inputMediator->currentUrl().toString(), + OpenType::OpenUrl); } else if (combo.key() == Qt::Key_Semicolon && combo.keyboardModifiers().testFlag(Qt::ControlModifier)) { - showCommandInput(""); + inputMediator->showCommandInput(""); } else if (combo.key() == Qt::Key_T && combo.keyboardModifiers().testFlag(Qt::ControlModifier)) { - webViewStack->openUrl(QUrl("https://lite.duckduckgo.com"), - OpenType::OpenUrlInTab); + inputMediator->openUrl(QUrl("https://lite.duckduckgo.com"), + OpenType::OpenUrlInTab); } else if (combo.key() == Qt::Key_J && combo.keyboardModifiers().testFlag(Qt::ControlModifier)) { - webViewStack->next(); + inputMediator->nextWebView(); } else if (combo.key() == Qt::Key_K && combo.keyboardModifiers().testFlag(Qt::ControlModifier)) { - webViewStack->previous(); + inputMediator->previousWebView(); } else if (combo.key() == Qt::Key_W && combo.keyboardModifiers().testFlag(Qt::ControlModifier)) { - webViewStack->closeCurrent(); + inputMediator->closeCurrentWebView(); } } |
