aboutsummaryrefslogtreecommitdiff
path: root/src/about/aboutplugin.cpp
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2020-04-25 22:09:13 +0300
committerAqua-sama <aqua@iserlohn-fortress.net>2020-05-26 12:50:15 +0300
commit0492a063806b6d63e4f378908b809de104a24820 (patch)
tree2e285d0c9b5067dc9395bfb751fe84bb8ac2a5f4 /src/about/aboutplugin.cpp
parentlibwebengine (diff)
downloadsmolbote-0492a063806b6d63e4f378908b809de104a24820.tar.xz
Update ProfileEditor plugin
ProfileEditor: - add tests - disable read-only settings on otr profiles Add WebProfile::setHeaders and WebProfile::setCookies
Diffstat (limited to 'src/about/aboutplugin.cpp')
-rw-r--r--src/about/aboutplugin.cpp60
1 files changed, 6 insertions, 54 deletions
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 <QPluginLoader>
#include <QToolButton>
-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);
- }
- }
}