From fdeb33d34a97d062a120f72da919f81d7b1d45bf Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Thu, 20 Mar 2025 22:10:57 +0530 Subject: Move header files to src --- include/CommandParser.hpp | 29 -------------------- include/Configuration.hpp | 13 --------- include/InputMediator.hpp | 33 ----------------------- include/LuaRuntime.hpp | 29 -------------------- include/keymap/KeySeqParser.hpp | 44 ------------------------------ include/keymap/KeymapEvaluator.hpp | 42 ----------------------------- include/utils.hpp | 11 -------- include/widgets/MainWindow.hpp | 19 ------------- include/widgets/WebView.hpp | 13 --------- include/widgets/WebViewStack.hpp | 55 -------------------------------------- 10 files changed, 288 deletions(-) delete mode 100644 include/CommandParser.hpp delete mode 100644 include/Configuration.hpp delete mode 100644 include/InputMediator.hpp delete mode 100644 include/LuaRuntime.hpp delete mode 100644 include/keymap/KeySeqParser.hpp delete mode 100644 include/keymap/KeymapEvaluator.hpp delete mode 100644 include/utils.hpp delete mode 100644 include/widgets/MainWindow.hpp delete mode 100644 include/widgets/WebView.hpp delete mode 100644 include/widgets/WebViewStack.hpp (limited to 'include') diff --git a/include/CommandParser.hpp b/include/CommandParser.hpp deleted file mode 100644 index 9197df5..0000000 --- a/include/CommandParser.hpp +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once - -#include -#include - -enum CommandType { - Noop, - LuaEval, - Open, - TabOpen, - TabNext, - TabPrev, - TabSelect, -}; - -struct Cmd { - CommandType command; - QString argsString; - QString rawInput; -}; - -class CommandParser { -public: - CommandParser(); - Cmd parse(QString command); - -private: - CommandType toCommandType(QString cmd); -}; diff --git a/include/Configuration.hpp b/include/Configuration.hpp deleted file mode 100644 index cc68803..0000000 --- a/include/Configuration.hpp +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -#include -#include - -class Configuration : public QObject { - Q_OBJECT - -public: - using QObject::QObject; - - QUrl newTabUrl = QUrl("https://lite.duckduckgo.com"); -}; diff --git a/include/InputMediator.hpp b/include/InputMediator.hpp deleted file mode 100644 index 7194ff9..0000000 --- a/include/InputMediator.hpp +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once - -#include -#include - -#include "LuaRuntime.hpp" -#include "keymap/KeymapEvaluator.hpp" -#include "utils.hpp" -#include "widgets/WebViewStack.hpp" - -class InputMediator : public QObject { - Q_OBJECT - -public: - InputMediator(WebViewStack *webViewStack, LuaRuntime *luaRuntime, - KeymapEvaluator *keymapEvaluator); - ~InputMediator(); - - DELEGATE(webViewStack, openUrl, openUrl) - DELEGATE(webViewStack, currentUrl, currentUrl) - DELEGATE(webViewStack, next, nextWebView) - DELEGATE(webViewStack, previous, previousWebView) - DELEGATE(webViewStack, closeCurrent, closeCurrentWebView) - DELEGATE(keymapEvaluator, evaluate, evaluateKeymap) - -private: - void evaluateCommand(QString command); - -private: - WebViewStack *webViewStack; - LuaRuntime *luaRuntime; - KeymapEvaluator *keymapEvaluator; -}; diff --git a/include/LuaRuntime.hpp b/include/LuaRuntime.hpp deleted file mode 100644 index 5bfc82c..0000000 --- a/include/LuaRuntime.hpp +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once -#include -#include - -#include "widgets/WebViewStack.hpp" - -class LuaRuntime : public QObject { - Q_OBJECT - -public: - static LuaRuntime *instance() { - static LuaRuntime inst; - return &inst; - } - - void evaluate(QString code); - -signals: - void urlOpened(QString url, OpenType openType); - -protected: - LuaRuntime(); - ~LuaRuntime(); - static int lua_onUrlOpen(lua_State *state); - static int lua_onUrlTabOpen(lua_State *state); - -private: - lua_State *state; -}; diff --git a/include/keymap/KeySeqParser.hpp b/include/keymap/KeySeqParser.hpp deleted file mode 100644 index fac2546..0000000 --- a/include/keymap/KeySeqParser.hpp +++ /dev/null @@ -1,44 +0,0 @@ -#pragma once - -#include -#include -#include - -struct KeyChord { - Qt::KeyboardModifiers mod; - Qt::Key key; -}; -bool operator==(const KeyChord a, const KeyChord b); - -typedef QList KeySequence; - -enum KeyMatchType { - NoMatch, - Match, - Pending, -}; - -class KeySeqParser { -public: - static const KeyMatchType keySequenceMatch(const KeySequence target, - const KeySequence current) { - for (int i = 0; i < target.length(); i++) { - if (current.length() <= i) - return KeyMatchType::Pending; - - if (target[i].key != current[i].key || - !target[i].mod.testFlags(current[i].mod)) - return KeyMatchType::NoMatch; - } - - return KeyMatchType::Match; - } - -public: - KeySeqParser(); - - KeySequence parse(QString keySequence); - -private: - Qt::Key parseKey(QString keyName); -}; diff --git a/include/keymap/KeymapEvaluator.hpp b/include/keymap/KeymapEvaluator.hpp deleted file mode 100644 index db93900..0000000 --- a/include/keymap/KeymapEvaluator.hpp +++ /dev/null @@ -1,42 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include - -#include "keymap/KeySeqParser.hpp" -#include "utils.hpp" - -typedef std::function KeyAction; - -struct KeyMap { - KeySequence keySequence; - KeyAction action; -}; - -enum KeyMode { Normal, Insert }; - -class KeymapEvaluator : public QObject { - Q_OBJECT - -public: - KeymapEvaluator(); - - void addKeymap(KeyMode mode, QString key, KeyAction action); - bool evaluate(Qt::KeyboardModifiers modifiers, Qt::Key key); - - DEFINE_SETTER(setCurrentMode, currentMode) - DEFINE_GETTER(getCurrentMode, currentMode) - -private: - const QList *currentModeKeys(); - bool isInsertableMode(); - -private: - QMap> modalKeys; - KeySeqParser keySeqParser; - KeyMode currentMode = KeyMode::Normal; - KeySequence activeKeySequence; -}; diff --git a/include/utils.hpp b/include/utils.hpp deleted file mode 100644 index 0650ac2..0000000 --- a/include/utils.hpp +++ /dev/null @@ -1,11 +0,0 @@ - -#define DELEGATE(OBJ, METHOD, METHOD_AS) \ - template decltype(auto) METHOD_AS(Args &&...args) { \ - return OBJ->METHOD(std::forward(args)...); \ - } - -#define DEFINE_SETTER(METHOD, PROPERTY) \ - template void METHOD(Arg val) { PROPERTY = val; } - -#define DEFINE_GETTER(METHOD, EXPR) \ - template decltype(auto) METHOD() { return EXPR; } diff --git a/include/widgets/MainWindow.hpp b/include/widgets/MainWindow.hpp deleted file mode 100644 index 2bbc42e..0000000 --- a/include/widgets/MainWindow.hpp +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once - -#include - -#include "Configuration.hpp" -#include "InputMediator.hpp" - -class MainWindow : public QMainWindow { -public: - MainWindow(); - -private: - void keyPressEvent(QKeyEvent *event) override; - bool eventFilter(QObject *object, QEvent *event) override; - -private: - InputMediator *inputMediator; - Configuration configuration; -}; diff --git a/include/widgets/WebView.hpp b/include/widgets/WebView.hpp deleted file mode 100644 index 8a95139..0000000 --- a/include/widgets/WebView.hpp +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -#include -#include -#include -#include - -class WebView : public QWebEngineView { - Q_OBJECT - -public: - WebView(QWebEngineProfile *profile); -}; diff --git a/include/widgets/WebViewStack.hpp b/include/widgets/WebViewStack.hpp deleted file mode 100644 index e5b7ecc..0000000 --- a/include/widgets/WebViewStack.hpp +++ /dev/null @@ -1,55 +0,0 @@ -#pragma once - -#include -#include -#include - -#include "Configuration.hpp" -#include "widgets/WebView.hpp" - -enum OpenType { OpenUrl, OpenUrlInTab, OpenUrlInBgTab, OpenUrlInWindow }; - -struct Tab { - QString url; - QString title; -}; - -class WebViewStack : public QWidget { - Q_OBJECT - -public: - inline static const QUrl NewtabURL = QUrl("about:blank"); - -public: - WebViewStack(const Configuration *configuration, - QWebEngineProfile *profile = new QWebEngineProfile, - QWidget *parent = nullptr); - - void openUrl(QUrl url, OpenType openType = OpenType::OpenUrl); - - std::vector urls(); - QList getTabList(); - u_int32_t currentWebViewIndex(); - u_int32_t count(); - QUrl currentUrl(); - - void focusWebView(long index); - void next(); - void previous(); - - void close(long index); - void closeCurrent(); - -private: - void setCurrentUrl(QUrl url); - WebView *createNewWebView(QUrl url, bool focus = false); - -private slots: - void onNewWebViewRequest(QWebEngineNewWindowRequest &request); - -private: - const Configuration *configuration; - QWebEngineProfile *profile; - QStackedLayout *layout; - QList webViewList; -}; -- cgit v1.3.1