Qt/Mapping: Add support for exclusive boolean settings

This commit is contained in:
spycrab
2018-07-02 15:16:43 +02:00
parent 3e2e813607
commit 0f48653935
6 changed files with 96 additions and 1 deletions

View File

@ -0,0 +1,39 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "DolphinQt2/Config/Mapping/MappingRadio.h"
#include "DolphinQt2/Config/Mapping/MappingWidget.h"
#include "InputCommon/ControllerEmu/ControllerEmu.h"
#include "InputCommon/ControllerEmu/Setting/BooleanSetting.h"
#include "InputCommon/ControllerInterface/ControllerInterface.h"
MappingRadio::MappingRadio(MappingWidget* widget, ControllerEmu::BooleanSetting* setting)
: QRadioButton(tr(setting->m_ui_name.c_str())), m_parent(widget), m_setting(setting)
{
Update();
Connect();
}
void MappingRadio::Connect()
{
connect(this, &QRadioButton::toggled, this, [this](int value) {
m_setting->SetValue(value);
m_parent->SaveSettings();
m_parent->GetController()->UpdateReferences(g_controller_interface);
});
}
void MappingRadio::Clear()
{
m_setting->SetValue(false);
m_parent->SaveSettings();
Update();
}
void MappingRadio::Update()
{
setChecked(m_setting->GetValue());
}