| | |
| | |
| | |
| |
|
| | #pragma once |
| |
|
| | #include <QCheckBox> |
| | #include <QComboBox> |
| | #include "common/assert.h" |
| | #include "common/settings.h" |
| |
|
| | namespace ConfigurationShared { |
| |
|
| | constexpr int USE_GLOBAL_INDEX = |
| | 0; |
| | constexpr int USE_GLOBAL_SEPARATOR_INDEX = 1; |
| | constexpr int USE_GLOBAL_OFFSET = 2; |
| |
|
| | |
| | enum class CheckState { |
| | Off, |
| | On, |
| | Global, |
| | Count, |
| | }; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | void ApplyPerGameSetting(Settings::SwitchableSetting<bool>* setting, const QCheckBox* checkbox, |
| | const CheckState& tracker); |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | template <typename Type, bool ranged> |
| | void ApplyPerGameSetting(Settings::SwitchableSetting<Type, ranged>* setting, |
| | const QComboBox* combobox, auto transform) { |
| | if (Settings::IsConfiguringGlobal() && setting->UsingGlobal()) { |
| | setting->SetValue(static_cast<Type>(transform(combobox->currentIndex()))); |
| | } else if (!Settings::IsConfiguringGlobal()) { |
| | if (combobox->currentIndex() == ConfigurationShared::USE_GLOBAL_INDEX) { |
| | setting->SetGlobal(true); |
| | } else { |
| | setting->SetGlobal(false); |
| | setting->SetValue(static_cast<Type>( |
| | transform(combobox->currentIndex() - ConfigurationShared::USE_GLOBAL_OFFSET))); |
| | } |
| | } |
| | } |
| |
|
| | |
| | template <typename Type, bool ranged> |
| | void ApplyPerGameSetting(Settings::SwitchableSetting<Type, ranged>* setting, |
| | const QComboBox* combobox) { |
| | const auto transform = [](s32 index) { return index; }; |
| | return ApplyPerGameSetting(setting, combobox, transform); |
| | } |
| |
|
| | |
| | void SetPerGameSetting(QCheckBox* checkbox, const Settings::SwitchableSetting<bool>* setting); |
| |
|
| | template <typename Type, bool ranged> |
| | void SetPerGameSetting(QComboBox* combobox, |
| | const Settings::SwitchableSetting<Type, ranged>* setting) { |
| | combobox->setCurrentIndex(setting->UsingGlobal() ? ConfigurationShared::USE_GLOBAL_INDEX |
| | : static_cast<int>(setting->GetValue()) + |
| | ConfigurationShared::USE_GLOBAL_OFFSET); |
| | } |
| |
|
| | |
| | |
| | template <typename Type, bool ranged> |
| | Type GetComboboxSetting(int index, const Settings::SwitchableSetting<Type, ranged>* setting) { |
| | if (Settings::IsConfiguringGlobal() || setting->UsingGlobal()) { |
| | return static_cast<Type>(index); |
| | } else if (!Settings::IsConfiguringGlobal()) { |
| | if (index == 0) { |
| | return setting->GetValue(); |
| | } else { |
| | return static_cast<Type>(index - ConfigurationShared::USE_GLOBAL_OFFSET); |
| | } |
| | } |
| | UNREACHABLE(); |
| | } |
| |
|
| | |
| | |
| | void SetHighlight(QWidget* widget, bool highlighted); |
| |
|
| | |
| | void SetColoredTristate(QCheckBox* checkbox, const Settings::SwitchableSetting<bool>& setting, |
| | CheckState& tracker); |
| | void SetColoredTristate(QCheckBox* checkbox, bool global, bool state, bool global_state, |
| | CheckState& tracker); |
| |
|
| | |
| | |
| | void SetColoredComboBox(QComboBox* combobox, QWidget* target, int global); |
| |
|
| | |
| | void InsertGlobalItem(QComboBox* combobox, int global_index); |
| |
|
| | } |
| |
|