diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 76 | ||||
-rw-r--r-- | src/about/CMakeLists.txt | 12 | ||||
-rw-r--r-- | src/about/aboutdialog.cpp | 6 | ||||
-rw-r--r-- | src/about/meson.build | 21 | ||||
-rw-r--r-- | src/browser.cpp | 13 | ||||
-rw-r--r-- | src/main.cpp | 117 | ||||
-rw-r--r-- | src/version.h.in | 8 | ||||
-rw-r--r-- | src/webengine/CMakeLists.txt | 10 |
8 files changed, 131 insertions, 132 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..b1ec891 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,76 @@ +# settings.h +add_custom_target(settings.h + ${PROJECT_SOURCE_DIR}/scripts/gen-default-cfg.py + --kconfig ${PROJECT_SOURCE_DIR}/Kconfig + --dotconfig ${PROJECT_SOURCE_DIR}/linux/.config + --input ${CMAKE_CURRENT_LIST_DIR}/settings.h.in + --output settings.h + BYPRODUCTS settings.h +) + +# version.h +configure_file(version.h.in version.h) + +add_executable(poi + applicationmenu.cpp + applicationmenu.h + bookmarks/bookmarksform.ui + bookmarks/bookmarkstoolbar.cpp + bookmarks/bookmarkstoolbar.h + bookmarks/bookmarkswidget.cpp + bookmarks/bookmarkswidget.h + #bookmarks/builtins.cpp + bookmarks/editbookmarkdialog.cpp + bookmarks/editbookmarkdialog.h + bookmarks/editbookmarkdialog.ui + browser.cpp + browser.h + #builtins.cpp + #builtins.h + #crashhandler.cpp + #crashhandler.h + #crashhandler_dummy.cpp + main.cpp + mainwindow/addressbar.cpp + mainwindow/addressbar.h + mainwindow/addressbar.ui + mainwindow/mainwindow.cpp + mainwindow/mainwindow.h + mainwindow/menubar.cpp + mainwindow/menubar.h + mainwindow/widgets/completer.cpp + mainwindow/widgets/completer.h + mainwindow/widgets/dockwidget.cpp + mainwindow/widgets/dockwidget.h + mainwindow/widgets/menusearch.cpp + mainwindow/widgets/menusearch.h + mainwindow/widgets/navigationbar.cpp + mainwindow/widgets/navigationbar.h + mainwindow/widgets/searchform.cpp + mainwindow/widgets/searchform.h + mainwindow/widgets/searchform.ui + mainwindow/widgets/urllineedit.cpp + mainwindow/widgets/urllineedit.h + session/savesessiondialog.cpp + session/savesessiondialog.h + session/savesessiondialog.ui + session/sessiondialog.cpp + session/sessiondialog.h + session/sessiondialog.ui + subwindow/subwindow.cpp + subwindow/subwindow.h + subwindow/tabwidget.cpp + subwindow/tabwidget.h + util.cpp + util.h + wallet/wallet.cpp + wallet/wallet.h +) +target_sources(poi PRIVATE settings.h) +target_include_directories(poi PRIVATE ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_CURRENT_BINARY_DIR}) +target_link_libraries(poi + PRIVATE SingleApplication::SingleApplication spdlog::spdlog + PRIVATE bookmarks configuration downloads session_formats urlfilter + PRIVATE about webengine +) + diff --git a/src/about/CMakeLists.txt b/src/about/CMakeLists.txt new file mode 100644 index 0000000..f1e2c41 --- /dev/null +++ b/src/about/CMakeLists.txt @@ -0,0 +1,12 @@ +add_library(about STATIC + aboutdialog.cpp aboutdialog.h aboutdialog.ui + aboutplugin.cpp aboutplugin.h aboutplugin.ui +) +target_link_libraries(about PUBLIC Qt6::Widgets Qt6::SvgWidgets) +target_include_directories(about PUBLIC ${CMAKE_CURRENT_LIST_DIR}) + +# tests +add_executable(test_about test/main.cpp) +target_link_libraries(test_about PRIVATE about) +add_test(NAME about_dialog COMMAND $<TARGET_FILE:test_about> -platform offscreen) +set_property(TEST about_dialog PROPERTY ENVIRONMENT autoclose=1) diff --git a/src/about/aboutdialog.cpp b/src/about/aboutdialog.cpp index 894b1ec..1013866 100644 --- a/src/about/aboutdialog.cpp +++ b/src/about/aboutdialog.cpp @@ -8,7 +8,6 @@ #include "aboutdialog.h" #include "ui_aboutdialog.h" -#include <version.h> // compiler // clang also defines __GNUC__, so we need to check for clang first @@ -59,7 +58,7 @@ AboutDialog::AboutDialog(QWidget *parent) "<p>This program is distributed in the hope that it will be useful, but without any warranty.</p>" "<p>You can read the full terms of the license on <a href='https://www.gnu.org/licenses/gpl-3.0.en.html'>the GNU website</a>.</p>")); - ui->detailsLabel->setText(tr("<p>Version " poi_Version "</p>" + ui->detailsLabel->setText(tr("<p>Version %1</p>" "<p>Compiled with " compiler "</p>" "<p>Libraries: <ul>" "<li><a href='https://www.qt.io/'>Qt5</a> " QT_VERSION_STR "</li>" @@ -69,7 +68,8 @@ AboutDialog::AboutDialog(QWidget *parent) #ifdef CONFIG_USEBREAKPAD "<li><a href='https://chromium.googlesource.com/breakpad/breakpad'>Breakpad</a></li>" #endif - "</ul></p>")); + "</ul></p>") + .arg(qApp->applicationVersion())); } AboutDialog::~AboutDialog() diff --git a/src/about/meson.build b/src/about/meson.build deleted file mode 100644 index 49274a8..0000000 --- a/src/about/meson.build +++ /dev/null @@ -1,21 +0,0 @@ -about_moc = mod_qt5.preprocess( - moc_headers: ['aboutdialog.h', 'aboutplugin.h'], - ui_files: ['aboutdialog.ui', 'aboutplugin.ui'], - dependencies: dep_qt5 -) - -dep_about = declare_dependency( - include_directories: '.', - link_with: static_library('about', - [ 'aboutdialog.cpp', 'aboutplugin.cpp', about_moc, version_h], - dependencies: [dep_qt5]) -) - -poi_sourceset.add(dep_about) - -test('about dialog', executable('about', - sources: 'test/main.cpp', - dependencies: [ dep_qt5, dep_about, dep_catch ]), - args: [ '-platform', 'offscreen' ], - env: 'autoclose=1' -) diff --git a/src/browser.cpp b/src/browser.cpp index f748e2f..a2ae8c9 100644 --- a/src/browser.cpp +++ b/src/browser.cpp @@ -31,7 +31,7 @@ #include <QTimer> #include <QTranslator> #include <QVersionNumber> -#include <pluginloader.h> +// #include <pluginloader.h> #include <spdlog/spdlog.h> #include <version.h> @@ -142,22 +142,31 @@ bool Browser::loadPlugin(const QString &path) } Configuration conf; + bool loaded = false; + +#ifdef HAVE_PLUGINLOADER const auto state = PluginLoader::signature_state( conf.value<bool>("plugins.signature.ignored").value(), conf.value<bool>("plugins.signature.checked").value(), conf.value<bool>("plugins.signature.enforced").value()); auto *loader = new PluginLoader(path, state, this); - const bool loaded = loader->load(); + loaded = loader->load(); +#endif if(!loaded) { +#ifdef HAVE_PLUGINLOADER delete loader; +#endif return false; } +#ifdef HAVE_PLUGINLOADER auto *info = new PluginInfo(loader); m_plugins.append(info); emit pluginAdded(loader); +#endif + return true; } diff --git a/src/main.cpp b/src/main.cpp index aa08236..60c3031 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7,36 +7,16 @@ */ #include "browser.h" -#include "builtins.h" #include "configuration.h" -#include "crashhandler.h" #include "session/sessiondialog.h" #include "session_json.hpp" #include "settings.h" -#include "util.h" -#include "version.h" +#include <QCommandLineParser> #include <QFile> #include <QPluginLoader> #include <QStandardPaths> -#include <iostream> -#include <memory> -#include <pluginloader.h> #include <spdlog/spdlog.h> -// a helper function to join the keys of a command_map into a string -inline std::string join_keys(const command_map &map, const std::string sep = ", ") -{ - std::vector<std::string> keys(map.size()); - std::transform(map.begin(), map.end(), keys.begin(), [](auto pair) { return pair.first; }); - std::sort(keys.begin(), keys.end()); - - std::string k; - std::for_each(keys.begin(), keys.end() - 1, [&k, &sep](const std::string &piece) { k += piece + sep; }); - k += keys.back(); - - return k; -} - int main(int argc, char **argv) { // change log pattern @@ -45,105 +25,30 @@ int main(int argc, char **argv) spdlog::set_level(spdlog::level::debug); // Set global log level to debug #endif - const command_map commands{ - { "configuration", builtins::configuration }, - { "bookmarks", builtins::bookmarks }, - }; - - const std::vector<std::string> args(argv + 1, argv + argc); - args::ArgumentParser parser("smolbote: yet another no-frills browser", "Subcommands: " + join_keys(commands)); - parser.Prog(argv[0]); - - args::HelpFlag cmd_help(parser, "help", "Display this help message.", { 'h', "help" }); - args::Flag cmd_version(parser, "version", "Display version information.", { 'v', "version" }); - args::Flag cmd_build(parser, "build", "Display build commit.", { 'b', "build" }); - - args::ValueFlag<std::string> cmd_config(parser, "config", "Set the configuration file.", { 'c', "config" }); - - args::Flag cmd_noRemote(parser, "no-remote", "Do not accept or send remote commands.", { "no-remote" }); - - args::Flag cmd_pickSession(parser, "pick-session", "Show all available sessions and select which one to open", { "pick-session" }); - args::ValueFlag<std::string> cmd_session(parser, "session", "Open the specified session.", { 's', "session" }); - - args::PositionalList<std::string> cmd_args(parser, "URL(s)", "List of URLs to open"); - cmd_args.KickOut(true); - - try { - auto next = parser.ParseArgs(args); - - if(cmd_version) - return builtins::version(); - if(cmd_build) - return builtins::build(); - - // create and load configuration - spdlog::debug("Loading configuration {}", init_conf(args::get(cmd_config))); - - if(cmd_args) { - const auto front = args::get(cmd_args).front(); - const auto cmd = commands.find(front); - if(cmd != commands.end()) { - return cmd->second(argv[0], next, std::end(args)); - } - } - - } catch(args::Help &) { - std::cout << parser; - return 0; - - } catch(args::Error &e) { - std::cerr << e.what() << std::endl; - std::cerr << parser; - return -1; - } + init_conf(""); // argc, argv, allowSecondary Browser app(argc, argv); // set this, otherwise the webview becomes black when using a stylesheet app.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings, true); - { - Configuration conf; - - if(conf.value<bool>("usebreakpad").value()) { - /* FIXME - CrashHandler::Context ctx( - conf.value<std::string>("path.crashdump").value(), - conf.value<std::string>("path.crashhandler").value()); - - if(CrashHandler::install_handler(ctx)) { - spdlog::info("Installed breakpad crash handler: {}", ctx.dumppath); - } else { - spdlog::warn("Failed to install breakpad crash handler: {}", ctx.dumppath); - } - */ - } - - // load plugins - for(const QString &path : Util::files(conf.value<QString>("plugins.path").value(), { "*.so", "*.dll" })) { - if(app.loadPlugin(path)) { - spdlog::debug("Loaded plugin [{}]", qUtf8Printable(path)); - } else { - spdlog::warn("Failed loading plugin [{}]", qUtf8Printable(path)); - } - } - } + QCommandLineParser parser; + parser.addHelpOption(); + parser.addPositionalArgument("url", "URLs to open"); + parser.process(app); const auto profile = []() { Configuration c; return c.value<QString>("profile.default").value(); }(); - QStringList urls; - for(const auto &u : args::get(cmd_args)) { - urls.append(QString::fromStdString(u)); - } + QStringList urls = parser.positionalArguments(); if(urls.isEmpty()) { urls.append(QString()); } // if app is primary, create new sessions from received messages - if(app.isPrimary() && !cmd_noRemote) { + if(app.isPrimary() /*&& !cmd_noRemote*/) { QObject::connect(&app, &Browser::receivedMessage, &app, [&app](quint32 instanceId, QByteArray message) { Q_UNUSED(instanceId); JsonSession session(message); @@ -153,7 +58,7 @@ int main(int argc, char **argv) { const auto session = [&]() { - if(cmd_session) { + /*if(cmd_session) { QFile sessionJson(QString::fromStdString(args::get(cmd_session))); if(sessionJson.open(QIODevice::ReadOnly | QIODevice::Text)) { return JsonSession(sessionJson.readAll()); @@ -164,11 +69,11 @@ int main(int argc, char **argv) if(const auto pick = dlg.pickSession()) { return JsonSession(pick.value()); } - } + }*/ return JsonSession(profile, urls); }(); - if(app.isPrimary() || cmd_noRemote) { + if(app.isPrimary() /*|| cmd_noRemote */) { app.open(session.get()); } else { // app is secondary and not standalone diff --git a/src/version.h.in b/src/version.h.in new file mode 100644 index 0000000..b387811 --- /dev/null +++ b/src/version.h.in @@ -0,0 +1,8 @@ +#ifndef SMOLBOTE_VERSION_H +#define SMOLBOTE_VERSION_H + +// output of 'git describe --long --abbrev=40': +// x.y.z-0-g0123456789012345678901234567890123456789 +#define poi_Version "@CMAKE_PROJECT_VERSION@" + +#endif // SMOLBOTE_VERSION_H diff --git a/src/webengine/CMakeLists.txt b/src/webengine/CMakeLists.txt new file mode 100644 index 0000000..704a6d0 --- /dev/null +++ b/src/webengine/CMakeLists.txt @@ -0,0 +1,10 @@ +add_library(webengine STATIC + urlinterceptor.cpp urlinterceptor.h + webpage.cpp webpage.h + webprofile.cpp webprofile.h + webprofilemanager.cpp webprofilemanager.h + webviewcontextmenu.cpp webviewcontextmenu.h + webview.cpp webview.h +) +target_link_libraries(webengine PUBLIC Qt6::WebEngineCore Qt6::WebEngineWidgets) +target_include_directories(webengine PUBLIC ${CMAKE_CURRENT_LIST_DIR} ${PROJECT_SOURCE_DIR}/include) |