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