blob: ffe7f9c9f4549c9d4cff5c8245466215e51dc89f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#include "configurationdialog.h"
#include "ui_configurationdialog.h"
#include <configuration.h>
#include <QKeySequenceEdit>
ConfigurationDialog::ConfigurationDialog(Configuration *conf, 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;
}
|