30 lines
932 B
C++
Raw Normal View History

2017-05-20 17:53:17 +02:00
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
2018-07-07 00:40:15 +02:00
#include "DolphinQt/Config/Mapping/MappingBool.h"
2017-05-20 17:53:17 +02:00
2018-07-07 00:40:15 +02:00
#include "DolphinQt/Config/Mapping/MappingWidget.h"
#include "InputCommon/ControllerEmu/ControllerEmu.h"
2017-05-20 17:53:17 +02:00
#include "InputCommon/ControllerEmu/Setting/BooleanSetting.h"
#include "InputCommon/ControllerInterface/ControllerInterface.h"
2017-05-20 17:53:17 +02:00
2019-03-14 20:27:49 -05:00
MappingBool::MappingBool(MappingWidget* parent, ControllerEmu::BooleanSetting* setting)
: QCheckBox(tr(setting->m_ui_name.c_str())), m_setting(*setting)
2017-05-20 17:53:17 +02:00
{
2019-03-14 20:27:49 -05:00
connect(this, &QCheckBox::stateChanged, this, [this, parent](int value) {
m_setting.SetValue(value);
parent->SaveSettings();
2017-05-20 17:53:17 +02:00
});
2019-03-14 20:27:49 -05:00
connect(parent, &MappingWidget::ConfigChanged, this, &MappingBool::ConfigChanged);
2017-05-20 17:53:17 +02:00
}
2019-03-14 20:27:49 -05:00
void MappingBool::ConfigChanged()
2017-05-20 17:53:17 +02:00
{
2019-03-14 20:27:49 -05:00
const bool old_state = blockSignals(true);
setChecked(m_setting.GetValue());
blockSignals(old_state);
2017-05-20 17:53:17 +02:00
}