- virtual bool hasDefaults() const;
-
- //! Check if there are changes in the page, compared to the state saved in permanent storage.
- bool hasChanged() const;
-
- //! Called immediately before save() is called.
- /** Derived classes should return false if saving is not possible (e.g. the current settings are invalid).
- * \return false, if the SettingsPage cannot be saved in its current state.
- */
- virtual bool aboutToSave();
-
- public slots:
- //! Save settings to permanent storage.
- virtual void save() = 0;
-
- //! Load settings from permanent storage, overriding any changes the user might have made in the dialog.
- virtual void load() = 0;
-
- //! Restore defaults, overriding any changes the user might have made in the dialog.
- /** The default implementation does nothing.
- */
- virtual void defaults();
-
- protected slots:
- //! Calling this slot is equivalent to calling setChangedState(true).
- void changed();
-
- protected:
- //! This should be called whenever the widget state changes from unchanged to change or the other way round.
- void setChangedState(bool hasChanged = true);
+ inline virtual bool hasDefaults() const { return false; }
+
+ //! Check if there are changes in the page, compared to the state saved in permanent storage.
+ inline bool hasChanged() const { return _changed || _autoWidgetsChanged; }
+
+ //! Called immediately before save() is called.
+ /** Derived classes should return false if saving is not possible (e.g. the current settings are invalid).
+ * \return false, if the SettingsPage cannot be saved in its current state.
+ */
+ inline virtual bool aboutToSave() { return true; }
+
+ //! sets checked state depending on \checked and stores the value for later comparision
+ static void load(QCheckBox *box, bool checked);
+ static bool hasChanged(QCheckBox *box);
+ static void load(QComboBox *box, int index);
+ static bool hasChanged(QComboBox *box);
+ static void load(QSpinBox *box, int value);
+ static bool hasChanged(QSpinBox *box);
+
+public slots:
+ //! Save settings to permanent storage.
+ /** This baseclass implementation saves the autoWidgets, so be sure to call it if you use
+ * this feature in your settingsPage!
+ */
+ virtual void save();
+
+ //! Load settings from permanent storage, overriding any changes the user might have made in the dialog.
+ /** This baseclass implementation loads the autoWidgets, so be sure to call it if you use
+ * this feature in your settingsPage!
+ */
+ virtual void load();
+
+ //! Restore defaults, overriding any changes the user might have made in the dialog.
+ /** This baseclass implementation loads the defaults of the autoWidgets (if available), so be sure
+ * to call it if you use this feature in your settingsPage!
+ */
+ virtual void defaults();
+
+protected slots:
+ //! Calling this slot is equivalent to calling setChangedState(true).
+ inline void changed() { setChangedState(true); }
+
+ //! This should be called whenever the widget state changes from unchanged to change or the other way round.
+ void setChangedState(bool hasChanged = true);
+
+protected:
+ void initAutoWidgets();
+ virtual QVariant loadAutoWidgetValue(const QString &widgetName);
+ virtual void saveAutoWidgetValue(const QString &widgetName, const QVariant &value);
+
+signals:
+ //! Emitted whenever the widget state changes.
+ void changed(bool hasChanged);
+
+private slots:
+ // for auto stuff
+ void autoWidgetHasChanged();
+
+private:
+ void findAutoWidgets(QObject *parent, QObjectList *widgetList) const;
+ QByteArray autoWidgetPropertyName(QObject *widget) const;
+ QString autoWidgetSettingsKey(QObject *widget) const;
+
+ QString _category, _title;
+ bool _changed, _autoWidgetsChanged;
+ QObjectList _autoWidgets;
+};