Qt Mapping*: make logic around setting/loading settings more consistent

Changes:
- signal for widget value changed: sets controller setting, saves
  settings
- Update(): only updates widget from existing controller setting
- Clear(): sets controller setting, saves settings, and calls Update()
This commit is contained in:
Michael M
2017-11-03 13:28:45 -07:00
parent bb38b39952
commit 14f22ad829
4 changed files with 12 additions and 15 deletions

View File

@ -10,7 +10,7 @@
MappingBool::MappingBool(MappingWidget* widget, ControllerEmu::BooleanSetting* setting)
: QCheckBox(QString::fromStdString(setting->m_ui_name)), m_parent(widget), m_setting(setting)
{
setChecked(setting->GetValue());
Update();
Connect();
}
@ -18,18 +18,18 @@ void MappingBool::Connect()
{
connect(this, &QCheckBox::stateChanged, this, [this](int value) {
m_setting->SetValue(value);
Update();
m_parent->SaveSettings();
});
}
void MappingBool::Clear()
{
setChecked(false);
m_setting->SetValue(false);
m_parent->SaveSettings();
Update();
}
void MappingBool::Update()
{
setChecked(m_setting->GetValue());
m_parent->SaveSettings();
}