Commit 96da1081 authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Track changes in GroupsConfigPage instead of GroupsConfigDialog

GnuPG-bug-id: 5638
parent 2eda5760
......@@ -29,7 +29,6 @@ class GroupsConfigDialog::Private
GroupsConfigDialog *const q;
GroupsConfigPage *configPage = nullptr;
bool changed = false;
public:
Private(GroupsConfigDialog *qq)
......@@ -82,10 +81,9 @@ GroupsConfigDialog::GroupsConfigDialog(QWidget *parent)
this, &GroupsConfigDialog::updateWidgets);
connect(d->configPage, &GroupsConfigPage::changed, this, [this] (bool state) {
d->changed = state;
updateButtons();
if (QPushButton *button = buttonBox()->button(QDialogButtonBox::Reset)) {
button->setEnabled(d->changed);
button->setEnabled(d->configPage->hasChanged());
}
});
}
......@@ -109,5 +107,5 @@ void GroupsConfigDialog::updateWidgets()
bool GroupsConfigDialog::hasChanged()
{
return d->changed;
return d->configPage->hasChanged();
}
......@@ -33,8 +33,11 @@ class GroupsConfigPage::Private
public:
~Private() = default;
void setChanged(bool changed);
private:
GroupsConfigWidget *widget = nullptr;
bool changed = false;
};
GroupsConfigPage::Private::Private(GroupsConfigPage *qq)
......@@ -42,6 +45,12 @@ GroupsConfigPage::Private::Private(GroupsConfigPage *qq)
{
}
void GroupsConfigPage::Private::setChanged(bool state)
{
changed = state;
Q_EMIT q->changed(changed);
}
GroupsConfigPage::GroupsConfigPage(QWidget *parent)
: QWidget(parent)
, d(new Private(this))
......@@ -56,15 +65,20 @@ GroupsConfigPage::GroupsConfigPage(QWidget *parent)
layout->addWidget(d->widget);
connect(d->widget, &GroupsConfigWidget::changed, this, [this] () { Q_EMIT changed(true); });
connect(d->widget, &GroupsConfigWidget::changed, this, [this] () { d->setChanged(true); });
}
GroupsConfigPage::~GroupsConfigPage() = default;
bool GroupsConfigPage::hasChanged() const
{
return d->changed;
}
void GroupsConfigPage::load()
{
d->widget->setGroups(KeyCache::instance()->configurableGroups());
Q_EMIT changed(false);
d->setChanged(false);
}
void GroupsConfigPage::save()
......
......@@ -21,6 +21,8 @@ public:
explicit GroupsConfigPage(QWidget *parent = nullptr);
~GroupsConfigPage() override;
bool hasChanged() const;
public Q_SLOTS:
void load();
void save();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment