diff options
| author | Akshay Nair <phenax5@gmail.com> | 2025-04-20 19:20:33 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2025-05-02 16:15:59 +0530 |
| commit | 2f1e73741da625c173156102457d5442b27cd953 (patch) | |
| tree | f59bd3f896fd5473d71a3fdaf7fa4833add248b5 /src/widgets | |
| parent | 31872258b18e81d5f973080e5130ebf49db3271f (diff) | |
| download | null-browser-2f1e73741da625c173156102457d5442b27cd953.tar.gz null-browser-2f1e73741da625c173156102457d5442b27cd953.zip | |
Add configuration directory loading + --config-dir cli arg
Diffstat (limited to '')
| -rw-r--r-- | src/widgets/BrowserApp.cpp | 17 | ||||
| -rw-r--r-- | src/widgets/BrowserApp.hpp | 5 |
2 files changed, 17 insertions, 5 deletions
diff --git a/src/widgets/BrowserApp.cpp b/src/widgets/BrowserApp.cpp index 502d930..1362941 100644 --- a/src/widgets/BrowserApp.cpp +++ b/src/widgets/BrowserApp.cpp @@ -1,3 +1,4 @@ +#include <QDir> #include <QKeyEvent> #include <QtCore> @@ -6,7 +7,7 @@ #include "widgets/BrowserApp.hpp" #include "widgets/BrowserWindow.hpp" -BrowserApp::BrowserApp() { +BrowserApp::BrowserApp(Configuration &configuration) : configuration(configuration) { auto &lua = LuaRuntime::instance(); lua.start_event_loop(); @@ -17,8 +18,18 @@ BrowserApp::BrowserApp() { // Global event filter qApp->installEventFilter(this); - // NOTE: TMP - lua.load_file_sync("./config.lua"); + qDebug() << "Config dir:" << configuration.get_config_dir().path(); + + // Load lua directory into package path + lua.append_package_path(configuration.get_config_lua_dir()); + + // Load init.lua + auto lua_init_file = configuration.get_config_lua_init_file(); + if (QFile::exists(lua_init_file)) { + lua.load_file_sync(lua_init_file); + } else { + qWarning() << "Unable to find init.lua:" << lua_init_file; + } // Initializes profile for (auto *profile : profiles) { diff --git a/src/widgets/BrowserApp.hpp b/src/widgets/BrowserApp.hpp index 90d1ae7..c659763 100644 --- a/src/widgets/BrowserApp.hpp +++ b/src/widgets/BrowserApp.hpp @@ -1,5 +1,6 @@ #pragma once +#include "Configuration.hpp" #include "widgets/BrowserWindow.hpp" #include <qlist.h> @@ -7,7 +8,7 @@ class BrowserApp : public QObject { Q_OBJECT public: - BrowserApp(); + BrowserApp(Configuration &configuration); BrowserWindow *create_window(const QStringList &urls = {}); @@ -15,7 +16,7 @@ protected: bool eventFilter(QObject *target, QEvent *event) override; private: - Configuration configuration; + Configuration &configuration; QWebEngineProfile default_profile{"default"}; QList<QWebEngineProfile *> profiles{&default_profile}; }; |
