From e87693c54ca97ed3a6ed25f9eaae8ab223fc18b1 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Wed, 29 Apr 2020 18:49:07 +0300 Subject: 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 --- src/about/aboutplugin.cpp | 77 +++++++++----------- src/about/aboutplugin.h | 5 +- src/about/aboutplugin.ui | 181 +++++++++++++--------------------------------- 3 files changed, 89 insertions(+), 174 deletions(-) (limited to 'src/about') 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 #include +#include 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 @@ 0 0 - 500 - 400 + 600 + 420 @@ -15,135 +15,54 @@ - - - 0 - - - - General - - - - - - Name - - - - - - - - - - - - - - Author - - - - - - - - - - - - - - Shortcut - - - - - - - - - - - - - - - - - - - - - - - - License - - - - - - - - Details - - - - - - TextLabel - - - - - - - - Key - - - - - Value - - - - - - - - - Controls - - - - - - Load - - - true - - - - - - - - - - - - - - Status - - - - - + + + true + + + + Name + + + + + Author + + + + + License + + + + + Shortcut + + + + + Enable + + + + + Path + + + + + + + + + Key + + + + + Value + + -- cgit v1.2.1