diff options
author | lat9nq <lat9nq@virginia.edu> | 2020-07-13 23:08:24 +0200 |
---|---|---|
committer | lat9nq <lat9nq@virginia.edu> | 2020-07-19 19:26:55 +0200 |
commit | e26e82d8d5f9a3907b3623bd50dffd1c9b84969e (patch) | |
tree | 7dcd7e9dc01a56cecfded796479c63b1b330befd | |
parent | Merge pull request #4376 from ogniK5377/dark-wait-tree (diff) | |
download | yuzu-e26e82d8d5f9a3907b3623bd50dffd1c9b84969e.tar yuzu-e26e82d8d5f9a3907b3623bd50dffd1c9b84969e.tar.gz yuzu-e26e82d8d5f9a3907b3623bd50dffd1c9b84969e.tar.bz2 yuzu-e26e82d8d5f9a3907b3623bd50dffd1c9b84969e.tar.lz yuzu-e26e82d8d5f9a3907b3623bd50dffd1c9b84969e.tar.xz yuzu-e26e82d8d5f9a3907b3623bd50dffd1c9b84969e.tar.zst yuzu-e26e82d8d5f9a3907b3623bd50dffd1c9b84969e.zip |
-rw-r--r-- | src/yuzu/configuration/configuration_shared.cpp | 42 | ||||
-rw-r--r-- | src/yuzu/configuration/configuration_shared.h | 16 |
2 files changed, 58 insertions, 0 deletions
diff --git a/src/yuzu/configuration/configuration_shared.cpp b/src/yuzu/configuration/configuration_shared.cpp index bb47c3933..f32fcf3b7 100644 --- a/src/yuzu/configuration/configuration_shared.cpp +++ b/src/yuzu/configuration/configuration_shared.cpp @@ -4,10 +4,15 @@ #include <QCheckBox> #include <QComboBox> +#include <QObject> #include "core/settings.h" #include "yuzu/configuration/configuration_shared.h" #include "yuzu/configuration/configure_per_game.h" +namespace ConfigurationShared { +Trackers trackers = {}; +} + void ConfigurationShared::ApplyPerGameSetting(Settings::Setting<bool>* setting, const QCheckBox* checkbox) { if (checkbox->checkState() == Qt::PartiallyChecked) { @@ -18,6 +23,17 @@ void ConfigurationShared::ApplyPerGameSetting(Settings::Setting<bool>* setting, } } +void ConfigurationShared::ApplyPerGameSetting(Settings::Setting<bool>* setting, + const QCheckBox* checkbox, + const CheckState& tracker) { + if (tracker == CheckState::Global) { + setting->SetGlobal(true); + } else { + setting->SetGlobal(false); + setting->SetValue(checkbox->checkState()); + } +} + void ConfigurationShared::ApplyPerGameSetting(Settings::Setting<int>* setting, const QComboBox* combobox) { if (combobox->currentIndex() == ConfigurationShared::USE_GLOBAL_INDEX) { @@ -69,6 +85,32 @@ void ConfigurationShared::SetPerGameSetting( ConfigurationShared::USE_GLOBAL_OFFSET); } +void ConfigurationShared::SetBGColor(QWidget* widget, bool highlighted) { + if (highlighted) { + widget->setStyleSheet(QStringLiteral("background-color:rgba(0,203,255,0.5);")); + } else { + widget->setStyleSheet(QStringLiteral("background-color:rgba(0,0,0,0);")); + } + widget->show(); +} + +void ConfigurationShared::SetColoredTristate(QCheckBox* checkbox, Settings::Setting<bool>& setting, + ConfigurationShared::CheckState& tracker) { + if (setting.UsingGlobal()) { + tracker = CheckState::Global; + } else { + tracker = (setting.GetValue() == setting.GetValue(true)) ? CheckState::On : CheckState::Off; + } + SetBGColor(checkbox, tracker != CheckState::Global); + QObject::connect(checkbox, &QCheckBox::clicked, checkbox, [checkbox, setting, &tracker]() { + tracker = static_cast<ConfigurationShared::CheckState>((tracker + 1) % CheckState::Count); + if (tracker == CheckState::Global) { + checkbox->setChecked(setting.GetValue(true)); + } + SetBGColor(checkbox, tracker != CheckState::Global); + }); +} + void ConfigurationShared::InsertGlobalItem(QComboBox* combobox) { const QString use_global_text = ConfigurePerGame::tr("Use global configuration"); combobox->insertItem(ConfigurationShared::USE_GLOBAL_INDEX, use_global_text); diff --git a/src/yuzu/configuration/configuration_shared.h b/src/yuzu/configuration/configuration_shared.h index b11b1b950..1163604bf 100644 --- a/src/yuzu/configuration/configuration_shared.h +++ b/src/yuzu/configuration/configuration_shared.h @@ -15,8 +15,20 @@ constexpr int USE_GLOBAL_INDEX = 0; constexpr int USE_GLOBAL_SEPARATOR_INDEX = 1; constexpr int USE_GLOBAL_OFFSET = 2; +enum CheckState { + Off, + On, + Global, + Count, +}; + +struct Trackers { +} extern trackers; + // Global-aware apply and set functions +void ApplyPerGameSetting(Settings::Setting<bool>* setting, const QCheckBox* checkbox, + const CheckState& tracker); void ApplyPerGameSetting(Settings::Setting<bool>* setting, const QCheckBox* checkbox); void ApplyPerGameSetting(Settings::Setting<int>* setting, const QComboBox* combobox); void ApplyPerGameSetting(Settings::Setting<Settings::RendererBackend>* setting, @@ -31,6 +43,10 @@ void SetPerGameSetting(QComboBox* combobox, void SetPerGameSetting(QComboBox* combobox, const Settings::Setting<Settings::GPUAccuracy>* setting); +void SetBGColor(QWidget* widget, bool highlighted); +void SetColoredTristate(QCheckBox* checkbox, Settings::Setting<bool>& setting, + ConfigurationShared::CheckState& tracker); + void InsertGlobalItem(QComboBox* combobox); } // namespace ConfigurationShared |