| 1 | // For license of this file, see <project-root-folder>/LICENSE.md. |
| 2 | |
| 3 | #ifndef SETTINGSPANEL_H |
| 4 | #define SETTINGSPANEL_H |
| 5 | |
| 6 | #include <QWidget> |
| 7 | |
| 8 | class Settings; |
| 9 | |
| 10 | class SettingsPanel : public QWidget { |
| 11 | Q_OBJECT |
| 12 | |
| 13 | public: |
| 14 | explicit SettingsPanel(Settings* settings, QWidget* parent = nullptr); |
| 15 | |
| 16 | virtual QString title() const = 0; |
| 17 | virtual QIcon icon() const = 0; |
| 18 | virtual void loadSettings() = 0; |
| 19 | virtual void saveSettings() = 0; |
| 20 | |
| 21 | bool requiresRestart() const; |
| 22 | bool isDirty() const; |
| 23 | |
| 24 | void setIsDirty(bool is_dirty); |
| 25 | void setRequiresRestart(bool requiresRestart); |
| 26 | |
| 27 | bool isLoaded() const; |
| 28 | |
| 29 | protected: |
| 30 | void onBeginLoadSettings(); |
| 31 | void onEndLoadSettings(); |
| 32 | void onBeginSaveSettings(); |
| 33 | void onEndSaveSettings(); |
| 34 | |
| 35 | // Settings to use to save/load. |
| 36 | Settings* settings() const; |
| 37 | |
| 38 | protected slots: |
| 39 | void dirtifySettings(); |
| 40 | void requireRestart(); |
| 41 | |
| 42 | signals: |
| 43 | void settingsChanged(); |
| 44 | |
| 45 | private: |
| 46 | bool m_requiresRestart; |
| 47 | bool m_isDirty; |
| 48 | bool m_isLoading; |
| 49 | bool m_isLoaded; |
| 50 | Settings* m_settings; |
| 51 | }; |
| 52 | |
| 53 | #endif // SETTINGSPANEL_H |