From d67a2304b0f542e21f680265da80efef3e0a83d9 Mon Sep 17 00:00:00 2001 From: rlnilsen <47765059+rlnilsen@users.noreply.github.com> Date: Wed, 30 Oct 2019 02:05:42 +0100 Subject: Input: Add optional "enable" setting to the ControlGroup class. The setting is exposed as a check box in the QGroupBox instance that visualises the ControlGroup instance. The setting is saved under "[control group name]/Enabled", but only when it is "false". The default value is "true". --- .../DolphinQt/Config/Mapping/MappingWidget.cpp | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'Source/Core/DolphinQt/Config/Mapping/MappingWidget.cpp') diff --git a/Source/Core/DolphinQt/Config/Mapping/MappingWidget.cpp b/Source/Core/DolphinQt/Config/Mapping/MappingWidget.cpp index b9149027ea..0268fe908e 100644 --- a/Source/Core/DolphinQt/Config/Mapping/MappingWidget.cpp +++ b/Source/Core/DolphinQt/Config/Mapping/MappingWidget.cpp @@ -4,8 +4,10 @@ #include "DolphinQt/Config/Mapping/MappingWidget.h" +#include #include #include +#include #include #include @@ -138,6 +140,28 @@ QGroupBox* MappingWidget::CreateGroupBox(const QString& name, ControllerEmu::Con form_layout->addRow(tr(setting->GetUIName()), setting_widget); } + if (group->can_be_disabled) + { + QLabel* group_enable_label = new QLabel(tr("Enable")); + QCheckBox* group_enable_checkbox = new QCheckBox(); + group_enable_checkbox->setChecked(group->enabled); + form_layout->insertRow(0, group_enable_label, group_enable_checkbox); + auto enable_group_by_checkbox = [group, form_layout, group_enable_label, + group_enable_checkbox] { + group->enabled = group_enable_checkbox->isChecked(); + for (int i = 0; i < form_layout->count(); ++i) + { + QWidget* widget = form_layout->itemAt(i)->widget(); + if (widget != nullptr && widget != group_enable_label && widget != group_enable_checkbox) + widget->setEnabled(group->enabled); + } + }; + enable_group_by_checkbox(); + connect(group_enable_checkbox, &QCheckBox::toggled, this, enable_group_by_checkbox); + connect(this, &MappingWidget::ConfigChanged, this, + [group_enable_checkbox, group] { group_enable_checkbox->setChecked(group->enabled); }); + } + return group_box; } -- cgit v1.2.3