dolphin/Source/Core/DolphinQt/TAS/TASSpinBox.cpp
Stavros Kosmas d09436cd1a DolphinQt: Improve TAS UI Widgets
Made Stick and IR Widgets bigger
Improved Stick and IR layouts to better utilize space
Made Stick and IR Widgets Scale at a fixed ratio when window is resized
Added Scrollbars to Stick and IR Widgets
Reduced Spinbox padding in dark style
2026-03-12 04:59:49 +02:00

61 lines
1.3 KiB
C++

// Copyright 2019 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "DolphinQt/TAS/TASSpinBox.h"
#include "DolphinQt/QtUtils/QueueOnObject.h"
TASSpinBox::TASSpinBox(QWidget* parent) : QSpinBox(parent)
{
connect(this, &TASSpinBox::valueChanged, this, &TASSpinBox::OnUIValueChanged);
}
int TASSpinBox::GetValue() const
{
return m_state.GetValue();
}
void TASSpinBox::OnControllerValueChanged(int new_value)
{
if (m_state.OnControllerValueChanged(new_value))
QueueOnObject(this, &TASSpinBox::ApplyControllerValueChange);
}
void TASSpinBox::OnUIValueChanged(int new_value)
{
m_state.OnUIValueChanged(new_value);
}
void TASSpinBox::ApplyControllerValueChange()
{
setValue(m_state.ApplyControllerValueChange());
}
QValidator::State TASSpinBox::validate(QString& input, int& pos) const
{
auto state = QSpinBox::validate(input, pos);
if (state == QValidator::Invalid)
{
bool ok;
input.toInt(&ok);
if (ok)
return QValidator::Intermediate;
}
return state;
}
void TASSpinBox::fixup(QString& input) const
{
bool ok;
int val = input.toInt(&ok);
if (ok)
{
if (val > maximum())
input = QString::number(maximum());
else if (val < minimum())
input = QString::number(minimum());
return;
}
QSpinBox::fixup(input);
}