From 0782d3971bcc92f4c4e346f1cdf72ca13d64c2f7 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 27 Nov 2018 05:14:59 -0500 Subject: yuzu/configure_input: Make CallConfigureDialog a non-member template function This doesn't depend on any part of the private interface, so it can be made a non-member internal function. --- src/yuzu/configuration/configure_input.cpp | 34 ++++++++++++---------- src/yuzu/configuration/configure_input.h | 3 -- .../configuration/configure_mouse_advanced.cpp | 4 +-- 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/src/yuzu/configuration/configure_input.cpp b/src/yuzu/configuration/configure_input.cpp index e58c62c9a..ec46dc4e3 100644 --- a/src/yuzu/configuration/configure_input.cpp +++ b/src/yuzu/configuration/configure_input.cpp @@ -20,6 +20,19 @@ #include "yuzu/configuration/configure_input_player.h" #include "yuzu/configuration/configure_mouse_advanced.h" +namespace { +template +void CallConfigureDialog(ConfigureInput& parent, Args&&... args) { + parent.applyConfiguration(); + Dialog dialog(&parent, std::forward(args)...); + + const auto res = dialog.exec(); + if (res == QDialog::Accepted) { + dialog.applyConfiguration(); + } +} +} // Anonymous namespace + ConfigureInput::ConfigureInput(QWidget* parent) : QWidget(parent), ui(std::make_unique()) { ui->setupUi(this); @@ -59,31 +72,20 @@ ConfigureInput::ConfigureInput(QWidget* parent) for (std::size_t i = 0; i < players_configure.size(); ++i) { connect(players_configure[i], &QPushButton::pressed, this, - [this, i]() { CallConfigureDialog(i, false); }); + [this, i] { CallConfigureDialog(*this, i, false); }); } connect(ui->handheld_configure, &QPushButton::pressed, this, - [this]() { CallConfigureDialog(8, false); }); + [this] { CallConfigureDialog(*this, 8, false); }); connect(ui->debug_configure, &QPushButton::pressed, this, - [this]() { CallConfigureDialog(9, true); }); + [this] { CallConfigureDialog(*this, 9, true); }); connect(ui->mouse_advanced, &QPushButton::pressed, this, - [this]() { CallConfigureDialog(); }); + [this] { CallConfigureDialog(*this); }); connect(ui->touchscreen_advanced, &QPushButton::pressed, this, - [this]() { CallConfigureDialog(); }); -} - -template -void ConfigureInput::CallConfigureDialog(Args&&... args) { - this->applyConfiguration(); - Dialog dialog(this, std::forward(args)...); - - const auto res = dialog.exec(); - if (res == QDialog::Accepted) { - dialog.applyConfiguration(); - } + [this] { CallConfigureDialog(*this); }); } void ConfigureInput::OnDockedModeChanged(bool last_state, bool new_state) { diff --git a/src/yuzu/configuration/configure_input.h b/src/yuzu/configuration/configure_input.h index 0de442bf0..e8723dfcb 100644 --- a/src/yuzu/configuration/configure_input.h +++ b/src/yuzu/configuration/configure_input.h @@ -32,9 +32,6 @@ public: private: void updateUIEnabled(); - template - void CallConfigureDialog(Args&&... args); - void OnDockedModeChanged(bool last_state, bool new_state); /// Load configuration settings. diff --git a/src/yuzu/configuration/configure_mouse_advanced.cpp b/src/yuzu/configuration/configure_mouse_advanced.cpp index dab58fbaa..ef857035e 100644 --- a/src/yuzu/configuration/configure_mouse_advanced.cpp +++ b/src/yuzu/configuration/configure_mouse_advanced.cpp @@ -4,11 +4,11 @@ #include #include -#include + #include #include -#include #include + #include "common/assert.h" #include "common/param_package.h" #include "input_common/main.h" -- cgit v1.2.3