| 8 | #include <QSettings> |
| 9 | |
| 10 | class SettingsAgent : public QObject |
| 11 | { |
| 12 | Q_OBJECT |
| 13 | public: |
| 14 | // 接口 |
| 15 | static SettingsAgent& instance(); |
| 16 | |
| 17 | /***** 相关的 getter 与 settter *****/ |
| 18 | Theme::ThemeMode ThemeMode() const; |
| 19 | void setThemeMode(Theme::ThemeMode& theme_mode); |
| 20 | |
| 21 | Qt::WindowStates WindowState() const; |
| 22 | void setWindowSate(Qt::WindowStates& window_state); |
| 23 | |
| 24 | QString Hotkey() const; |
| 25 | void setHotkey(const QString& hotkey); |
| 26 | |
| 27 | QString Language() const; |
| 28 | void setLanguage(const QString& language); |
| 29 | /***********************************/ |
| 30 | |
| 31 | signals: |
| 32 | void currentThemeChanged(Theme::ThemeMode current_theme); |
| 33 | void currentLanguageChanged(const QString current_language); |
| 34 | |
| 35 | private: |
| 36 | explicit SettingsAgent(QObject *parent = nullptr); |
| 37 | ~SettingsAgent(); |
| 38 | Q_DISABLE_COPY(SettingsAgent); |
| 39 | |
| 40 | // 所有配置以键值对形式存储 |
| 41 | QMap<QString, QVariant> _config; |
| 42 | |
| 43 | // 配置文件完整文件路径 |
| 44 | QString _settings_file_path; |
| 45 | |
| 46 | // 默认主题设置 |
| 47 | const Theme::ThemeMode _DEFAULT_THEMEMODE = Theme::Light; |
| 48 | |
| 49 | // 默认语言设置 |
| 50 | const QString _DEFAULT_LANGUAGE = "en_US"; |
| 51 | // 支持语言列表 |
| 52 | const QStringList _language_support_list = { |
| 53 | "en_US", |
| 54 | "zh_CN", |
| 55 | "zh_TW" |
| 56 | }; |
| 57 | }; |
| 58 | |
| 59 | #endif // SETTINGSAGENT_H |
nothing calls this directly
no outgoing calls
no test coverage detected