aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/about/aboutdialog.cpp78
-rw-r--r--src/about/aboutdialog.h31
-rw-r--r--src/about/aboutdialog.ui201
-rw-r--r--src/about/aboutplugin.cpp111
-rw-r--r--src/about/aboutplugin.h31
-rw-r--r--src/about/aboutplugin.ui196
-rw-r--r--src/about/meson.build21
-rw-r--r--src/about/test/main.cpp21
-rw-r--r--src/meson.build2
9 files changed, 692 insertions, 0 deletions
diff --git a/src/about/aboutdialog.cpp b/src/about/aboutdialog.cpp
new file mode 100644
index 0000000..894b1ec
--- /dev/null
+++ b/src/about/aboutdialog.cpp
@@ -0,0 +1,78 @@
+/*
+ * 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://library.iserlohn-fortress.net/aqua/smolbote.git
+ *
+ * SPDX-License-Identifier: GPL-3.0
+ */
+
+#include "aboutdialog.h"
+#include "ui_aboutdialog.h"
+#include <version.h>
+
+// compiler
+// clang also defines __GNUC__, so we need to check for clang first
+#if defined(__clang__)
+#define compiler "Clang " __clang_version__
+#elif defined(__GNUC__)
+#define compiler "GCC " __VERSION__
+#elif defined(_MSC_VER)
+#define compiler "MSVC"
+#else
+#define compiler "unknown compiler"
+#endif
+
+AboutDialog::AboutDialog(QWidget *parent)
+ : QDialog(parent)
+ , ui(new Ui::AboutDialog)
+{
+ //setAttribute(Qt::WA_DeleteOnClose, true);
+ ui->setupUi(this);
+
+ const QByteArray icon_svg = R"SVG(
+<svg xmlns="http://www.w3.org/2000/svg" width="300" height="300" version="1.1">
+ <circle cx="150" cy="150" r="100" stroke="#000000" stroke-width="6" fill="#e60026"></circle>
+ <circle cx="150" cy="150" r="87" stroke="#000000" stroke-width="4" fill="#e5e4e2"></circle>
+ <path d="M230,150 A80,80 0 0 0 150,70 L150,150 Z" />
+ <path d="M70,150 A80,80 0 0 0 150,230 L150,150 Z" />
+</svg>
+)SVG";
+ ui->appIcon_svg->load(icon_svg);
+
+ ui->appName_label->setText(qApp->applicationName());
+ ui->appVersion_label->setText(qApp->applicationVersion());
+
+ ui->aboutLabel->setText(tr("<h2>%1 %2</h2>"
+ "<p><i>yet another no-frills browser</i></p>"
+ "<p>This program is free software, see <i>License</i> for more information.</p>")
+ .arg(qApp->applicationName(), qApp->applicationVersion()));
+
+ ui->licenseLabel->setText(tr("<p>Copyright 2017 - 2020 aqua@</p>"
+ "<p>This program is free software, and you are welcome to use it under the conditions set by the GNU GPLv3.<br>"
+ "This is a short summary: <ul>"
+ "<li> the freedom to use the software for any purpose,</li>"
+ "<li> the freedom to change the software to suit your needs,</li>"
+ "<li> the freedom to share the software with anyone,</li>"
+ "<li> the freedom to share the changes you make, and</li>"
+ "<li> the responsibility to grant the same freedoms when sharing the software.</li>"
+ "</ul>"
+ "<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>"
+ "<p>Compiled with " compiler "</p>"
+ "<p>Libraries: <ul>"
+ "<li><a href='https://www.qt.io/'>Qt5</a> " QT_VERSION_STR "</li>"
+ "<li>spdlog</li>"
+ "<li><a href='https://github.com/Taywee/args'>args.hxx</a></li>"
+ "<li><a href='https://github.com/itay-grudev/SingleApplication'>SingleApplication</a></li>"
+#ifdef CONFIG_USEBREAKPAD
+ "<li><a href='https://chromium.googlesource.com/breakpad/breakpad'>Breakpad</a></li>"
+#endif
+ "</ul></p>"));
+}
+
+AboutDialog::~AboutDialog()
+{
+ delete ui;
+}
diff --git a/src/about/aboutdialog.h b/src/about/aboutdialog.h
new file mode 100644
index 0000000..e114e7c
--- /dev/null
+++ b/src/about/aboutdialog.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://library.iserlohn-fortress.net/aqua/smolbote.git
+ *
+ * SPDX-License-Identifier: GPL-3.0
+ */
+
+#ifndef SMOLBOTE_ABOUTDIALOG_H
+#define SMOLBOTE_ABOUTDIALOG_H
+
+#include <QDialog>
+
+namespace Ui
+{
+class AboutDialog;
+}
+
+class AboutDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit AboutDialog(QWidget *parent = nullptr);
+ ~AboutDialog() override;
+
+private:
+ Ui::AboutDialog *ui;
+};
+
+#endif // SMOLBOTE_ABOUTDIALOG_H
diff --git a/src/about/aboutdialog.ui b/src/about/aboutdialog.ui
new file mode 100644
index 0000000..5b1c12a
--- /dev/null
+++ b/src/about/aboutdialog.ui
@@ -0,0 +1,201 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>AboutDialog</class>
+ <widget class="QDialog" name="AboutDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>600</width>
+ <height>420</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>About</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="QSvgWidget" name="appIcon_svg" native="true">
+ <property name="minimumSize">
+ <size>
+ <width>120</width>
+ <height>120</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>120</width>
+ <height>120</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="appName_label">
+ <property name="text">
+ <string>smolbote</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="appVersion_label">
+ <property name="text">
+ <string>0.1.0</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QTabWidget" name="tabWidget">
+ <property name="tabPosition">
+ <enum>QTabWidget::West</enum>
+ </property>
+ <property name="currentIndex">
+ <number>0</number>
+ </property>
+ <widget class="QWidget" name="tabWidgetPage1">
+ <attribute name="title">
+ <string>About</string>
+ </attribute>
+ <layout class="QVBoxLayout" name="verticalLayout_4">
+ <item>
+ <widget class="QLabel" name="aboutLabel">
+ <property name="text">
+ <string>TextLabel</string>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="tabWidgetPage2">
+ <attribute name="title">
+ <string>License</string>
+ </attribute>
+ <layout class="QVBoxLayout" name="verticalLayout_5">
+ <item>
+ <widget class="QLabel" name="licenseLabel">
+ <property name="text">
+ <string>TextLabel</string>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ <property name="openExternalLinks">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="tabWidgetPage3">
+ <attribute name="title">
+ <string>Details</string>
+ </attribute>
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <item>
+ <widget class="QLabel" name="detailsLabel">
+ <property name="text">
+ <string>TextLabel</string>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ <property name="openExternalLinks">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="tab">
+ <attribute name="title">
+ <string>Plugins</string>
+ </attribute>
+ </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>
+ </item>
+ </layout>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>QSvgWidget</class>
+ <extends>QWidget</extends>
+ <header location="global">QSvgWidget</header>
+ <container>1</container>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>AboutDialog</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>AboutDialog</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/src/about/aboutplugin.cpp b/src/about/aboutplugin.cpp
new file mode 100644
index 0000000..99c04ec
--- /dev/null
+++ b/src/about/aboutplugin.cpp
@@ -0,0 +1,111 @@
+/*
+ * 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, QLatin1String("---") });
+
+ switch(json.type()) {
+ case QJsonValue::Bool:
+ item->setText(1, json.toBool() ? QLatin1String("true") : QLatin1String("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 auto &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, QLatin1String("null"));
+ break;
+
+ case QJsonValue::Undefined:
+ item->setText(1, QLatin1String("undefined"));
+ break;
+ }
+
+ return item;
+}
+
+AboutPluginDialog::AboutPluginDialog(QPluginLoader *loader, QWidget *parent)
+ : QDialog(parent)
+ , ui(new Ui::AboutPluginDialog)
+{
+ setAttribute(Qt::WA_DeleteOnClose, true);
+ ui->setupUi(this);
+
+ // load button icon
+ {
+ QIcon load_icon;
+ load_icon.addPixmap(style()->standardPixmap(QStyle::SP_MediaPlay), QIcon::Normal, QIcon::On);
+ load_icon.addPixmap(style()->standardPixmap(QStyle::SP_MediaStop), QIcon::Normal, QIcon::Off);
+ ui->load->setIcon(load_icon);
+ }
+
+ auto metaData = loader->metaData()["MetaData"].toObject();
+
+ this->setWindowTitle(metaData["name"].toString());
+
+ ui->path->setText(loader->fileName());
+ ui->load->setChecked(loader->isLoaded());
+
+ connect(ui->load, &QToolButton::clicked, this, [this, loader](bool checked) {
+ if(checked) {
+ // load plugin
+ if(!loader->load()) {
+ ui->load->setChecked(false);
+ ui->error->setText(loader->errorString());
+ }
+ } else {
+ // unload plugin
+ if(!loader->unload()) {
+ ui->load->setChecked(true);
+ ui->error->setText(loader->errorString());
+ }
+ }
+ });
+
+ ui->name->setText(metaData[QLatin1String("name")].toString());
+ ui->author->setText(metaData[QLatin1String("author")].toString());
+ ui->license->setText(metaData[QLatin1String("license")].toString());
+ ui->shortcut->setText(metaData[QLatin1String("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/src/about/aboutplugin.h b/src/about/aboutplugin.h
new file mode 100644
index 0000000..9651060
--- /dev/null
+++ b/src/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(QPluginLoader *loader, QWidget *parent = nullptr);
+ ~AboutPluginDialog() override;
+
+private:
+ Ui::AboutPluginDialog *ui;
+};
+
+#endif // SMOLBOTE_ABOUTPLUGIN_H
diff --git a/src/about/aboutplugin.ui b/src/about/aboutplugin.ui
new file mode 100644
index 0000000..5df1c0d
--- /dev/null
+++ b/src/about/aboutplugin.ui
@@ -0,0 +1,196 @@
+<?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>500</width>
+ <height>400</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>
+ <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 class="QWidget" name="controls_tab">
+ <attribute name="title">
+ <string>Controls</string>
+ </attribute>
+ <layout class="QFormLayout" name="formLayout_2">
+ <item row="0" column="1">
+ <widget class="QToolButton" name="load">
+ <property name="text">
+ <string>Load</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLabel" name="error">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0">
+ <widget class="QLabel" name="error_label">
+ <property name="text">
+ <string>Status</string>
+ </property>
+ </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/src/about/meson.build b/src/about/meson.build
new file mode 100644
index 0000000..49274a8
--- /dev/null
+++ b/src/about/meson.build
@@ -0,0 +1,21 @@
+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/about/test/main.cpp b/src/about/test/main.cpp
new file mode 100644
index 0000000..18037e1
--- /dev/null
+++ b/src/about/test/main.cpp
@@ -0,0 +1,21 @@
+#include <QApplication>
+#include <QTimer>
+#include "aboutdialog.h"
+
+int main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+ app.setApplicationName("about");
+ app.setApplicationVersion("1.2.3");
+
+ AboutDialog dlg;
+ QObject::connect(&dlg, &AboutDialog::finished, &app, &QApplication::quit);
+ dlg.show();
+
+ if(qEnvironmentVariableIsSet("autoclose")) {
+ QTimer::singleShot(200, &dlg, &AboutDialog::accept);
+ }
+
+ return app.exec();
+}
+
diff --git a/src/meson.build b/src/meson.build
index 31f4ffc..1101b7a 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -7,6 +7,8 @@ poi_settings_h = custom_target('default_config_value',
command: [ python3, '@INPUT0@', '--kconfig=@INPUT1@', '--dotconfig=@INPUT2@', '--input=@INPUT3@', '--output=@OUTPUT@' ]
)
+subdir('about')
+
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/navigationbar.h', 'mainwindow/widgets/searchform.h',