forked from ShuriZma/suyu
1
0
Fork 0

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.
This commit is contained in:
Lioncash 2018-11-27 05:14:59 -05:00
parent 11cf13a6e1
commit 0782d3971b
3 changed files with 20 additions and 21 deletions

View File

@ -20,6 +20,19 @@
#include "yuzu/configuration/configure_input_player.h"
#include "yuzu/configuration/configure_mouse_advanced.h"
namespace {
template <typename Dialog, typename... Args>
void CallConfigureDialog(ConfigureInput& parent, Args&&... args) {
parent.applyConfiguration();
Dialog dialog(&parent, std::forward<Args>(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::ConfigureInput>()) {
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<ConfigureInputPlayer>(i, false); });
[this, i] { CallConfigureDialog<ConfigureInputPlayer>(*this, i, false); });
}
connect(ui->handheld_configure, &QPushButton::pressed, this,
[this]() { CallConfigureDialog<ConfigureInputPlayer>(8, false); });
[this] { CallConfigureDialog<ConfigureInputPlayer>(*this, 8, false); });
connect(ui->debug_configure, &QPushButton::pressed, this,
[this]() { CallConfigureDialog<ConfigureInputPlayer>(9, true); });
[this] { CallConfigureDialog<ConfigureInputPlayer>(*this, 9, true); });
connect(ui->mouse_advanced, &QPushButton::pressed, this,
[this]() { CallConfigureDialog<ConfigureMouseAdvanced>(); });
[this] { CallConfigureDialog<ConfigureMouseAdvanced>(*this); });
connect(ui->touchscreen_advanced, &QPushButton::pressed, this,
[this]() { CallConfigureDialog<ConfigureTouchscreenAdvanced>(); });
}
template <typename Dialog, typename... Args>
void ConfigureInput::CallConfigureDialog(Args&&... args) {
this->applyConfiguration();
Dialog dialog(this, std::forward<Args>(args)...);
const auto res = dialog.exec();
if (res == QDialog::Accepted) {
dialog.applyConfiguration();
}
[this] { CallConfigureDialog<ConfigureTouchscreenAdvanced>(*this); });
}
void ConfigureInput::OnDockedModeChanged(bool last_state, bool new_state) {

View File

@ -32,9 +32,6 @@ public:
private:
void updateUIEnabled();
template <typename Dialog, typename... Args>
void CallConfigureDialog(Args&&... args);
void OnDockedModeChanged(bool last_state, bool new_state);
/// Load configuration settings.

View File

@ -4,11 +4,11 @@
#include <algorithm>
#include <memory>
#include <utility>
#include <QKeyEvent>
#include <QMenu>
#include <QMessageBox>
#include <QTimer>
#include "common/assert.h"
#include "common/param_package.h"
#include "input_common/main.h"