configuration_shared.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // Copyright 2016 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <QCheckBox>
  6. #include <QComboBox>
  7. #include <QString>
  8. #include "common/settings.h"
  9. namespace ConfigurationShared {
  10. constexpr int USE_GLOBAL_INDEX = 0;
  11. constexpr int USE_GLOBAL_SEPARATOR_INDEX = 1;
  12. constexpr int USE_GLOBAL_OFFSET = 2;
  13. // CheckBoxes require a tracker for their state since we emulate a tristate CheckBox
  14. enum class CheckState {
  15. Off, // Checkbox overrides to off/false
  16. On, // Checkbox overrides to on/true
  17. Global, // Checkbox defers to the global state
  18. Count, // Simply the number of states, not a valid checkbox state
  19. };
  20. // Global-aware apply and set functions
  21. // ApplyPerGameSetting, given a Settings::Setting and a Qt UI element, properly applies a Setting
  22. void ApplyPerGameSetting(Settings::Setting<bool>* setting, const QCheckBox* checkbox,
  23. const CheckState& tracker);
  24. void ApplyPerGameSetting(Settings::Setting<int>* setting, const QComboBox* combobox);
  25. void ApplyPerGameSetting(Settings::Setting<Settings::RendererBackend>* setting,
  26. const QComboBox* combobox);
  27. // Sets a Qt UI element given a Settings::Setting
  28. void SetPerGameSetting(QCheckBox* checkbox, const Settings::Setting<bool>* setting);
  29. void SetPerGameSetting(QComboBox* combobox, const Settings::Setting<int>* setting);
  30. void SetPerGameSetting(QComboBox* combobox,
  31. const Settings::Setting<Settings::RendererBackend>* setting);
  32. void SetPerGameSetting(QComboBox* combobox,
  33. const Settings::Setting<Settings::GPUAccuracy>* setting);
  34. void SetPerGameSetting(QComboBox* combobox,
  35. const Settings::Setting<Settings::CPUAccuracy>* setting);
  36. // (Un)highlights a Qt UI element
  37. void SetHighlight(QWidget* widget, bool highlighted);
  38. // Sets up a QCheckBox like a tristate one, given a Setting
  39. void SetColoredTristate(QCheckBox* checkbox, const Settings::Setting<bool>& setting,
  40. CheckState& tracker);
  41. void SetColoredTristate(QCheckBox* checkbox, bool global, bool state, bool global_state,
  42. CheckState& tracker);
  43. // Sets up coloring of a QWidget `target` based on the state of a QComboBox, and calls
  44. // InsertGlobalItem
  45. void SetColoredComboBox(QComboBox* combobox, QWidget* target, int global);
  46. // Adds the "Use Global Configuration" selection and separator to the beginning of a QComboBox
  47. void InsertGlobalItem(QComboBox* combobox, int global_index);
  48. } // namespace ConfigurationShared