diff options
| author | Tilka <tilkax@gmail.com> | 2020-02-09 01:37:30 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-02-09 01:37:30 +0000 |
| commit | 2e2540317e8752b8fe2e4d549a0b5c1ab1911041 (patch) | |
| tree | c5997fb92fc14a5dbbc061a5b572da18d0877e86 /Source/Core/DolphinQt/Config/Mapping/MappingWidget.cpp | |
| parent | 7fe11c95782a305e1e03a401e54d819700b39805 (diff) | |
| parent | 0a1634bedf17f7b27a3781d8e5ac6bafb20cd546 (diff) | |
Merge pull request #8417 from jordan-woyak/setting-expressions
InputCommon: Allow controller settings specified with input expresions.
Diffstat (limited to 'Source/Core/DolphinQt/Config/Mapping/MappingWidget.cpp')
| -rw-r--r-- | Source/Core/DolphinQt/Config/Mapping/MappingWidget.cpp | 45 |
1 files changed, 35 insertions, 10 deletions
diff --git a/Source/Core/DolphinQt/Config/Mapping/MappingWidget.cpp b/Source/Core/DolphinQt/Config/Mapping/MappingWidget.cpp index 1e2aabd3ec..eb39bac64f 100644 --- a/Source/Core/DolphinQt/Config/Mapping/MappingWidget.cpp +++ b/Source/Core/DolphinQt/Config/Mapping/MappingWidget.cpp @@ -9,8 +9,8 @@ #include <QGroupBox> #include <QLabel> #include <QPushButton> -#include <QTimer> +#include "DolphinQt/Config/Mapping/IOWindow.h" #include "DolphinQt/Config/Mapping/MappingButton.h" #include "DolphinQt/Config/Mapping/MappingIndicator.h" #include "DolphinQt/Config/Mapping/MappingNumeric.h" @@ -28,14 +28,6 @@ MappingWidget::MappingWidget(MappingWindow* parent) : m_parent(parent) connect(parent, &MappingWindow::Update, this, &MappingWidget::Update); connect(parent, &MappingWindow::Save, this, &MappingWidget::SaveSettings); connect(parent, &MappingWindow::ConfigChanged, this, &MappingWidget::ConfigChanged); - - const auto timer = new QTimer(this); - connect(timer, &QTimer::timeout, this, [this] { - const auto lock = m_parent->GetController()->GetStateLock(); - emit Update(); - }); - - timer->start(1000 / INDICATOR_UPDATE_FREQ); } MappingWindow* MappingWidget::GetParent() const @@ -138,10 +130,21 @@ QGroupBox* MappingWidget::CreateGroupBox(const QString& name, ControllerEmu::Con setting_widget = new MappingBool(this, static_cast<ControllerEmu::NumericSetting<bool>*>(setting.get())); break; + + default: + // FYI: Widgets for additional types can be implemented as needed. + break; } if (setting_widget) - form_layout->addRow(tr(setting->GetUIName()), setting_widget); + { + const auto hbox = new QHBoxLayout; + + hbox->addWidget(setting_widget); + hbox->addWidget(CreateSettingAdvancedMappingButton(*setting)); + + form_layout->addRow(tr(setting->GetUIName()), hbox); + } } if (group->can_be_disabled) @@ -173,3 +176,25 @@ ControllerEmu::EmulatedController* MappingWidget::GetController() const { return m_parent->GetController(); } + +QPushButton* +MappingWidget::CreateSettingAdvancedMappingButton(ControllerEmu::NumericSettingBase& setting) +{ + const auto button = new QPushButton(tr("...")); + button->setFixedWidth(QFontMetrics(font()).boundingRect(button->text()).width() * 2); + + button->connect(button, &QPushButton::clicked, [this, &setting]() { + if (setting.IsSimpleValue()) + setting.SetExpressionFromValue(); + + IOWindow io(this, GetController(), &setting.GetInputReference(), IOWindow::Type::Input); + io.exec(); + + setting.SimplifyIfPossible(); + + ConfigChanged(); + SaveSettings(); + }); + + return button; +} |
