aboutsummaryrefslogtreecommitdiff
path: root/src/about
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2020-04-29 18:49:07 +0300
committerAqua-sama <aqua@iserlohn-fortress.net>2020-05-08 13:40:29 +0300
commite87693c54ca97ed3a6ed25f9eaae8ab223fc18b1 (patch)
tree54194ca979ac7e646ff3f10ed6d7f7753273f0be /src/about
parentExpand pluginloader test coverage (diff)
downloadsmolbote-e87693c54ca97ed3a6ed25f9eaae8ab223fc18b1.tar.xz
libwebengine
Make src/webengine into a static library - Add some tests - Updated manpage - Remove WebProfileManager::id and WebProfileManager::instance - Add consumable semantics checks to WebProfileManager - Add WebProfileManager::walk Add ApplicationMenu class
Diffstat (limited to 'src/about')
-rw-r--r--src/about/aboutplugin.cpp77
-rw-r--r--src/about/aboutplugin.h5
-rw-r--r--src/about/aboutplugin.ui181
3 files changed, 89 insertions, 174 deletions
diff --git a/src/about/aboutplugin.cpp b/src/about/aboutplugin.cpp
index 99c04ec..92e55bb 100644
--- a/src/about/aboutplugin.cpp
+++ b/src/about/aboutplugin.cpp
@@ -10,6 +10,7 @@
#include "ui_aboutplugin.h"
#include <QJsonArray>
#include <QPluginLoader>
+#include <QToolButton>
QTreeWidgetItem *createItem(const QString &key, const QJsonValue &json, QTreeWidgetItem *parent)
{
@@ -54,58 +55,50 @@ QTreeWidgetItem *createItem(const QString &key, const QJsonValue &json, QTreeWid
return item;
}
-AboutPluginDialog::AboutPluginDialog(QPluginLoader *loader, QWidget *parent)
+AboutPluginDialog::AboutPluginDialog(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;
}
+
+void AboutPluginDialog::add(QPluginLoader *loader)
+{
+ const auto index = ui->tableWidget->rowCount();
+ ui->tableWidget->setRowCount(index + 1);
+
+ const auto metadata = loader->metaData()["MetaData"].toObject();
+ ui->tableWidget->setItem(index, 0, new QTableWidgetItem(metadata.value("name").toString()));
+ ui->tableWidget->setItem(index, 1, new QTableWidgetItem(metadata.value("author").toString()));
+ ui->tableWidget->setItem(index, 2, new QTableWidgetItem(metadata.value("license").toString()));
+ ui->tableWidget->setItem(index, 3, new QTableWidgetItem(metadata.value("shortcut").toString()));
+ ui->tableWidget->setItem(index, 5, new QTableWidgetItem(loader->fileName()));
+
+ auto *enable_btn = new QToolButton(this);
+ enable_btn->setCheckable(true);
+ enable_btn->setChecked(loader->isLoaded());
+ ui->tableWidget->setCellWidget(index, 4, enable_btn);
+
+ connect(enable_btn, &QToolButton::clicked, this, [ loader, enable_btn ](bool checked) {
+ const bool success = checked ? loader->load() : loader->unload();
+ if(!success) {
+ enable_btn->setChecked(!checked);
+ //ui->error->setText(loader->errorString());
+ }
+ });
+
+ for(const QString &key : metadata.keys()) {
+ auto *i = createItem(key, metadata.value(key), nullptr);
+ if(i != nullptr) {
+ ui->details_treeWidget->insertTopLevelItem(0, i);
+ }
+ }
+}
diff --git a/src/about/aboutplugin.h b/src/about/aboutplugin.h
index 9651060..b01cc78 100644
--- a/src/about/aboutplugin.h
+++ b/src/about/aboutplugin.h
@@ -21,9 +21,12 @@ class AboutPluginDialog : public QDialog
Q_OBJECT
public:
- explicit AboutPluginDialog(QPluginLoader *loader, QWidget *parent = nullptr);
+ explicit AboutPluginDialog(QWidget *parent = nullptr);
~AboutPluginDialog() override;
+public slots:
+ void add(QPluginLoader *loader);
+
private:
Ui::AboutPluginDialog *ui;
};
diff --git a/src/about/aboutplugin.ui b/src/about/aboutplugin.ui
index 5df1c0d..d4291e5 100644
--- a/src/about/aboutplugin.ui
+++ b/src/about/aboutplugin.ui
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>500</width>
- <height>400</height>
+ <width>600</width>
+ <height>420</height>
</rect>
</property>
<property name="windowTitle">
@@ -15,135 +15,54 @@
</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 class="QTableWidget" name="tableWidget">
+ <attribute name="horizontalHeaderStretchLastSection">
+ <bool>true</bool>
+ </attribute>
+ <column>
+ <property name="text">
+ <string>Name</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Author</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>License</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Shortcut</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Enable</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Path</string>
+ </property>
+ </column>
+ </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>
<item>