diff --git a/src/ui/settingspage.cpp b/src/ui/settingspage.cpp index dfb32657b..f21affe32 100644 --- a/src/ui/settingspage.cpp +++ b/src/ui/settingspage.cpp @@ -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; } diff --git a/src/ui/settingspage.h b/src/ui/settingspage.h index 22858dc3b..852e2d697 100644 --- a/src/ui/settingspage.h +++ b/src/ui/settingspage.h @@ -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() {}