dolphin/Source/Core/DolphinQt/Config/ConfigControls/ConfigRadio.cpp
Dentomologist 70b0bb4fc0 ConfigControl: Fix font styling bugs
Fix two bugs with bold and italic labels when a non-Base config layer is
active.

First, when constructing a ConfigControl the label wouldn't be
bolded until the next time a ConfigChanged signal was received. This
would happen if the user started a game before opening a config window
for the first time since starting Dolphin.

Second, ConfigRadioInt would bold/italicize every radio button for that
setting instead of just the selected radio button.

Renames the IsConfigLocal function to ShouldLabelBeBold, since the
former name was inaccurate if m_layer wasn't the local layer.
2025-09-25 10:47:28 -07:00

48 lines
1003 B
C++

// Copyright 2018 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "DolphinQt/Config/ConfigControls/ConfigRadio.h"
ConfigRadioInt::ConfigRadioInt(const QString& label, const Config::Info<int>& setting, int value,
Config::Layer* layer)
: ConfigControl(label, setting.GetLocation(), layer), m_setting(setting), m_value(value)
{
setChecked(IsSelected());
connect(this, &QRadioButton::toggled, this, &ConfigRadioInt::Update);
}
int ConfigRadioInt::GetValue() const
{
return m_value;
}
void ConfigRadioInt::Update()
{
if (isChecked())
{
SaveValue(m_setting, m_value);
emit OnSelected(m_value);
}
else
{
emit OnDeselected(m_value);
}
}
bool ConfigRadioInt::IsSelected() const
{
return ReadValue(m_setting) == m_value;
}
void ConfigRadioInt::OnConfigChanged()
{
setChecked(IsSelected());
}
bool ConfigRadioInt::ShouldLabelBeBold() const
{
return IsSelected() && ConfigControl::ShouldLabelBeBold();
}