Merge pull request #6175 from ligfx/qtinputupdateclear
Qt Mapping*: make logic around setting/loading settings more consistent
This commit is contained in:
commit
41c2618b10
|
@ -10,7 +10,7 @@
|
||||||
MappingBool::MappingBool(MappingWidget* widget, ControllerEmu::BooleanSetting* setting)
|
MappingBool::MappingBool(MappingWidget* widget, ControllerEmu::BooleanSetting* setting)
|
||||||
: QCheckBox(QString::fromStdString(setting->m_ui_name)), m_parent(widget), m_setting(setting)
|
: QCheckBox(QString::fromStdString(setting->m_ui_name)), m_parent(widget), m_setting(setting)
|
||||||
{
|
{
|
||||||
setChecked(setting->GetValue());
|
Update();
|
||||||
Connect();
|
Connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,18 +18,18 @@ void MappingBool::Connect()
|
||||||
{
|
{
|
||||||
connect(this, &QCheckBox::stateChanged, this, [this](int value) {
|
connect(this, &QCheckBox::stateChanged, this, [this](int value) {
|
||||||
m_setting->SetValue(value);
|
m_setting->SetValue(value);
|
||||||
Update();
|
m_parent->SaveSettings();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void MappingBool::Clear()
|
void MappingBool::Clear()
|
||||||
{
|
{
|
||||||
setChecked(false);
|
m_setting->SetValue(false);
|
||||||
|
m_parent->SaveSettings();
|
||||||
Update();
|
Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MappingBool::Update()
|
void MappingBool::Update()
|
||||||
{
|
{
|
||||||
setChecked(m_setting->GetValue());
|
setChecked(m_setting->GetValue());
|
||||||
m_parent->SaveSettings();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,9 +83,8 @@ void MappingButton::OnButtonTimeout()
|
||||||
|
|
||||||
void MappingButton::Clear()
|
void MappingButton::Clear()
|
||||||
{
|
{
|
||||||
m_parent->Update();
|
|
||||||
m_reference->SetExpression("");
|
m_reference->SetExpression("");
|
||||||
Update();
|
m_parent->SaveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MappingButton::Update()
|
void MappingButton::Update()
|
||||||
|
@ -93,7 +92,6 @@ void MappingButton::Update()
|
||||||
const auto lock = ControllerEmu::EmulatedController::GetStateLock();
|
const auto lock = ControllerEmu::EmulatedController::GetStateLock();
|
||||||
m_reference->UpdateReference(g_controller_interface, m_parent->GetParent()->GetDeviceQualifier());
|
m_reference->UpdateReference(g_controller_interface, m_parent->GetParent()->GetDeviceQualifier());
|
||||||
setText(EscapeAmpersand(QString::fromStdString(m_reference->GetExpression())));
|
setText(EscapeAmpersand(QString::fromStdString(m_reference->GetExpression())));
|
||||||
m_parent->SaveSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MappingButton::mouseReleaseEvent(QMouseEvent* event)
|
void MappingButton::mouseReleaseEvent(QMouseEvent* event)
|
||||||
|
|
|
@ -11,7 +11,7 @@ MappingNumeric::MappingNumeric(MappingWidget* widget, ControllerEmu::NumericSett
|
||||||
: m_parent(widget), m_setting(setting), m_range(setting->m_high - setting->m_low)
|
: m_parent(widget), m_setting(setting), m_range(setting->m_high - setting->m_low)
|
||||||
{
|
{
|
||||||
setRange(setting->m_low, setting->m_high);
|
setRange(setting->m_low, setting->m_high);
|
||||||
setValue(setting->m_low + setting->GetValue() * m_range);
|
Update();
|
||||||
Connect();
|
Connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,18 +20,18 @@ void MappingNumeric::Connect()
|
||||||
connect(this, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this,
|
connect(this, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this,
|
||||||
[this](int value) {
|
[this](int value) {
|
||||||
m_setting->SetValue(static_cast<double>(value - m_setting->m_low) / m_range);
|
m_setting->SetValue(static_cast<double>(value - m_setting->m_low) / m_range);
|
||||||
Update();
|
m_parent->SaveSettings();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void MappingNumeric::Clear()
|
void MappingNumeric::Clear()
|
||||||
{
|
{
|
||||||
setValue(m_setting->m_low + (m_setting->m_low + m_setting->m_high) / 2);
|
m_setting->SetValue(m_setting->m_low + (m_setting->m_low + m_setting->m_high) / 2);
|
||||||
|
m_parent->SaveSettings();
|
||||||
Update();
|
Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MappingNumeric::Update()
|
void MappingNumeric::Update()
|
||||||
{
|
{
|
||||||
setValue(m_setting->m_low + m_setting->GetValue() * m_range);
|
setValue(m_setting->m_low + m_setting->GetValue() * m_range);
|
||||||
m_parent->SaveSettings();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,14 +57,15 @@ QGroupBox* MappingWidget::CreateGroupBox(const QString& name, ControllerEmu::Con
|
||||||
|
|
||||||
auto* control_ref = control->control_ref.get();
|
auto* control_ref = control->control_ref.get();
|
||||||
|
|
||||||
connect(button, &MappingButton::AdvancedPressed, [this, control_ref] {
|
connect(button, &MappingButton::AdvancedPressed, [this, button, control_ref] {
|
||||||
if (m_parent->GetDevice() == nullptr)
|
if (m_parent->GetDevice() == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
IOWindow io(this, m_parent->GetController(), control_ref,
|
IOWindow io(this, m_parent->GetController(), control_ref,
|
||||||
control_ref->IsInput() ? IOWindow::Type::Input : IOWindow::Type::Output);
|
control_ref->IsInput() ? IOWindow::Type::Input : IOWindow::Type::Output);
|
||||||
io.exec();
|
io.exec();
|
||||||
Update();
|
SaveSettings();
|
||||||
|
button->Update();
|
||||||
});
|
});
|
||||||
|
|
||||||
m_buttons.push_back(button);
|
m_buttons.push_back(button);
|
||||||
|
@ -111,8 +112,6 @@ void MappingWidget::Update()
|
||||||
|
|
||||||
for (auto* checkbox : m_bools)
|
for (auto* checkbox : m_bools)
|
||||||
checkbox->Update();
|
checkbox->Update();
|
||||||
|
|
||||||
LoadSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ControllerEmu::EmulatedController* MappingWidget::GetController() const
|
ControllerEmu::EmulatedController* MappingWidget::GetController() const
|
||||||
|
|
Loading…
Reference in New Issue