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 /include/InputMediator.hpp | |
| parent | d46cf6e12452261c6aaf498dddf8e1176d349d6e (diff) | |
| download | null-browser-05ae8976a8e1ab5411058de244c4e2fcc87ec369.tar.gz null-browser-05ae8976a8e1ab5411058de244c4e2fcc87ec369.zip | |
Refactor MainWindow into InputMediator
Diffstat (limited to '')
| -rw-r--r-- | include/InputMediator.hpp | 60 |
1 files changed, 60 insertions, 0 deletions
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 {}; |
