- public:
- SettingsPage(const QString &category, const QString &name, QWidget *parent = 0);
- virtual ~SettingsPage() {};
- virtual QString category() const;
- virtual QString title() const;
+public:
+ SettingsPage(const QString &category, const QString &name, QWidget *parent = 0);
+ virtual ~SettingsPage() {};
+
+ //! The category of this settings page.
+ inline virtual QString category() const { return _category; }
+
+ //! The title of this settings page.
+ inline virtual QString title() const { return _title; }
+
+ //! Derived classes need to define this and return true if they have default settings.
+ /** If this method returns true, the "Restore Defaults" button in the SettingsDlg is
+ * enabled. You also need to provide an implementation of defaults() then.
+ *
+ * The default implementation returns false.
+ */
+ 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; }
+
+ //! 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; }
+
+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;