2019-07-17 20:15:25 +02:00
|
|
|
// Copyright 2019 Dolphin Emulator Project
|
2021-07-05 03:22:19 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2019-07-17 20:15:25 +02:00
|
|
|
|
2023-04-28 19:41:09 -07:00
|
|
|
#include "DolphinQt/Config/ConfigControls/ConfigInteger.h"
|
2019-07-17 20:15:25 +02:00
|
|
|
|
2023-04-28 19:41:09 -07:00
|
|
|
ConfigInteger::ConfigInteger(int minimum, int maximum, const Config::Info<int>& setting, int step)
|
2024-09-17 23:29:13 -07:00
|
|
|
: ConfigInteger(minimum, maximum, setting, nullptr, step)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ConfigInteger::ConfigInteger(int minimum, int maximum, const Config::Info<int>& setting,
|
|
|
|
Config::Layer* layer, int step)
|
|
|
|
: ConfigControl(setting.GetLocation(), layer), m_setting(setting)
|
2019-07-17 20:15:25 +02:00
|
|
|
{
|
|
|
|
setMinimum(minimum);
|
|
|
|
setMaximum(maximum);
|
|
|
|
setSingleStep(step);
|
2024-09-17 23:29:13 -07:00
|
|
|
setValue(ReadValue(setting));
|
2019-07-17 20:15:25 +02:00
|
|
|
|
2023-11-04 14:01:39 -07:00
|
|
|
connect(this, &ConfigInteger::valueChanged, this, &ConfigInteger::Update);
|
2019-07-17 20:15:25 +02:00
|
|
|
}
|
|
|
|
|
2023-04-28 19:41:09 -07:00
|
|
|
void ConfigInteger::Update(int value)
|
2019-07-17 20:15:25 +02:00
|
|
|
{
|
2024-09-17 23:29:13 -07:00
|
|
|
SaveValue(m_setting, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigInteger::OnConfigChanged()
|
|
|
|
{
|
|
|
|
setValue(ReadValue(m_setting));
|
2019-07-17 20:15:25 +02:00
|
|
|
}
|
2024-09-29 17:12:22 -07:00
|
|
|
|
|
|
|
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());
|
|
|
|
});
|
|
|
|
}
|