diff options
-rw-r--r-- | lib/about/CMakeLists.txt | 2 | ||||
-rw-r--r-- | lib/about/aboutdialog.cpp | 28 | ||||
-rw-r--r-- | plugins/ProfileEditor/ProfileEditor.json | 6 | ||||
-rw-r--r-- | plugins/interfaces.h | 4 | ||||
-rw-r--r-- | src/browser.cpp | 6 | ||||
-rw-r--r-- | src/browser.h | 5 |
6 files changed, 41 insertions, 10 deletions
diff --git a/lib/about/CMakeLists.txt b/lib/about/CMakeLists.txt index be506fe..7f53e8d 100644 --- a/lib/about/CMakeLists.txt +++ b/lib/about/CMakeLists.txt @@ -15,6 +15,8 @@ add_library(about target_include_directories(about PRIVATE ${Boost_INCLUDE_DIRS} PRIVATE ${CMAKE_BINARY_DIR}/src + PRIVATE ${CMAKE_SOURCE_DIR}/src + PRIVATE ${CMAKE_SOURCE_DIR}/plugins ) target_link_libraries(about Qt5::Widgets) diff --git a/lib/about/aboutdialog.cpp b/lib/about/aboutdialog.cpp index 6b4ebb8..e716217 100644 --- a/lib/about/aboutdialog.cpp +++ b/lib/about/aboutdialog.cpp @@ -11,6 +11,7 @@ #include <QtWebEngine/QtWebEngineVersion> #include <boost/version.hpp> #include "version.h" +#include <browser.h> // compiler // clang also defines __GNUC__, so we need to check for clang first @@ -24,6 +25,21 @@ #define compiler "unknown compiler" #endif +inline QString getPluginList() +{ + auto *browser = qobject_cast<Browser*>(qApp); + Q_CHECK_PTR(browser); + + QString plugins; + for(const Plugin &p : browser->plugins()) { + plugins.append(QString("<li>%1 (%2)</li>").arg(p.name, p.author)); + } + if(!plugins.isEmpty()) + plugins = "Loaded plugins: <ul>" + plugins + "</ul"; + + return plugins; +} + AboutDialog::AboutDialog(QWidget *parent) : QDialog(parent) , ui(new Ui::AboutDialog) @@ -36,7 +52,8 @@ AboutDialog::AboutDialog(QWidget *parent) auto *aboutLabel = new QLabel(this); aboutLabel->setWordWrap(true); aboutLabel->setText(tr("<h2>smolbote %1</h2>" - "<p><i>yet another no-frills browser</i></p>") + "<p><i>yet another no-frills browser</i></p>" + "<p>This program is free software, and is built upon other free software: Qt " QT_VERSION_STR " and Boost " BOOST_LIB_VERSION "</p>") .arg(qApp->applicationVersion())); ui->toolBox->addItem(aboutLabel, tr("About")); @@ -54,15 +71,14 @@ AboutDialog::AboutDialog(QWidget *parent) "<p>This program is distributed in the hope that it will be useful, but without any warranty.</p>")); ui->toolBox->addItem(licenseLabel, tr("License")); + + + auto *detailsLabel = new QLabel(this); detailsLabel->setWordWrap(true); detailsLabel->setText(tr("<p>Build " SMOLBOTE_BRANCH ":" SMOLBOTE_COMMIT "</p>" "<p>Compiled with " compiler "</p>" - "<p>Libraries: <ul>" - "<li>Qt " QT_VERSION_STR "</li>" - "<li>QtWebEngine " QTWEBENGINE_VERSION_STR "</li>" - "<li>Boost " BOOST_LIB_VERSION " </li>" - "</ul></p>")); + "<p>%1</p>").arg(getPluginList())); ui->toolBox->addItem(detailsLabel, tr("Details")); } diff --git a/plugins/ProfileEditor/ProfileEditor.json b/plugins/ProfileEditor/ProfileEditor.json index 8b2677b..ffb1c32 100644 --- a/plugins/ProfileEditor/ProfileEditor.json +++ b/plugins/ProfileEditor/ProfileEditor.json @@ -1,7 +1,5 @@ { "name": "Profile Editor", - "author": "Aqua-sama [aqua@iserlohn-fortress.net]", - "shortcut": "Ctrl+F2", - "addToMenu": false, - "addToToolbar": true + "author": "Aqua-sama", + "shortcut": "Ctrl+F2" } diff --git a/plugins/interfaces.h b/plugins/interfaces.h index 8b5b78c..1b653cd 100644 --- a/plugins/interfaces.h +++ b/plugins/interfaces.h @@ -10,6 +10,7 @@ #define SMOLBOTE_PLUGIN_INTERFACES_H #include <QtPlugin> +#include <QKeySequence> #include <memory> #include <functional> @@ -20,6 +21,9 @@ class WebProfile; struct Plugin { + QString name; + QString author; + QKeySequence shortcut; std::shared_ptr<QObject> instance; }; diff --git a/src/browser.cpp b/src/browser.cpp index 8abe10a..7c7dca3 100644 --- a/src/browser.cpp +++ b/src/browser.cpp @@ -21,6 +21,7 @@ #include <QFileInfo> #include <QFileInfoList> #include <QPluginLoader> +#include <QJsonArray> inline Plugin loadPluginFromPath(const QString &path) { @@ -32,6 +33,11 @@ inline Plugin loadPluginFromPath(const QString &path) qDebug("Loading plugin: %s [ok]", qUtf8Printable(path)); #endif + auto meta = loader.metaData().value("MetaData").toObject(); + p.name = meta.value("name").toString(); + p.author = meta.value("author").toString(); + p.shortcut = QKeySequence::fromString(meta.value("shortcut").toString()); + p.instance = std::shared_ptr<QObject>(loader.instance()); #ifdef QT_DEBUG diff --git a/src/browser.h b/src/browser.h index a06993d..e6b94e4 100644 --- a/src/browser.h +++ b/src/browser.h @@ -48,6 +48,11 @@ public: return m_commands.keys(); } + const QVector<Plugin> plugins() const + { + return m_plugins; + } + public slots: void createSession(const QString &profileName, bool newWindow, const QStringList &urls); MainWindow *createWindow(); |