aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2018-11-22 10:23:47 +0100
committerAqua-sama <aqua@iserlohn-fortress.net>2018-11-22 10:23:47 +0100
commit240fb8427a89d0aa78da07c8d147a0d57df5bb67 (patch)
treeaa4d46020f89e3d5dfc0b5fb24bc7190acbfe60c
parentAdd link to GPL to About dialog (diff)
downloadsmolbote-240fb8427a89d0aa78da07c8d147a0d57df5bb67.tar.xz
Add AboutPlugin dialog
-rw-r--r--cmake/VendorConfig.cmake53
-rw-r--r--lib/about/aboutplugin.cpp87
-rw-r--r--lib/about/aboutplugin.h31
-rw-r--r--lib/about/aboutplugin.ui179
-rw-r--r--lib/about/meson.build6
-rw-r--r--src/browser.cpp39
-rw-r--r--src/mainwindow/mainwindow.ui8
7 files changed, 333 insertions, 70 deletions
diff --git a/cmake/VendorConfig.cmake b/cmake/VendorConfig.cmake
deleted file mode 100644
index bb88eec..0000000
--- a/cmake/VendorConfig.cmake
+++ /dev/null
@@ -1,53 +0,0 @@
-find_package(PythonInterp 3.2 REQUIRED)
-
-string(TOLOWER ${CMAKE_SYSTEM_NAME} SYSTEM_NAME)
-
-if (NOT EXISTS "${PROJECT_SOURCE_DIR}/${SYSTEM_NAME}/.config")
- message(FATAL_ERROR "No vendor config for ${SYSTEM_NAME}: ${PROJECT_SOURCE_DIR}/${SYSTEM_NAME}/.config is missing")
-endif()
-# there is a .config in ${PROJECT_SOURCE_DIR}/${SYSTEM_NAME}/.config
-
-function(config KEY KCONFIG)
-execute_process(
- COMMAND ${PYTHON_EXECUTABLE} "${PROJECT_SOURCE_DIR}/tools/config.py" "--kconfig=${PROJECT_SOURCE_DIR}/${KCONFIG}" "--dotconfig=${PROJECT_SOURCE_DIR}/${SYSTEM_NAME}/.config" ${KEY}
- WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE output OUTPUT_STRIP_TRAILING_WHITESPACE)
- set("CONFIG_${KEY}" ${output} PARENT_SCOPE)
-endfunction()
-
-config("POI_NAME" "src/Kconfig")
-config("POI_EXE" "src/Kconfig")
-
-config("INSTALL_BINDIR" "Kconfig")
-config("INSTALL_LIBDIR" "Kconfig")
-config("INSTALL_PLUGINDIR" "Kconfig")
-config("INSTALL_APPDIR" "Kconfig")
-config("INSTALL_ICONDIR" "Kconfig")
-
-add_custom_command(OUTPUT "${PROJECT_BINARY_DIR}/include/config.h"
- COMMAND ${CMAKE_COMMAND} -E make_directory "${PROJECT_BINARY_DIR}/include"
- COMMAND ${CMAKE_COMMAND} -E env "srctree=${PROJECT_SOURCE_DIR}"
- ${PYTHON_EXECUTABLE} "${PROJECT_SOURCE_DIR}/tools/Kconfiglib/genconfig.py" "--header-path=${PROJECT_BINARY_DIR}/include/config.h" "${PROJECT_SOURCE_DIR}/src/Kconfig"
- WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/${SYSTEM_NAME}")
-
-add_custom_target(config_header DEPENDS "${PROJECT_BINARY_DIR}/include/config.h")
-
-# QTBUG defines
-execute_process(
- COMMAND ${PYTHON_EXECUTABLE} "${PROJECT_SOURCE_DIR}/tools/config.py" "--kconfig=${PROJECT_SOURCE_DIR}/src/Kconfig" "--dotconfig=${PROJECT_SOURCE_DIR}/${SYSTEM_NAME}/.config" "QTBUG"
- WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE QTBUGS OUTPUT_STRIP_TRAILING_WHITESPACE)
-foreach(bug IN LISTS QTBUGS)
- set(${bug} CACHE STRING "${bug} workaround")
-endforeach()
-
-
-## Version information, used in src/version.h.in
-if (EXISTS "${PROJECT_SOURCE_DIR}/.git")
- execute_process(COMMAND git rev-list --count HEAD WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE VerRevision OUTPUT_STRIP_TRAILING_WHITESPACE)
- execute_process(COMMAND git rev-parse --short HEAD WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE VerShortId OUTPUT_STRIP_TRAILING_WHITESPACE)
- execute_process(COMMAND git rev-parse HEAD WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE VerCommit OUTPUT_STRIP_TRAILING_WHITESPACE)
- execute_process(COMMAND git rev-parse --abbrev-ref HEAD WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE VerBranch OUTPUT_STRIP_TRAILING_WHITESPACE)
-endif()
-
-set(poi_Version "r${VerRevision}" CACHE STRING "Short version string")
-set(poi_Describe "r${VerRevision}-${VerShortId}" CACHE STRING "Long version string")
-set(poi_Build "${VerBranch}-${VerCommit}" CACHE STRING "Build string")
diff --git a/lib/about/aboutplugin.cpp b/lib/about/aboutplugin.cpp
new file mode 100644
index 0000000..7df75fa
--- /dev/null
+++ b/lib/about/aboutplugin.cpp
@@ -0,0 +1,87 @@
+/*
+ * 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 "aboutplugin.h"
+#include "ui_aboutplugin.h"
+#include <QJsonArray>
+#include <QPluginLoader>
+
+QTreeWidgetItem *createItem(const QString &key, const QJsonValue &json, QTreeWidgetItem *parent)
+{
+ auto *item = new QTreeWidgetItem(parent, { key, QLatin1Literal("---") });
+
+ switch(json.type()) {
+ case QJsonValue::Bool:
+ item->setText(1, json.toBool() ? QLatin1Literal("true") : QLatin1Literal("false"));
+ break;
+
+ case QJsonValue::Double:
+ item->setText(1, QString::number(json.toDouble()));
+ break;
+
+ case QJsonValue::String:
+ item->setText(1, json.toString());
+ break;
+
+ case QJsonValue::Array:
+ item->setText(1, QString());
+ for(const QJsonValue &v : json.toArray()) {
+ createItem(QString(), v, item);
+ }
+ break;
+
+ case QJsonValue::Object:
+ item->setText(1, QString());
+ for(const QString &k : json.toObject().keys()) {
+ createItem(k, json.toObject()[k], item);
+ }
+ break;
+
+ case QJsonValue::Null:
+ item->setText(1, QLatin1Literal("null"));
+ break;
+
+ case QJsonValue::Undefined:
+ item->setText(1, QLatin1Literal("undefined"));
+ break;
+ }
+
+ return item;
+}
+
+AboutPluginDialog::AboutPluginDialog(const QPluginLoader *loader, QWidget *parent)
+ : QDialog(parent)
+ , ui(new Ui::AboutPluginDialog)
+{
+ setAttribute(Qt::WA_DeleteOnClose, true);
+ ui->setupUi(this);
+
+ auto metaData = loader->metaData()["MetaData"].toObject();
+
+ this->setWindowTitle(metaData["name"].toString());
+
+ ui->path->setText(loader->fileName());
+ ui->loaded->setChecked(loader->isLoaded());
+
+ ui->name->setText(metaData[QLatin1Literal("name")].toString());
+ ui->author->setText(metaData[QLatin1Literal("author")].toString());
+ ui->license->setText(metaData[QLatin1Literal("license")].toString());
+ ui->shortcut->setText(metaData[QLatin1Literal("shortcut")].toString());
+
+ for(const QString &key : loader->metaData().keys()) {
+ auto *i = createItem(key, loader->metaData()[key], nullptr);
+
+ if(i != nullptr)
+ ui->details_treeWidget->insertTopLevelItem(0, i);
+ }
+}
+
+AboutPluginDialog::~AboutPluginDialog()
+{
+ delete ui;
+}
diff --git a/lib/about/aboutplugin.h b/lib/about/aboutplugin.h
new file mode 100644
index 0000000..adab215
--- /dev/null
+++ b/lib/about/aboutplugin.h
@@ -0,0 +1,31 @@
+/*
+ * 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
+ */
+
+#ifndef SMOLBOTE_ABOUTPLUGIN_H
+#define SMOLBOTE_ABOUTPLUGIN_H
+
+#include <QDialog>
+
+namespace Ui
+{
+class AboutPluginDialog;
+}
+class QPluginLoader;
+class AboutPluginDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit AboutPluginDialog(const QPluginLoader *loader, QWidget *parent = nullptr);
+ ~AboutPluginDialog() override;
+
+private:
+ Ui::AboutPluginDialog *ui;
+};
+
+#endif // SMOLBOTE_ABOUTPLUGIN_H
diff --git a/lib/about/aboutplugin.ui b/lib/about/aboutplugin.ui
new file mode 100644
index 0000000..f2d4848
--- /dev/null
+++ b/lib/about/aboutplugin.ui
@@ -0,0 +1,179 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>AboutPluginDialog</class>
+ <widget class="QDialog" name="AboutPluginDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>474</width>
+ <height>329</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Dialog</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QTabWidget" name="tabWidget">
+ <property name="currentIndex">
+ <number>0</number>
+ </property>
+ <widget class="QWidget" name="general_tab">
+ <attribute name="title">
+ <string>General</string>
+ </attribute>
+ <layout class="QFormLayout" name="formLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="name_label">
+ <property name="text">
+ <string>Name</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLabel" name="name">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="author_label">
+ <property name="text">
+ <string>Author</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLabel" name="author">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="shortcut_label">
+ <property name="text">
+ <string>Shortcut</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QLabel" name="shortcut">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1">
+ <layout class="QHBoxLayout" name="controls_layout">
+ <item>
+ <widget class="QPushButton" name="loaded">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Load</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="2" column="1">
+ <widget class="QLabel" name="license">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="license_label">
+ <property name="text">
+ <string>License</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="details_tab">
+ <attribute name="title">
+ <string>Details</string>
+ </attribute>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="QLabel" name="path">
+ <property name="text">
+ <string>TextLabel</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QTreeWidget" name="details_treeWidget">
+ <column>
+ <property name="text">
+ <string>Key</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Value</string>
+ </property>
+ </column>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Close</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>AboutPluginDialog</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>248</x>
+ <y>254</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>AboutPluginDialog</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/lib/about/meson.build b/lib/about/meson.build
index 35598b3..961c7ef 100644
--- a/lib/about/meson.build
+++ b/lib/about/meson.build
@@ -1,11 +1,11 @@
about_moc = qt5.preprocess(
- moc_headers: ['aboutdialog.h'],
- ui_files: ['aboutdialog.ui'],
+ moc_headers: ['aboutdialog.h', 'aboutplugin.h'],
+ ui_files: ['aboutdialog.ui', 'aboutplugin.ui'],
dependencies: dep_qt5
)
about_inc = include_directories('.')
-about_lib = static_library('about', ['aboutdialog.cpp', about_moc],
+about_lib = static_library('about', ['aboutdialog.cpp', 'aboutplugin.cpp', about_moc],
dependencies: [dep_qt5, dep_genheaders]
)
diff --git a/src/browser.cpp b/src/browser.cpp
index 8ff8616..0bd3d06 100644
--- a/src/browser.cpp
+++ b/src/browser.cpp
@@ -7,11 +7,21 @@
*/
#include "browser.h"
+#include "aboutdialog.h"
+#include "aboutplugin.h"
#include "addressbar.h"
+#include "bookmarkswidget.h"
+#include "config.h"
+#include "configuration.h"
+#include "downloadswidget.h"
#include "mainwindow/mainwindow.h"
+#include "profilemanager.h"
#include "subwindow/subwindow.h"
+#include "ui_mainwindow.h"
#include "util.h"
+#include "webengine/filter.h"
#include "webengine/urlinterceptor.h"
+#include "webprofile.h"
#include <QAction>
#include <QDir>
#include <QFileInfo>
@@ -20,18 +30,9 @@
#include <QJsonDocument>
#include <QPluginLoader>
#include <QTimer>
-#include "aboutdialog.h"
-#include "bookmarkswidget.h"
-#include "configuration.h"
-#include "downloadswidget.h"
-#include <version.h>
-#include "profilemanager.h"
-#include "webprofile.h"
-#include "webengine/filter.h"
-#include <QPluginLoader>
-#include <plugininterface.h>
-#include "config.h"
#include <QVersionNumber>
+#include <plugininterface.h>
+#include <version.h>
Browser::Browser(int &argc, char *argv[], bool allowSecondary)
: SingleApplication(argc, argv, allowSecondary, SingleApplication::User | SingleApplication::SecondaryNotification | SingleApplication::ExcludeAppVersion)
@@ -69,12 +70,12 @@ const QStringList Browser::configurationOptions() const
return options;
}
-const QString Browser::configuration(const QString& key) const
+const QString Browser::configuration(const QString &key) const
{
return m_config->value<QString>(qUtf8Printable(key)).value_or(QString());
}
-void Browser::setConfiguration(const QString& key, const QString& value)
+void Browser::setConfiguration(const QString &key, const QString &value)
{
m_config->setValue(qUtf8Printable(key), value);
}
@@ -223,6 +224,18 @@ MainWindow *Browser::createWindow()
connect(window->addressBar, &AddressBar::complete, m_bookmarks.get(), &BookmarksWidget::search);
connect(window, &MainWindow::createBookmark, m_bookmarks.get(), &BookmarksWidget::addBookmark);
+ connect(window->ui->menuTools, &QMenu::aboutToShow, this, [this, window]() {
+ window->ui->menuPlugins->clear();
+
+ for(const QPluginLoader *l : m_plugins) {
+ auto *action = window->ui->menuPlugins->addAction(l->metaData()[QLatin1String("MetaData")].toObject()[QLatin1String("name")].toString());
+ connect(action, &QAction::triggered, this, [l, window]() {
+ auto *dlg = new AboutPluginDialog(l, window);
+ dlg->exec();
+ });
+ }
+ });
+
auto *bookmarksAction = new QAction(tr("Bookmarks"), window);
m_config->setShortcut(bookmarksAction, "bookmarks.shortcut");
connect(bookmarksAction, &QAction::triggered, window, [this, window]() {
diff --git a/src/mainwindow/mainwindow.ui b/src/mainwindow/mainwindow.ui
index cb6d39e..ad213c6 100644
--- a/src/mainwindow/mainwindow.ui
+++ b/src/mainwindow/mainwindow.ui
@@ -20,7 +20,7 @@
<x>0</x>
<y>0</y>
<width>800</width>
- <height>23</height>
+ <height>30</height>
</rect>
</property>
<widget class="QMenu" name="menusmolbote">
@@ -55,6 +55,12 @@
<property name="title">
<string>Too&amp;ls</string>
</property>
+ <widget class="QMenu" name="menuPlugins">
+ <property name="title">
+ <string>&amp;Plugins</string>
+ </property>
+ </widget>
+ <addaction name="menuPlugins"/>
</widget>
<widget class="QMenu" name="menuPage">
<property name="title">