diff options
author | lat9nq <22451773+lat9nq@users.noreply.github.com> | 2021-06-28 15:58:16 -0400 |
---|---|---|
committer | lat9nq <22451773+lat9nq@users.noreply.github.com> | 2021-06-28 17:32:17 -0400 |
commit | b91b76df4fe27d781bd95ddb89b78ff54df57029 (patch) | |
tree | abd3de5c02b036ec936a70599e496ba1d45d7849 /src/yuzu/configuration/config.h | |
parent | 35b17fa5e0a69c019852fed9ede9b64f08dd21a0 (diff) |
general: Make most settings a BasicSetting
Creates a new BasicSettings class in common/settings, and forces setting
a default and label for each setting that uses it in common/settings.
Moves defaults and labels from both frontends into common settings.
Creates a helper function in each frontend to facillitate reading the
settings now with the new default and label properties.
Settings::Setting is also now a subclass of Settings::BasicSetting. Also
adds documentation for both Setting and BasicSetting.
Diffstat (limited to 'src/yuzu/configuration/config.h')
-rw-r--r-- | src/yuzu/configuration/config.h | 75 |
1 files changed, 61 insertions, 14 deletions
diff --git a/src/yuzu/configuration/config.h b/src/yuzu/configuration/config.h index 62501997c..96f9b6de1 100644 --- a/src/yuzu/configuration/config.h +++ b/src/yuzu/configuration/config.h @@ -102,28 +102,75 @@ private: void SaveUILayoutValues(); void SaveWebServiceValues(); + /** + * Reads a setting from the qt_config. + * + * @param name The setting's identifier + * @param default_value The value to use when the setting is not already present in the config + */ QVariant ReadSetting(const QString& name) const; QVariant ReadSetting(const QString& name, const QVariant& default_value) const; - QVariant ReadSetting(const QString& name, Settings::CPUAccuracy default_value) const; - QVariant ReadSetting(const QString& name, Settings::GPUAccuracy default_value) const; - QVariant ReadSetting(const QString& name, Settings::RendererBackend default_value) const; - // Templated ReadSettingGlobal functions will also look for the use_global setting and set - // both the value and the global state properly - template <typename Type> - void ReadSettingGlobal(Settings::Setting<Type>& setting, const QString& name); + + /** + * Only reads a setting from the qt_config if the current config is a global config, or if the + * current config is a custom config and the setting is overriding the global setting. Otherwise + * it does nothing. + * + * @param setting The variable to be modified + * @param name The setting's identifier + * @param default_value The value to use when the setting is not already present in the config + */ template <typename Type> void ReadSettingGlobal(Type& setting, const QString& name, const QVariant& default_value) const; - // Templated WriteSettingGlobal functions will also write the global state if needed and will - // skip writing the actual setting if it defers to the global value + + /** + * Writes a setting to the qt_config. + * + * @param name The setting's idetentifier + * @param value Value of the setting + * @param default_value Default of the setting if not present in qt_config + * @param use_global Specifies if the custom or global config should be in use, for custom + * configs + */ void WriteSetting(const QString& name, const QVariant& value); void WriteSetting(const QString& name, const QVariant& value, const QVariant& default_value); + void WriteSetting(const QString& name, const QVariant& value, const QVariant& default_value, + bool use_global); + + /** + * Reads a value from the qt_config and applies it to the setting, using its label and default + * value. If the config is a custom config, this will also read the global state of the setting + * and apply that information to it. + * + * @param The setting + */ template <typename Type> - void WriteSettingGlobal(const QString& name, const Settings::Setting<Type>& setting); + void ReadGlobalSetting(Settings::Setting<Type>& setting); + + /** + * Sets a value to the qt_config using the setting's label and default value. If the config is a + * custom config, it will apply the global state, and the custom value if needed. + * + * @param The setting + */ + template <typename Type> + void WriteGlobalSetting(const Settings::Setting<Type>& setting); + + /** + * Reads a value from the qt_config using the setting's label and default value and applies the + * value to the setting. + * + * @param The setting + */ + template <typename Type> + void ReadBasicSetting(Settings::BasicSetting<Type>& setting); + + /** Sets a value from the setting in the qt_config using the setting's label and default value. + * + * @param The setting + */ template <typename Type> - void WriteSettingGlobal(const QString& name, const Settings::Setting<Type>& setting, - const QVariant& default_value); - void WriteSettingGlobal(const QString& name, const QVariant& value, bool use_global, - const QVariant& default_value); + void WriteBasicSetting(const Settings::BasicSetting<Type>& setting); ConfigType type; std::unique_ptr<QSettings> qt_config; |