|
@ -16,14 +16,17 @@ |
|
|
using namespace QtMvvm; |
|
|
using namespace QtMvvm; |
|
|
|
|
|
|
|
|
SettingsDialog::SettingsDialog(ViewModel *viewModel, QWidget *parent) : |
|
|
SettingsDialog::SettingsDialog(ViewModel *viewModel, QWidget *parent) : |
|
|
QDialog(parent), |
|
|
QDialog{parent}, |
|
|
d(new SettingsDialogPrivate(this, viewModel)) |
|
|
d{new SettingsDialogPrivate{this, viewModel}} |
|
|
{ |
|
|
{ |
|
|
d->ui->setupUi(this); |
|
|
d->ui->setupUi(this); |
|
|
connect(d->ui->buttonBox, &QDialogButtonBox::clicked, |
|
|
connect(d->ui->buttonBox, &QDialogButtonBox::clicked, |
|
|
d, &SettingsDialogPrivate::buttonBoxClicked); |
|
|
d, &SettingsDialogPrivate::buttonBoxClicked); |
|
|
connect(d->ui->filterLineEdit, &QLineEdit::textChanged, |
|
|
connect(d->ui->filterLineEdit, &QLineEdit::textChanged, |
|
|
d, &SettingsDialogPrivate::filterTextChanged); |
|
|
d, &SettingsDialogPrivate::filterTextChanged); |
|
|
|
|
|
connect(d->viewModel, &SettingsViewModel::valueChanged, |
|
|
|
|
|
d, &SettingsDialogPrivate::entryChanged, |
|
|
|
|
|
Qt::QueuedConnection); // to detach updated from the bulk save operation
|
|
|
|
|
|
|
|
|
if(parentWidget()) { |
|
|
if(parentWidget()) { |
|
|
setWindowModality(Qt::WindowModal); |
|
|
setWindowModality(Qt::WindowModal); |
|
@ -104,6 +107,15 @@ void SettingsDialogPrivate::createUi() |
|
|
ui->categoryListWidget->setCurrentRow(0); |
|
|
ui->categoryListWidget->setCurrentRow(0); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SettingsDialogPrivate::entryChanged(const QString &key) |
|
|
|
|
|
{ |
|
|
|
|
|
auto content = keyMap.value(key); |
|
|
|
|
|
if(!content) |
|
|
|
|
|
return; |
|
|
|
|
|
auto info = entryMap.value(content); |
|
|
|
|
|
info.second.write(content, viewModel->loadValue(info.first.key, info.first.defaultValue)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
void SettingsDialogPrivate::createCategory(const SettingsElements::Category &category) |
|
|
void SettingsDialogPrivate::createCategory(const SettingsElements::Category &category) |
|
|
{ |
|
|
{ |
|
|
auto item = new QListWidgetItem(); |
|
|
auto item = new QListWidgetItem(); |
|
@ -195,6 +207,7 @@ void SettingsDialogPrivate::createEntry(const SettingsElements::Entry &entry, QW |
|
|
changedEntries.insert(content); |
|
|
changedEntries.insert(content); |
|
|
|
|
|
|
|
|
entryMap.insert(content, {entry, property}); |
|
|
entryMap.insert(content, {entry, property}); |
|
|
|
|
|
keyMap.insert(entry.key, content); |
|
|
} catch (PresenterException &e) { |
|
|
} catch (PresenterException &e) { |
|
|
logWarning() << "Failed to create settings widget for key" |
|
|
logWarning() << "Failed to create settings widget for key" |
|
|
<< entry.key |
|
|
<< entry.key |
|
|