Permalink
Browse files

Qt/Mapping: Add support for exclusive boolean settings

  • Loading branch information...
spycrab committed Jul 2, 2018
1 parent 3e2e813 commit 0f4865393506ffedc8c1fb93b891a9249a6c0b2a
@@ -63,6 +63,7 @@ add_executable(dolphin-emu
Config/Mapping/MappingCommon.cpp
Config/Mapping/MappingIndicator.cpp
Config/Mapping/MappingNumeric.cpp
Config/Mapping/MappingRadio.cpp
Config/Mapping/MappingWidget.cpp
Config/Mapping/MappingWindow.cpp
Config/Mapping/WiimoteEmuExtension.cpp
@@ -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());
}
@@ -0,0 +1,29 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include <QRadioButton>
class MappingWidget;
namespace ControllerEmu
{
class BooleanSetting;
};
class MappingRadio : public QRadioButton
{
public:
MappingRadio(MappingWidget* widget, ControllerEmu::BooleanSetting* setting);
void Clear();
void Update();
private:
void Connect();
MappingWidget* m_parent;
ControllerEmu::BooleanSetting* m_setting;
};
@@ -13,6 +13,7 @@
#include "DolphinQt2/Config/Mapping/MappingButton.h"
#include "DolphinQt2/Config/Mapping/MappingIndicator.h"
#include "DolphinQt2/Config/Mapping/MappingNumeric.h"
#include "DolphinQt2/Config/Mapping/MappingRadio.h"
#include "DolphinQt2/Config/Mapping/MappingWindow.h"
#include "InputCommon/ControlReference/ControlReference.h"
@@ -114,7 +115,22 @@ QGroupBox* MappingWidget::CreateGroupBox(const QString& name, ControllerEmu::Con
for (auto& boolean : group->boolean_settings)
{
if (!boolean->IsExclusive())
continue;
auto* checkbox = new MappingRadio(this, boolean.get());
form_layout->addRow(checkbox);
m_radio.push_back(checkbox);
}
for (auto& boolean : group->boolean_settings)
{
if (boolean->IsExclusive())
continue;
auto* checkbox = new MappingBool(this, boolean.get());
form_layout->addRow(checkbox);
m_bools.push_back(checkbox);
}
@@ -135,6 +151,9 @@ void MappingWidget::OnClearFields()
for (auto* checkbox : m_bools)
checkbox->Clear();
for (auto* radio : m_radio)
radio->Clear();
}
void MappingWidget::Update()
@@ -148,6 +167,9 @@ void MappingWidget::Update()
for (auto* checkbox : m_bools)
checkbox->Update();
for (auto* radio : m_radio)
radio->Update();
SaveSettings();
}
@@ -17,6 +17,7 @@ class MappingBool;
class MappingButton;
class MappingNumeric;
class MappingWindow;
class MappingRadio;
class QGroupBox;
namespace ControllerEmu
@@ -64,6 +65,7 @@ class MappingWidget : public QWidget
MappingWindow* m_parent;
bool m_first = true;
std::vector<MappingBool*> m_bools;
std::vector<MappingRadio*> m_radio;
std::vector<MappingButton*> m_buttons;
std::vector<MappingNumeric*> m_numerics;
};
@@ -296,6 +296,7 @@
<ClCompile Include="Config\Mapping\MappingCommon.cpp" />
<ClCompile Include="Config\Mapping\MappingIndicator.cpp" />
<ClCompile Include="Config\Mapping\MappingNumeric.cpp" />
<ClCompile Include="Config\Mapping\MappingRadio.cpp" />
<ClCompile Include="Config\Mapping\MappingWidget.cpp" />
<ClCompile Include="Config\Mapping\MappingWindow.cpp" />
<ClCompile Include="Config\Mapping\WiimoteEmuExtension.cpp" />
@@ -368,6 +369,7 @@
<!--Put standard C/C++ headers here. Headers that are listed in the QtMoc ItemGroup must NOT be listed here.-->
<ItemGroup>
<ClInclude Include="Config\Mapping\MappingCommon.h" />
<ClInclude Include="Config\Mapping\MappingRadio.h" />
<ClInclude Include="Debugger\RegisterColumn.h" />
<ClInclude Include="QtUtils\ActionHelper.h" />
<ClInclude Include="QtUtils\ImageConverter.h" />
@@ -462,4 +464,4 @@
<Message Text="Copy: @(BinaryFiles) -&gt; $(BinaryOutputDir)" Importance="High" />
<Copy SourceFiles="@(BinaryFiles)" DestinationFolder="$(BinaryOutputDir)" />
</Target>
</Project>
</Project>

0 comments on commit 0f48653

Please sign in to comment.