settings: Only save settings for visited pages
Set a flag when a page is shown. On apply or accept, only save if that flag is set.
This commit is contained in:
parent
77badd37ff
commit
96a17c9f40
@ -17,18 +17,35 @@
|
||||
|
||||
#include "settingsdialog.h"
|
||||
#include "settingspage.h"
|
||||
#include "core/logging.h"
|
||||
|
||||
SettingsPage::SettingsPage(SettingsDialog* dialog)
|
||||
: QWidget(dialog), dialog_(dialog) {}
|
||||
: QWidget(dialog), maybe_changed_(false), dialog_(dialog) {}
|
||||
|
||||
void SettingsPage::showEvent(QShowEvent* event) {
|
||||
QWidget::showEvent(event);
|
||||
maybe_changed_ = true;
|
||||
}
|
||||
|
||||
void SettingsPage::Apply() {
|
||||
Save();
|
||||
if (maybe_changed_) {
|
||||
qLog(Debug) << "Saving" << windowTitle();
|
||||
Save();
|
||||
if (!isVisible())
|
||||
// Don't expect additional changes until the page is visible again.
|
||||
maybe_changed_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
void SettingsPage::Accept() {
|
||||
Save();
|
||||
if (maybe_changed_) {
|
||||
qLog(Debug) << "Saving" << windowTitle();
|
||||
Save();
|
||||
maybe_changed_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
void SettingsPage::Reject() {
|
||||
Cancel();
|
||||
maybe_changed_ = false;
|
||||
}
|
||||
|
@ -45,10 +45,15 @@ class SettingsPage : public QWidget {
|
||||
// The dialog that this page belongs to.
|
||||
SettingsDialog* dialog() const { return dialog_; }
|
||||
|
||||
signals:
|
||||
signals:
|
||||
void NotificationPreview(OSD::Behaviour, QString, QString);
|
||||
void SetWiimotedevInterfaceActived(bool);
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent* event);
|
||||
|
||||
bool maybe_changed_;
|
||||
|
||||
private:
|
||||
virtual void Save() = 0;
|
||||
virtual void Cancel() {}
|
||||
|
Loading…
x
Reference in New Issue
Block a user