aboutsummaryrefslogtreecommitdiff
path: root/plugins/ConfigurationEditor/forms
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2018-10-09 12:05:28 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2018-10-09 12:05:28 +0200
commit3639d5789259561c531a3481d7061a0cb492c644 (patch)
treec9c7ff04022b62cf5be4d4ea31bf28d966ccefda /plugins/ConfigurationEditor/forms
parentCreate .profile file when adding a new profile (diff)
downloadsmolbote-3639d5789259561c531a3481d7061a0cb492c644.tar.xz
Unlink plugins from lib/ libraries
Diffstat (limited to 'plugins/ConfigurationEditor/forms')
-rw-r--r--plugins/ConfigurationEditor/forms/configurationdialog.cpp65
-rw-r--r--plugins/ConfigurationEditor/forms/configurationdialog.h23
2 files changed, 54 insertions, 34 deletions
diff --git a/plugins/ConfigurationEditor/forms/configurationdialog.cpp b/plugins/ConfigurationEditor/forms/configurationdialog.cpp
index ffe7f9c..f433d70 100644
--- a/plugins/ConfigurationEditor/forms/configurationdialog.cpp
+++ b/plugins/ConfigurationEditor/forms/configurationdialog.cpp
@@ -1,41 +1,50 @@
+/*
+ * This file is part of smolbote. It's copyrighted by the contributors recorded
+ * in the version control history of the file, available from its original
+ * location: https://neueland.iserlohn-fortress.net/gitea/aqua/smolbote
+ *
+ * SPDX-License-Identifier: GPL-3.0
+ */
+
#include "configurationdialog.h"
-#include "ui_configurationdialog.h"
-#include <configuration.h>
#include <QKeySequenceEdit>
+#include <QLineEdit>
-ConfigurationDialog::ConfigurationDialog(Configuration *conf, QWidget *parent) :
+ConfigurationDialog::ConfigurationDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::ConfigurationDialog)
{
ui->setupUi(this);
- Q_CHECK_PTR(conf);
-
- for(const auto &option : conf->options()) {
- auto path = QString::fromStdString(option->long_name());
- auto value = QString::fromStdString(conf->value<std::string>(option->long_name().c_str()).value_or(""));
-
- QTreeWidgetItem *item = nullptr;
- if(path.contains("shortcut")) {
- item = new QTreeWidgetItem(ui->shortcuts_treeWidget);
- auto *edit = new QKeySequenceEdit(value);
- connect(edit, &QKeySequenceEdit::keySequenceChanged, this, [=](const QKeySequence &keySequqnce) {
- conf->setValue(qUtf8Printable(path), keySequqnce.toString());
- });
- ui->shortcuts_treeWidget->setItemWidget(item, 1, edit);
- } else {
- item = new QTreeWidgetItem(ui->settings_treeWidget);
- item->setText(1, value);
- }
-
- item->setText(0, path);
-
- }
-
- ui->settings_treeWidget->resizeColumnToContents(0);
- ui->shortcuts_treeWidget->resizeColumnToContents(0);
}
ConfigurationDialog::~ConfigurationDialog()
{
delete ui;
}
+
+void ConfigurationDialog::addOption(const QString &key, const QString &value)
+{
+ QTreeWidgetItem *item = nullptr;
+
+ if(key.contains(QLatin1Literal("shortcut"))) {
+ item = new QTreeWidgetItem(ui->shortcuts_treeWidget);
+
+ auto *edit = new QKeySequenceEdit(value);
+ ui->shortcuts_treeWidget->setItemWidget(item, 1, edit);
+
+ connect(edit, &QKeySequenceEdit::keySequenceChanged, this, [this, key](const QKeySequence &keySequence) {
+ emit configurationChanged(key, keySequence.toString());
+ });
+
+ } else {
+ item = new QTreeWidgetItem(ui->settings_treeWidget);
+
+ auto *edit = new QLineEdit(value);
+ ui->settings_treeWidget->setItemWidget(item, 1, edit);
+
+ connect(edit, &QLineEdit::editingFinished, this, [this, key, edit]() {
+ emit configurationChanged(key, edit->text());
+ });
+ }
+ item->setText(0, key);
+}
diff --git a/plugins/ConfigurationEditor/forms/configurationdialog.h b/plugins/ConfigurationEditor/forms/configurationdialog.h
index 9d86f2d..fd07aa8 100644
--- a/plugins/ConfigurationEditor/forms/configurationdialog.h
+++ b/plugins/ConfigurationEditor/forms/configurationdialog.h
@@ -1,21 +1,32 @@
+/*
+ * This file is part of smolbote. It's copyrighted by the contributors recorded
+ * in the version control history of the file, available from its original
+ * location: https://neueland.iserlohn-fortress.net/gitea/aqua/smolbote
+ *
+ * SPDX-License-Identifier: GPL-3.0
+ */
+
#ifndef CONFIGURATIONDIALOG_H
#define CONFIGURATIONDIALOG_H
#include <QDialog>
+#include "ui_configurationdialog.h"
-namespace Ui {
-class ConfigurationDialog;
-}
-
-class Configuration;
class ConfigurationDialog : public QDialog
{
Q_OBJECT
+ friend class ConfigurationEditorPlugin;
+
public:
- explicit ConfigurationDialog(Configuration *conf, QWidget *parent = nullptr);
+ explicit ConfigurationDialog(QWidget *parent = nullptr);
~ConfigurationDialog();
+ void addOption(const QString &key, const QString &value);
+
+signals:
+ void configurationChanged(const QString &key, const QString &value);
+
private:
Ui::ConfigurationDialog *ui;
};