From feaec1906ea336b77022809aacc2ec4115b329c2 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Fri, 15 Jun 2018 09:59:57 +0200 Subject: AboutDialog: add profile list to details tab --- lib/about/CMakeLists.txt | 2 ++ lib/about/aboutdialog.cpp | 28 ++++++++++++++++++++++------ plugins/ProfileEditor/ProfileEditor.json | 6 ++---- plugins/interfaces.h | 4 ++++ src/browser.cpp | 6 ++++++ 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 #include #include "version.h" +#include // 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(qApp); + Q_CHECK_PTR(browser); + + QString plugins; + for(const Plugin &p : browser->plugins()) { + plugins.append(QString("
  • %1 (%2)
  • ").arg(p.name, p.author)); + } + if(!plugins.isEmpty()) + plugins = "Loaded plugins:
      " + plugins + "setWordWrap(true); aboutLabel->setText(tr("

      smolbote %1

      " - "

      yet another no-frills browser

      ") + "

      yet another no-frills browser

      " + "

      This program is free software, and is built upon other free software: Qt " QT_VERSION_STR " and Boost " BOOST_LIB_VERSION "

      ") .arg(qApp->applicationVersion())); ui->toolBox->addItem(aboutLabel, tr("About")); @@ -54,15 +71,14 @@ AboutDialog::AboutDialog(QWidget *parent) "

      This program is distributed in the hope that it will be useful, but without any warranty.

      ")); ui->toolBox->addItem(licenseLabel, tr("License")); + + + auto *detailsLabel = new QLabel(this); detailsLabel->setWordWrap(true); detailsLabel->setText(tr("

      Build " SMOLBOTE_BRANCH ":" SMOLBOTE_COMMIT "

      " "

      Compiled with " compiler "

      " - "

      Libraries:

        " - "
      • Qt " QT_VERSION_STR "
      • " - "
      • QtWebEngine " QTWEBENGINE_VERSION_STR "
      • " - "
      • Boost " BOOST_LIB_VERSION "
      • " - "

      ")); + "

      %1

      ").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 +#include #include #include @@ -20,6 +21,9 @@ class WebProfile; struct Plugin { + QString name; + QString author; + QKeySequence shortcut; std::shared_ptr 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 #include #include +#include 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(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 plugins() const + { + return m_plugins; + } + public slots: void createSession(const QString &profileName, bool newWindow, const QStringList &urls); MainWindow *createWindow(); -- cgit v1.2.1