diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/browser.cpp | 37 | ||||
-rw-r--r-- | src/conf.hpp.in | 33 | ||||
-rw-r--r-- | src/main.cpp | 17 | ||||
-rw-r--r-- | src/mainwindow/mainwindow.cpp | 13 | ||||
-rw-r--r-- | src/meson.build | 48 | ||||
-rw-r--r-- | src/settings.h.in | 29 | ||||
-rw-r--r-- | src/webengine/webview.cpp | 4 |
7 files changed, 68 insertions, 113 deletions
diff --git a/src/browser.cpp b/src/browser.cpp index b3039a5..c3cbd2f 100644 --- a/src/browser.cpp +++ b/src/browser.cpp @@ -9,17 +9,21 @@ #include "browser.h" #include "aboutdialog.h" #include "aboutplugin.h" -#include "mainwindow/addressbar.h" +#include "adblock/adblocklist.h" #include "bookmarkswidget.h" -#include "conf.hpp" #include "configuration.h" #include "downloadswidget.h" +#include "hostlist/hostlist.h" +#include "mainwindow/addressbar.h" #include "mainwindow/mainwindow.h" -#include "webengine/webprofilemanager.h" +#include "mainwindow/menubar.h" #include "subwindow/subwindow.h" +#include "urlfilter.h" #include "util.h" #include "webengine/urlinterceptor.h" #include "webengine/webprofile.h" +#include "webengine/webprofilemanager.h" +#include "webengine/webview.h" #include <QAction> #include <QDir> #include <QFileDialog> @@ -27,30 +31,25 @@ #include <QFileInfoList> #include <QJsonArray> #include <QJsonDocument> +#include <QLibraryInfo> #include <QPluginLoader> #include <QTimer> +#include <QTranslator> #include <QVersionNumber> #include <plugininterface.h> -#include <version.h> -#include "mainwindow/menubar.h" -#include "webengine/webview.h" -#include "urlfilter.h" -#include "adblock/adblocklist.h" -#include "hostlist/hostlist.h" -#include <spdlog/spdlog.h> #include <pluginloader.h> -#include <QLibraryInfo> -#include <QTranslator> +#include <spdlog/spdlog.h> +#include <version.h> Browser::Browser(int &argc, char *argv[], bool allowSecondary) : SingleApplication(argc, argv, allowSecondary, SingleApplication::User | SingleApplication::SecondaryNotification | SingleApplication::ExcludeAppVersion) { - setApplicationName(CONFIG_POI_NAME); - setWindowIcon(QIcon(CONFIG_POI_ICON)); + Configuration conf; + + setApplicationName(conf.value<QString>("poi.name").value()); + setWindowIcon(QIcon(conf.value<QString>("poi.icon").value())); setApplicationVersion(QVersionNumber::fromString(QLatin1String(poi_Version)).toString()); - Configuration conf; - if(const auto _translation = conf.value<QString>("browser.translation")) { auto *translator = new QTranslator(this); if(translator->load(_translation.value())) @@ -70,7 +69,6 @@ Browser::Browser(int &argc, char *argv[], bool allowSecondary) if(auto iconTheme = conf.value<QString>("browser.iconTheme")) { QIcon::setThemeName(iconTheme.value()); } - } Browser::~Browser() @@ -104,7 +102,7 @@ QPair<QString, Profile *> Browser::loadProfile(const QString &id, bool isOffTheR { Configuration conf; - const QString _id = [id](){ + const QString _id = [id]() { // if id contains a separator, it should be a path if(id.contains(QDir::separator())) { return QFileInfo(id).baseName(); @@ -313,7 +311,8 @@ void Browser::addPluginTo(PluginInfo *info, MainWindow *window) }); auto *removeAction = pluginMenu->addAction(tr("Remove")); - connect(removeAction, &QAction::triggered, this, [this, info]() {; + connect(removeAction, &QAction::triggered, this, [this, info]() { + ; m_plugins.removeOne(info); delete info; }); diff --git a/src/conf.hpp.in b/src/conf.hpp.in deleted file mode 100644 index ed97730..0000000 --- a/src/conf.hpp.in +++ /dev/null @@ -1,33 +0,0 @@ -/* - * This file is part of smolbote. It's copyrighted by the contributors recorded - * in the version control history of the file, available from its original - * location: https://neueland.iserlohn-fortress.net/gitea/aqua/smolbote - * - * SPDX-License-Identifier: GPL-3.0 - */ - -#include "configuration.h" -#include <fstream> - -#mesondefine CONFIG_POI_NAME -#mesondefine CONFIG_POI_ICON -#mesondefine CONFIG_POI_CFG_PATH - -#mesondefine CONFIG_QTBUG_65223 - -inline void init_conf(const std::string &path) -{ - auto value_map = std::make_unique<Configuration, std::initializer_list<std::pair<std::string, conf_value_t>>>({ - @conf_init_list@ - }); - - std::fstream fs; - fs.open(path, std::fstream::in); - if(fs.is_open()) { - value_map->read(fs); - fs.close(); - } - - Configuration::move_global(std::move(value_map)); -} - diff --git a/src/main.cpp b/src/main.cpp index 7889c08..f4f2b78 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -8,11 +8,11 @@ #include "browser.h" #include "builtins.h" -#include "conf.hpp" #include "configuration.h" #include "crashhandler.h" #include "session/session.h" #include "session/sessiondialog.h" +#include "settings.h" #include "util.h" #include "version.h" #include <QFile> @@ -91,20 +91,7 @@ int main(int argc, char **argv) return builtins::build(); // create and load configuration - const std::string config_path = [&]() { - std::string path; - if(cmd_config) - path = args::get(cmd_config); - else - path = std::string(CONFIG_POI_CFG_PATH); - - if(path.front() == '~') - path.replace(0, 1, QStandardPaths::writableLocation(QStandardPaths::HomeLocation).toStdString()); - - return path; - }(); - spdlog::debug("Opening config file {}", config_path); - init_conf(config_path); + init_conf(args::get(cmd_config)); if(cmd_args) { const auto front = args::get(cmd_args).front(); diff --git a/src/mainwindow/mainwindow.cpp b/src/mainwindow/mainwindow.cpp index 292d922..558fe49 100644 --- a/src/mainwindow/mainwindow.cpp +++ b/src/mainwindow/mainwindow.cpp @@ -9,15 +9,14 @@ #include "mainwindow.h" #include "addressbar.h" #include "browser.h" -#include "conf.hpp" #include "configuration.h" #include "menubar.h" -#include "webengine/webprofilemanager.h" #include "session/session.h" #include "session/sessiondialog.h" #include "subwindow/subwindow.h" -#include "webengine/webview.h" #include "webengine/webprofile.h" +#include "webengine/webprofilemanager.h" +#include "webengine/webview.h" #include "widgets/dockwidget.h" #include "widgets/navigationbar.h" #include "widgets/searchform.h" @@ -35,9 +34,6 @@ #include <QStatusBar> #include <QToolBar> #include <QUrl> -#ifdef CONFIG_PLASMA_BLUR -#include <KWindowEffects> -#endif MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) @@ -46,11 +42,6 @@ MainWindow::MainWindow(QWidget *parent) m_menuBar = new MenuBar(this); this->setMenuBar(m_menuBar); -#ifdef CONFIG_PLASMA_BLUR - setAttribute(Qt::WA_TranslucentBackground, true); - KWindowEffects::enableBlurBehind(this->winId(), true); -#endif - Configuration config; // create UI diff --git a/src/meson.build b/src/meson.build index 3494112..25f94f0 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,5 +1,13 @@ -# poi -poi_moc = mod_qt5.preprocess( +python = import('python') +python3 = python.find_installation('python3') + +poi_settings_h = custom_target('default_config_value', + input: files('../scripts/gen-default-cfg.py', '../Kconfig', '..'/host_machine.system()/'.config', 'settings.h.in'), + output: 'settings.h', + command: [ python3, '@INPUT0@', '--kconfig=@INPUT1@', '--dotconfig=@INPUT2@', '--input=@INPUT3@', '--output=@OUTPUT@' ] +) + +poi_sourceset.add(mod_qt5.preprocess( moc_headers: ['browser.h', 'mainwindow/mainwindow.h', 'mainwindow/addressbar.h', 'mainwindow/menubar.h', 'mainwindow/widgets/completer.h', 'mainwindow/widgets/urllineedit.h', 'mainwindow/widgets/dockwidget.h', 'mainwindow/widgets/menusearch.h', 'mainwindow/widgets/navigationbar.h', 'mainwindow/widgets/searchform.h', 'session/savesessiondialog.h', 'session/sessiondialog.h', 'session/sessionform.h', @@ -9,14 +17,10 @@ poi_moc = mod_qt5.preprocess( qresources: '../data/resources.qrc', rcc_extra_arguments: ['--format-version=1'], dependencies: dep_qt5 -) +)) -poi = executable(get_option('poiName'), install: true, - cpp_args: ['-DQAPPLICATION_CLASS=QApplication'], - dependencies: [dep_qt5, dep_spdlog, dep_SingleApplication, dep_args, optional_deps, - dep_about, dep_bookmarks, dep_configuration, dep_downloads, dep_pluginloader, dep_urlfilter], - include_directories: [include], - sources: ['main.cpp', 'builtins.cpp', 'crashhandler.cpp', poi_moc, version_h, +poi_sourceset.add(files( + 'main.cpp', 'builtins.cpp', 'crashhandler.cpp', 'browser.cpp', 'util.cpp', 'util.h', @@ -43,29 +47,9 @@ poi = executable(get_option('poiName'), install: true, 'webengine/webview.cpp', 'webengine/webprofile.cpp', 'webengine/webprofilemanager.cpp', - interfaces_moc, - 'wallet/wallet.cpp', 'wallet/wallet.h'] + 'wallet/wallet.cpp', 'wallet/wallet.h' +), + interfaces_moc, version_h, poi_settings_h ) -# install .desktop file and firejail profile for systems in this array -if ['linux'].contains(host_machine.system()) - conf = configuration_data({ - 'exec_poi': get_option('prefix') / get_option('bindir') / get_option('poiName'), - 'firejail': get_option('firejail'), - 'firejail_profile': get_option('prefix') / get_option('libdir') / 'smolbote/poi.profile' - }) - - # application icon - install_data('../data/poi.svg', install_dir: get_option('datadir') / 'icons/hicolor/scalable/apps') - - # firejail profile - install_data('../linux/firejail/poi.profile', install_dir: get_option('libdir') / 'smolbote') - - # Install .desktop to $prefix/share/applications - desktop_install_dir = get_option('datadir') / 'applications' - configure_file(input: '../linux/poi.desktop.in', output: 'poi.desktop', configuration: conf, install_dir: desktop_install_dir ) - configure_file(input: '../linux/poi_firejail.desktop.in', output: 'poi_firejail.desktop', configuration: conf, install_dir: desktop_install_dir ) - configure_file(input: '../linux/poi_picksession.desktop.in', output: 'poi_picksession.desktop', configuration: conf, install_dir: desktop_install_dir ) - -endif diff --git a/src/settings.h.in b/src/settings.h.in new file mode 100644 index 0000000..a4b5159 --- /dev/null +++ b/src/settings.h.in @@ -0,0 +1,29 @@ +#pragma once + +#include <QStandardPaths> +#include <configuration.h> +#include <fstream> + +inline void init_conf(const std::string &path) +{ + + const std::string cfgpath = [&]() { + auto p = path; + if(p.front() == '~') + p.replace(0, 1, QStandardPaths::writableLocation(QStandardPaths::HomeLocation).toStdString()); + return p; + }(); + + auto value_map = std::make_unique<Configuration, std::initializer_list<std::pair<std::string, conf_value_t>>>({ + @__DEFAULT_CFG__ + }); + + std::fstream fs; + fs.open(path, std::fstream::in); + if(fs.is_open()) { + value_map->read(fs); + fs.close(); + } + + Configuration::move_global(std::move(value_map)); +} diff --git a/src/webengine/webview.cpp b/src/webengine/webview.cpp index 930b747..4fa227f 100644 --- a/src/webengine/webview.cpp +++ b/src/webengine/webview.cpp @@ -8,7 +8,6 @@ #include "webview.h" #include "browser.h" -#include "conf.hpp" #include "subwindow/subwindow.h" #include "wallet/wallet.h" #include "webpage.h" @@ -57,13 +56,12 @@ WebView::WebView(WebProfile *profile, QWidget *parent) m_loaded = true; }); -#ifdef CONFIG_QTBUG_65223 + // TODO for Qt 5.15, check for fix on QTBUG 65223 connect(this, &QWebEngineView::loadProgress, this, [this](int progress) { if(progress == 100) { emit loadFinished(true); } }); -#endif } void WebView::setProfile(WebProfile *profile) |