aboutsummaryrefslogtreecommitdiff
path: root/src/about/aboutplugin.cpp
diff options
context:
space:
mode:
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);
- }
- }
}