aboutsummaryrefslogtreecommitdiff
path: root/src/about/aboutplugin.cpp
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/aboutplugin.cpp
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/aboutplugin.cpp')
-rw-r--r--src/about/aboutplugin.cpp77
1 files changed, 35 insertions, 42 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);
+ }
+ }
+}