From 0492a063806b6d63e4f378908b809de104a24820 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Sat, 25 Apr 2020 22:09:13 +0300 Subject: Update ProfileEditor plugin ProfileEditor: - add tests - disable read-only settings on otr profiles Add WebProfile::setHeaders and WebProfile::setCookies --- src/about/aboutplugin.cpp | 60 +++++------------------------------------------ 1 file changed, 6 insertions(+), 54 deletions(-) (limited to 'src/about/aboutplugin.cpp') diff --git a/src/about/aboutplugin.cpp b/src/about/aboutplugin.cpp index 92e55bb..a011b47 100644 --- a/src/about/aboutplugin.cpp +++ b/src/about/aboutplugin.cpp @@ -12,57 +12,12 @@ #include #include -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(QWidget *parent) : QDialog(parent) , ui(new Ui::AboutPluginDialog) { setAttribute(Qt::WA_DeleteOnClose, true); ui->setupUi(this); - - } AboutPluginDialog::~AboutPluginDialog() @@ -85,20 +40,17 @@ void AboutPluginDialog::add(QPluginLoader *loader) auto *enable_btn = new QToolButton(this); enable_btn->setCheckable(true); enable_btn->setChecked(loader->isLoaded()); + enable_btn->setText(loader->isLoaded() ? "loaded" : "unloaded"); ui->tableWidget->setCellWidget(index, 4, enable_btn); - connect(enable_btn, &QToolButton::clicked, this, [ loader, enable_btn ](bool checked) { + connect(enable_btn, &QToolButton::clicked, this, [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()); + ui->msg->setText(loader->errorString()); + } else { + ui->msg->setText(checked ? "Plugin successfully loaded" : "Plugin successfully unloaded"); + enable_btn->setText(checked ? "loaded" : "unloaded"); } }); - - for(const QString &key : metadata.keys()) { - auto *i = createItem(key, metadata.value(key), nullptr); - if(i != nullptr) { - ui->details_treeWidget->insertTopLevelItem(0, i); - } - } } -- cgit v1.2.1