summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Lioncash2018-12-26 17:30:19 -0500
committerGravatar Lioncash2018-12-26 17:36:36 -0500
commitfaa9110541fb38a3edb67eed418982785923044f (patch)
tree7893dd9688d1712343fe479f2d00bbf0fc999cdd /src
parentFixed shader linking error due to TLDS (#1934) (diff)
downloadyuzu-faa9110541fb38a3edb67eed418982785923044f.tar.gz
yuzu-faa9110541fb38a3edb67eed418982785923044f.tar.xz
yuzu-faa9110541fb38a3edb67eed418982785923044f.zip
configure_input_simple: Make input profile array constexpr
Calling tr() from a file-scope array isn't advisable, since it can be executed before the Qt libraries are even fully initialized, which can lead to crashes. Instead, the translatable strings should be annotated, and the tr() function should be called at the string's usage site.
Diffstat (limited to 'src')
-rw-r--r--src/yuzu/configuration/configure_input_simple.cpp19
1 files changed, 7 insertions, 12 deletions
diff --git a/src/yuzu/configuration/configure_input_simple.cpp b/src/yuzu/configuration/configure_input_simple.cpp
index b4f3724bd..07d71e9d1 100644
--- a/src/yuzu/configuration/configure_input_simple.cpp
+++ b/src/yuzu/configuration/configure_input_simple.cpp
@@ -3,12 +3,8 @@
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <array> 5#include <array>
6#include <cstring>
7#include <functional>
8#include <tuple> 6#include <tuple>
9 7
10#include <QDialog>
11
12#include "ui_configure_input_simple.h" 8#include "ui_configure_input_simple.h"
13#include "yuzu/configuration/configure_input.h" 9#include "yuzu/configuration/configure_input.h"
14#include "yuzu/configuration/configure_input_player.h" 10#include "yuzu/configuration/configure_input_player.h"
@@ -73,20 +69,18 @@ void DualJoyconsDockedOnProfileSelect() {
73 69
74// Name, OnProfileSelect (called when selected in drop down), OnConfigure (called when configure 70// Name, OnProfileSelect (called when selected in drop down), OnConfigure (called when configure
75// is clicked) 71// is clicked)
76using InputProfile = 72using InputProfile = std::tuple<const char*, void (*)(), void (*)(ConfigureInputSimple*)>;
77 std::tuple<QString, std::function<void()>, std::function<void(ConfigureInputSimple*)>>;
78 73
79const std::array<InputProfile, 3> INPUT_PROFILES{{ 74constexpr std::array<InputProfile, 3> INPUT_PROFILES{{
80 {ConfigureInputSimple::tr("Single Player - Handheld - Undocked"), HandheldOnProfileSelect, 75 {QT_TR_NOOP("Single Player - Handheld - Undocked"), HandheldOnProfileSelect,
81 [](ConfigureInputSimple* caller) { 76 [](ConfigureInputSimple* caller) {
82 CallConfigureDialog<ConfigureInputPlayer>(caller, HANDHELD_INDEX, false); 77 CallConfigureDialog<ConfigureInputPlayer>(caller, HANDHELD_INDEX, false);
83 }}, 78 }},
84 {ConfigureInputSimple::tr("Single Player - Dual Joycons - Docked"), 79 {QT_TR_NOOP("Single Player - Dual Joycons - Docked"), DualJoyconsDockedOnProfileSelect,
85 DualJoyconsDockedOnProfileSelect,
86 [](ConfigureInputSimple* caller) { 80 [](ConfigureInputSimple* caller) {
87 CallConfigureDialog<ConfigureInputPlayer>(caller, 1, false); 81 CallConfigureDialog<ConfigureInputPlayer>(caller, 1, false);
88 }}, 82 }},
89 {ConfigureInputSimple::tr("Custom"), [] {}, CallConfigureDialog<ConfigureInput>}, 83 {QT_TR_NOOP("Custom"), [] {}, CallConfigureDialog<ConfigureInput>},
90}}; 84}};
91 85
92} // namespace 86} // namespace
@@ -101,7 +95,8 @@ ConfigureInputSimple::ConfigureInputSimple(QWidget* parent)
101 ui->setupUi(this); 95 ui->setupUi(this);
102 96
103 for (const auto& profile : INPUT_PROFILES) { 97 for (const auto& profile : INPUT_PROFILES) {
104 ui->profile_combobox->addItem(std::get<0>(profile), std::get<0>(profile)); 98 const QString label = tr(std::get<0>(profile));
99 ui->profile_combobox->addItem(label, label);
105 } 100 }
106 101
107 connect(ui->profile_combobox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, 102 connect(ui->profile_combobox, QOverload<int>::of(&QComboBox::currentIndexChanged), this,