Add method to bold slider/spin labels when a user game ini setting is being used

This commit is contained in:
TryTwo 2024-09-29 17:12:22 -07:00
parent fd52e55ef8
commit f215d5f5b1
6 changed files with 55 additions and 4 deletions

View File

@ -29,3 +29,13 @@ void ConfigInteger::OnConfigChanged()
{
setValue(ReadValue(m_setting));
}
ConfigIntegerLabel::ConfigIntegerLabel(const QString& text, ConfigInteger* widget)
: QLabel(text), m_widget(QPointer<ConfigInteger>(widget))
{
connect(&Settings::Instance(), &Settings::ConfigChanged, this, [this]() {
// Label shares font changes with ConfigInteger to mark game ini settings.
if (m_widget)
setFont(m_widget->font());
});
}

View File

@ -3,6 +3,8 @@
#pragma once
#include <QLabel>
#include "DolphinQt/Config/ConfigControls/ConfigControl.h"
#include "DolphinQt/Config/ToolTipControls/ToolTipSpinBox.h"
@ -28,3 +30,14 @@ protected:
private:
const Config::Info<int>& m_setting;
};
class ConfigIntegerLabel final : public QLabel
{
Q_OBJECT
public:
ConfigIntegerLabel(const QString& text, ConfigInteger* widget);
private:
QPointer<ConfigInteger> m_widget;
};

View File

@ -1,7 +1,10 @@
// Copyright 2017 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <QFont>
#include "DolphinQt/Config/ConfigControls/ConfigSlider.h"
#include "DolphinQt/Settings.h"
ConfigSlider::ConfigSlider(int minimum, int maximum, const Config::Info<int>& setting, int tick)
: ConfigSlider(minimum, maximum, setting, nullptr, tick)
@ -30,3 +33,13 @@ void ConfigSlider::OnConfigChanged()
{
setValue(ReadValue(m_setting));
}
ConfigSliderLabel::ConfigSliderLabel(const QString& text, ConfigSlider* slider)
: QLabel(text), m_slider(QPointer<ConfigSlider>(slider))
{
connect(&Settings::Instance(), &Settings::ConfigChanged, this, [this]() {
// Label shares font changes with slider to mark game ini settings.
if (m_slider)
setFont(m_slider->font());
});
}

View File

@ -3,6 +3,8 @@
#pragma once
#include <QLabel>
#include "DolphinQt/Config/ConfigControls/ConfigControl.h"
#include "DolphinQt/Config/ToolTipControls/ToolTipSlider.h"
@ -28,3 +30,14 @@ protected:
private:
const Config::Info<int>& m_setting;
};
class ConfigSliderLabel final : public QLabel
{
Q_OBJECT
public:
ConfigSliderLabel(const QString& text, ConfigSlider* slider);
private:
QPointer<ConfigSlider> m_slider;
};

View File

@ -147,9 +147,11 @@ void GameConfigWidget::CreateWidgets()
m_use_monoscopic_shadows->setToolTip(
tr("Use a single depth buffer for both eyes. Needed for a few games."));
stereoscopy_layout->addWidget(new QLabel(tr("Depth Percentage:")), 0, 0);
stereoscopy_layout->addWidget(new ConfigSliderLabel(tr("Depth Percentage:"), m_depth_slider), 0,
0);
stereoscopy_layout->addWidget(m_depth_slider, 0, 1);
stereoscopy_layout->addWidget(new QLabel(tr("Convergence:")), 1, 0);
stereoscopy_layout->addWidget(new ConfigIntegerLabel(tr("Convergence:"), m_convergence_spin), 1,
0);
stereoscopy_layout->addWidget(m_convergence_spin, 1, 1);
stereoscopy_layout->addWidget(m_use_monoscopic_shadows, 2, 0);

View File

@ -235,9 +235,9 @@ void EnhancementsWidget::CreateWidgets()
stereoscopy_layout->addWidget(new QLabel(tr("Stereoscopic 3D Mode:")), 0, 0);
stereoscopy_layout->addWidget(m_3d_mode, 0, 1);
stereoscopy_layout->addWidget(new QLabel(tr("Depth:")), 1, 0);
stereoscopy_layout->addWidget(new ConfigSliderLabel(tr("Depth:"), m_3d_depth), 1, 0);
stereoscopy_layout->addWidget(m_3d_depth, 1, 1);
stereoscopy_layout->addWidget(new QLabel(tr("Convergence:")), 2, 0);
stereoscopy_layout->addWidget(new ConfigSliderLabel(tr("Convergence:"), m_3d_convergence), 2, 0);
stereoscopy_layout->addWidget(m_3d_convergence, 2, 1);
stereoscopy_layout->addWidget(m_3d_swap_eyes, 3, 0);
stereoscopy_layout->addWidget(m_3d_per_eye_resolution, 4, 0);