From 12d0ce37db7323e8efd56d6a698a98abcb8d680b Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Tue, 11 Mar 2025 11:31:14 +0530 Subject: Add command+url adapter and switching --- include/widgets/CommandInput.hpp | 29 ----------------------------- include/widgets/InputLine.hpp | 35 +++++++++++++++++++++++++++++++++++ include/widgets/MainWindow.hpp | 11 ++++++----- 3 files changed, 41 insertions(+), 34 deletions(-) delete mode 100644 include/widgets/CommandInput.hpp create mode 100644 include/widgets/InputLine.hpp (limited to 'include/widgets') diff --git a/include/widgets/CommandInput.hpp b/include/widgets/CommandInput.hpp deleted file mode 100644 index 3ce9500..0000000 --- a/include/widgets/CommandInput.hpp +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once - -#include -#include -#include -#include - -class CommandInput : public QWidget { - Q_OBJECT - -public: - CommandInput(QString defaultInput = "", QWidget *parentNode = nullptr); - void setInputFocus(bool focussed); - bool isInputFocussed(); - QString getInputCommand(); - void setInputText(QString text); - -signals: - void submitted(QString command); - void cancelled(); - -protected: - void keyPressEvent(QKeyEvent *event) override; - void emitSubmit(); - -private: - QBoxLayout *layout; - QLineEdit *input; -}; diff --git a/include/widgets/InputLine.hpp b/include/widgets/InputLine.hpp new file mode 100644 index 0000000..2324f18 --- /dev/null +++ b/include/widgets/InputLine.hpp @@ -0,0 +1,35 @@ +#pragma once + +#include +#include +#include +#include +#include + +#include "completion/Adapter.hpp" + +class InputLine : public QWidget { + Q_OBJECT + +public: + InputLine(QString defaultInput = "", QWidget *parentNode = nullptr); + void setInputFocus(bool focussed); + bool isInputFocussed(); + QString getInputCommand(); + void setInputText(QString text); + void setAdapter(Adapter *adapter); + +signals: + void submitted(QString command); + void cancelled(); + +protected: + void keyPressEvent(QKeyEvent *event) override; + void emitSubmit(); + +private: + QBoxLayout *layout; + QLineEdit *input; + QLabel *promptPrefix; + Adapter *adapter = nullptr; +}; diff --git a/include/widgets/MainWindow.hpp b/include/widgets/MainWindow.hpp index 7f54ce2..b64bf8c 100644 --- a/include/widgets/MainWindow.hpp +++ b/include/widgets/MainWindow.hpp @@ -7,7 +7,7 @@ #include "LuaRuntime.hpp" #include "widgets/BrowserManager.hpp" -#include "widgets/CommandInput.hpp" +#include "widgets/InputLine.hpp" class MainWindow : public QMainWindow { public: @@ -15,14 +15,15 @@ public: protected: void keyPressEvent(QKeyEvent *event) override; - void toggleURLInput(); void evaluateCommand(QString command); - void hideURLInput(); - void showURLInput(); + void hideInputLine(); + void showInputLine(); + void showURLInput(QString url = ""); + void showCommandInput(QString command = ""); private: BrowserManager *browserManager; - CommandInput *commandInput; + InputLine *inputLine; LuaRuntime *luaRuntime; QStackedLayout *layout; }; -- cgit v1.3.1