mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-10 16:19:28 +01:00
a7abd7dba0
GraphicsRadioInt is used by the panes in the Graphics config window to create radio buttons that change their associated config setting, and update their own state when something else changes the config setting. Despite its current name nothing about this class is particular to the Graphics window, so renaming it to ConfigRadioInt better reflects its purpose. This should also make it less confusing when ConfigRadioInts are added to other config panes.
35 lines
949 B
C++
35 lines
949 B
C++
// Copyright 2018 Dolphin Emulator Project
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#include "DolphinQt/Config/ConfigControls/ConfigRadio.h"
|
|
|
|
#include <QSignalBlocker>
|
|
|
|
#include "Common/Config/Config.h"
|
|
|
|
#include "DolphinQt/Settings.h"
|
|
|
|
ConfigRadioInt::ConfigRadioInt(const QString& label, const Config::Info<int>& setting, int value)
|
|
: ToolTipRadioButton(label), m_setting(setting), m_value(value)
|
|
{
|
|
setChecked(Config::Get(m_setting) == m_value);
|
|
connect(this, &QRadioButton::toggled, this, &ConfigRadioInt::Update);
|
|
|
|
connect(&Settings::Instance(), &Settings::ConfigChanged, this, [this] {
|
|
QFont bf = font();
|
|
bf.setBold(Config::GetActiveLayerForConfig(m_setting) != Config::LayerType::Base);
|
|
setFont(bf);
|
|
|
|
const QSignalBlocker blocker(this);
|
|
setChecked(Config::Get(m_setting) == m_value);
|
|
});
|
|
}
|
|
|
|
void ConfigRadioInt::Update()
|
|
{
|
|
if (!isChecked())
|
|
return;
|
|
|
|
Config::SetBaseOrCurrent(m_setting, m_value);
|
|
}
|