diff options
Diffstat (limited to 'src/widgets')
| -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}; }; |
