From 60773194a039fced8cf2da308e1b8220d08a1636 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Mon, 5 Jun 2023 21:05:22 -0400 Subject: settings: Add a registry of settings LoadString: Sanitize input settings: Handle empty string, remove redundant category settings: Rename Input to Controls, FS to DataStorage settings: Fix Controls groups information settings: Move use_docked_mode to System (again) settings: Document settings: Add type identification function settings: Move registry into values settings: Move global_reset_registry into values settings: Separate AdvGraphics from Renderer settings: More document squash settings: Use linkage object uisettings: Move registry into settings Probably wont build without uisettings: Use settings linkage object config: Load settings with a map Uses the new all_settings vector to load settings. qt-config: Rename settings category qt config: Rename to read category config: Read/write contols category with for_each This is extremely limited due to the complexity of the Controls group, but this handles the the settings that use the interface. qt-config: Use new settings registry qt-config: Read/write advgrphics qt-config: Use settings linkage object yuzu_cmd: Load setting off of vector cmd-config: Finish settings rename config: Read controls settings group with for_each cmd/config: Move registry into values cmd: Read adv graphics cmd-config: Use settings linkage object --- src/yuzu/configuration/configuration_shared.h | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'src/yuzu/configuration/configuration_shared.h') diff --git a/src/yuzu/configuration/configuration_shared.h b/src/yuzu/configuration/configuration_shared.h index 04c88758c..1e61bcbeb 100644 --- a/src/yuzu/configuration/configuration_shared.h +++ b/src/yuzu/configuration/configuration_shared.h @@ -57,8 +57,26 @@ void SetPerGameSetting(QComboBox* combobox, void SetHighlight(QWidget* widget, bool highlighted); // Sets up a QCheckBox like a tristate one, given a Setting -void SetColoredTristate(QCheckBox* checkbox, const Settings::SwitchableSetting& setting, - CheckState& tracker); +template +void SetColoredTristate(QCheckBox* checkbox, + const Settings::SwitchableSetting& setting, + CheckState& tracker) { + if (setting.UsingGlobal()) { + tracker = CheckState::Global; + } else { + tracker = (setting.GetValue() == setting.GetValue(true)) ? CheckState::On : CheckState::Off; + } + SetHighlight(checkbox, tracker != CheckState::Global); + QObject::connect(checkbox, &QCheckBox::clicked, checkbox, [checkbox, setting, &tracker] { + tracker = static_cast((static_cast(tracker) + 1) % + static_cast(CheckState::Count)); + if (tracker == CheckState::Global) { + checkbox->setChecked(setting.GetValue(true)); + } + SetHighlight(checkbox, tracker != CheckState::Global); + }); +} + void SetColoredTristate(QCheckBox* checkbox, bool global, bool state, bool global_state, CheckState& tracker); -- cgit v1.2.3