summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Lioncash2018-09-12 01:11:25 -0400
committerGravatar Lioncash2018-09-12 02:34:53 -0400
commite89c22c1471d02e5e9c3fe3f5fd4e6cb7800f6cc (patch)
tree4910043f0cd8f9dc01bcde8615025b7e46d625b4 /src
parentyuzu/configure_gamelist: Use std::array instead of std::vector for translatab... (diff)
downloadyuzu-e89c22c1471d02e5e9c3fe3f5fd4e6cb7800f6cc.tar.gz
yuzu-e89c22c1471d02e5e9c3fe3f5fd4e6cb7800f6cc.tar.xz
yuzu-e89c22c1471d02e5e9c3fe3f5fd4e6cb7800f6cc.zip
yuzu/configure_gamelist: Make combo box strings translatable
Given these are shown to the user, they should be translatable. While we're at it, also set up the dialog to automatically retranslate the dialog along with the combo boxes if it receives a LanguageChange event.
Diffstat (limited to '')
-rw-r--r--src/yuzu/configuration/configure_gamelist.cpp65
-rw-r--r--src/yuzu/configuration/configure_gamelist.h3
2 files changed, 47 insertions, 21 deletions
diff --git a/src/yuzu/configuration/configure_gamelist.cpp b/src/yuzu/configuration/configure_gamelist.cpp
index 20090ed29..0be030434 100644
--- a/src/yuzu/configuration/configure_gamelist.cpp
+++ b/src/yuzu/configuration/configure_gamelist.cpp
@@ -11,6 +11,23 @@
11#include "yuzu/configuration/configure_gamelist.h" 11#include "yuzu/configuration/configure_gamelist.h"
12#include "yuzu/ui_settings.h" 12#include "yuzu/ui_settings.h"
13 13
14namespace {
15constexpr std::array<std::pair<u32, const char*>, 5> default_icon_sizes{{
16 std::make_pair(0, QT_TR_NOOP("None")),
17 std::make_pair(32, QT_TR_NOOP("Small (32x32)")),
18 std::make_pair(64, QT_TR_NOOP("Standard (64x64)")),
19 std::make_pair(128, QT_TR_NOOP("Large (128x128)")),
20 std::make_pair(256, QT_TR_NOOP("Full Size (256x256)")),
21}};
22
23constexpr std::array<const char*, 4> row_text_names{{
24 QT_TR_NOOP("Filename"),
25 QT_TR_NOOP("Filetype"),
26 QT_TR_NOOP("Title ID"),
27 QT_TR_NOOP("Title Name"),
28}};
29} // Anonymous namespace
30
14ConfigureGameList::ConfigureGameList(QWidget* parent) 31ConfigureGameList::ConfigureGameList(QWidget* parent)
15 : QWidget(parent), ui(new Ui::ConfigureGameList) { 32 : QWidget(parent), ui(new Ui::ConfigureGameList) {
16 ui->setupUi(this); 33 ui->setupUi(this);
@@ -41,33 +58,39 @@ void ConfigureGameList::setConfiguration() {
41 ui->row_2_text_combobox->findData(UISettings::values.row_2_text_id)); 58 ui->row_2_text_combobox->findData(UISettings::values.row_2_text_id));
42} 59}
43 60
44void ConfigureGameList::InitializeIconSizeComboBox() { 61void ConfigureGameList::changeEvent(QEvent* event) {
45 static const std::array<std::pair<u32, std::string>, 5> default_icon_sizes{{ 62 if (event->type() == QEvent::LanguageChange) {
46 std::make_pair(0, "None"), std::make_pair(32, "Small"), 63 RetranslateUI();
47 std::make_pair(64, "Standard"), std::make_pair(128, "Large"), 64 return;
48 std::make_pair(256, "Full Size"), 65 }
49 }};
50 66
67 QWidget::changeEvent(event);
68}
69
70void ConfigureGameList::RetranslateUI() {
71 ui->retranslateUi(this);
72
73 for (int i = 0; i < ui->icon_size_combobox->count(); i++) {
74 ui->icon_size_combobox->setItemText(i, tr(default_icon_sizes[i].second));
75 }
76
77 for (int i = 0; i < ui->row_1_text_combobox->count(); i++) {
78 const QString name = tr(row_text_names[i]);
79
80 ui->row_1_text_combobox->setItemText(i, name);
81 ui->row_2_text_combobox->setItemText(i, name);
82 }
83}
84
85void ConfigureGameList::InitializeIconSizeComboBox() {
51 for (const auto& size : default_icon_sizes) { 86 for (const auto& size : default_icon_sizes) {
52 ui->icon_size_combobox->addItem(QString::fromStdString(size.second + " (" + 87 ui->icon_size_combobox->addItem(size.second, size.first);
53 std::to_string(size.first) + "x" +
54 std::to_string(size.first) + ")"),
55 size.first);
56 } 88 }
57} 89}
58 90
59void ConfigureGameList::InitializeRowComboBoxes() { 91void ConfigureGameList::InitializeRowComboBoxes() {
60 static const std::array<std::string, 4> row_text_names{{
61 "Filename",
62 "Filetype",
63 "Title ID",
64 "Title Name",
65 }};
66
67 for (size_t i = 0; i < row_text_names.size(); ++i) { 92 for (size_t i = 0; i < row_text_names.size(); ++i) {
68 ui->row_1_text_combobox->addItem(QString::fromStdString(row_text_names[i]), 93 ui->row_1_text_combobox->addItem(row_text_names[i], QVariant::fromValue(i));
69 QVariant::fromValue(i)); 94 ui->row_2_text_combobox->addItem(row_text_names[i], QVariant::fromValue(i));
70 ui->row_2_text_combobox->addItem(QString::fromStdString(row_text_names[i]),
71 QVariant::fromValue(i));
72 } 95 }
73} 96}
diff --git a/src/yuzu/configuration/configure_gamelist.h b/src/yuzu/configuration/configure_gamelist.h
index 71fd67e99..ff7406c60 100644
--- a/src/yuzu/configuration/configure_gamelist.h
+++ b/src/yuzu/configuration/configure_gamelist.h
@@ -23,6 +23,9 @@ public:
23private: 23private:
24 void setConfiguration(); 24 void setConfiguration();
25 25
26 void changeEvent(QEvent*) override;
27 void RetranslateUI();
28
26 void InitializeIconSizeComboBox(); 29 void InitializeIconSizeComboBox();
27 void InitializeRowComboBoxes(); 30 void InitializeRowComboBoxes();
28 31