diff options
| author | TryTwo <taolas@gmail.com> | 2024-09-17 23:29:13 -0700 |
|---|---|---|
| committer | JosJuice <josjuice@gmail.com> | 2024-12-07 16:31:34 +0100 |
| commit | 08df9a66e03acb614dca6d1c118818f84f1cbcfd (patch) | |
| tree | c8f1e1c18b24ec4e4aaa50e572a78776aac37092 /Source/Core/DolphinQt/Config/ConfigControls/ConfigBool.cpp | |
| parent | 0a84d93a8e64d946405b0e17edd1a29ccfac0606 (diff) | |
DolphinQt: Refactor, add ConfigControl class
This reduces code duplication in the different ConfigControls. This is
helpful for the next commit, which will modify the now deduplicated
code.
Diffstat (limited to 'Source/Core/DolphinQt/Config/ConfigControls/ConfigBool.cpp')
| -rw-r--r-- | Source/Core/DolphinQt/Config/ConfigControls/ConfigBool.cpp | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/Source/Core/DolphinQt/Config/ConfigControls/ConfigBool.cpp b/Source/Core/DolphinQt/Config/ConfigControls/ConfigBool.cpp index 89ab9c15be..0f99284297 100644 --- a/Source/Core/DolphinQt/Config/ConfigControls/ConfigBool.cpp +++ b/Source/Core/DolphinQt/Config/ConfigControls/ConfigBool.cpp @@ -3,31 +3,22 @@ #include "DolphinQt/Config/ConfigControls/ConfigBool.h" -#include <QEvent> -#include <QFont> -#include <QSignalBlocker> - -#include "Common/Config/Config.h" - -#include "DolphinQt/Settings.h" - ConfigBool::ConfigBool(const QString& label, const Config::Info<bool>& setting, bool reverse) - : ToolTipCheckBox(label), m_setting(setting), m_reverse(reverse) + : ConfigControl(label, setting.GetLocation()), m_setting(setting), m_reverse(reverse) { + setChecked(ReadValue(setting) ^ reverse); + connect(this, &QCheckBox::toggled, this, &ConfigBool::Update); - setChecked(Config::Get(m_setting) ^ reverse); +} - connect(&Settings::Instance(), &Settings::ConfigChanged, this, [this] { - QFont bf = font(); - bf.setBold(Config::GetActiveLayerForConfig(m_setting) != Config::LayerType::Base); - setFont(bf); +void ConfigBool::Update() +{ + const bool value = static_cast<bool>(isChecked() ^ m_reverse); - const QSignalBlocker blocker(this); - setChecked(Config::Get(m_setting) ^ m_reverse); - }); + SaveValue(m_setting, value); } -void ConfigBool::Update() +void ConfigBool::OnConfigChanged() { - Config::SetBaseOrCurrent(m_setting, static_cast<bool>(isChecked() ^ m_reverse)); + setChecked(ReadValue(m_setting) ^ m_reverse); } |
