diff options
| author | 2018-09-12 18:24:11 -0400 | |
|---|---|---|
| committer | 2018-09-12 18:24:11 -0400 | |
| commit | 938aa5779c924bc84dd7651587382e47a7f03352 (patch) | |
| tree | 49944155487854d182598023cc3e36e3574bb9f7 /src | |
| parent | Merge pull request #1163 from FearlessTobi/add-audio-stretching (diff) | |
| parent | yuzu/configure_gamelist: Make combo box strings translatable (diff) | |
| download | yuzu-938aa5779c924bc84dd7651587382e47a7f03352.tar.gz yuzu-938aa5779c924bc84dd7651587382e47a7f03352.tar.xz yuzu-938aa5779c924bc84dd7651587382e47a7f03352.zip | |
Merge pull request #1302 from lioncash/config
yuzu/configure_gamelist: Mark combo-box strings as translatable
Diffstat (limited to '')
| -rw-r--r-- | src/yuzu/configuration/configure_gamelist.cpp | 103 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_gamelist.h | 7 |
2 files changed, 74 insertions, 36 deletions
diff --git a/src/yuzu/configuration/configure_gamelist.cpp b/src/yuzu/configuration/configure_gamelist.cpp index 1ae3423cf..0be030434 100644 --- a/src/yuzu/configuration/configure_gamelist.cpp +++ b/src/yuzu/configuration/configure_gamelist.cpp | |||
| @@ -2,47 +2,51 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include "core/core.h" | 5 | #include <array> |
| 6 | #include <utility> | ||
| 7 | |||
| 8 | #include "common/common_types.h" | ||
| 6 | #include "core/settings.h" | 9 | #include "core/settings.h" |
| 7 | #include "ui_configure_gamelist.h" | 10 | #include "ui_configure_gamelist.h" |
| 8 | #include "ui_settings.h" | ||
| 9 | #include "yuzu/configuration/configure_gamelist.h" | 11 | #include "yuzu/configuration/configure_gamelist.h" |
| 12 | #include "yuzu/ui_settings.h" | ||
| 13 | |||
| 14 | namespace { | ||
| 15 | constexpr 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 | |||
| 23 | constexpr 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 | ||
| 10 | 30 | ||
| 11 | ConfigureGameList::ConfigureGameList(QWidget* parent) | 31 | ConfigureGameList::ConfigureGameList(QWidget* parent) |
| 12 | : QWidget(parent), ui(new Ui::ConfigureGameList) { | 32 | : QWidget(parent), ui(new Ui::ConfigureGameList) { |
| 13 | ui->setupUi(this); | 33 | ui->setupUi(this); |
| 14 | 34 | ||
| 15 | static const std::vector<std::pair<u32, std::string>> default_icon_sizes{ | 35 | InitializeIconSizeComboBox(); |
| 16 | std::make_pair(0, "None"), std::make_pair(32, "Small"), | 36 | InitializeRowComboBoxes(); |
| 17 | std::make_pair(64, "Standard"), std::make_pair(128, "Large"), | ||
| 18 | std::make_pair(256, "Full Size"), | ||
| 19 | }; | ||
| 20 | |||
| 21 | for (const auto& size : default_icon_sizes) { | ||
| 22 | ui->icon_size_combobox->addItem(QString::fromStdString(size.second + " (" + | ||
| 23 | std::to_string(size.first) + "x" + | ||
| 24 | std::to_string(size.first) + ")"), | ||
| 25 | size.first); | ||
| 26 | } | ||
| 27 | |||
| 28 | static const std::vector<std::string> row_text_names{ | ||
| 29 | "Filename", | ||
| 30 | "Filetype", | ||
| 31 | "Title ID", | ||
| 32 | "Title Name", | ||
| 33 | }; | ||
| 34 | |||
| 35 | for (size_t i = 0; i < row_text_names.size(); ++i) { | ||
| 36 | ui->row_1_text_combobox->addItem(QString::fromStdString(row_text_names[i]), | ||
| 37 | QVariant::fromValue(i)); | ||
| 38 | ui->row_2_text_combobox->addItem(QString::fromStdString(row_text_names[i]), | ||
| 39 | QVariant::fromValue(i)); | ||
| 40 | } | ||
| 41 | 37 | ||
| 42 | this->setConfiguration(); | 38 | this->setConfiguration(); |
| 43 | } | 39 | } |
| 44 | 40 | ||
| 45 | ConfigureGameList::~ConfigureGameList() {} | 41 | ConfigureGameList::~ConfigureGameList() = default; |
| 42 | |||
| 43 | void ConfigureGameList::applyConfiguration() { | ||
| 44 | UISettings::values.show_unknown = ui->show_unknown->isChecked(); | ||
| 45 | UISettings::values.icon_size = ui->icon_size_combobox->currentData().toUInt(); | ||
| 46 | UISettings::values.row_1_text_id = ui->row_1_text_combobox->currentData().toUInt(); | ||
| 47 | UISettings::values.row_2_text_id = ui->row_2_text_combobox->currentData().toUInt(); | ||
| 48 | Settings::Apply(); | ||
| 49 | } | ||
| 46 | 50 | ||
| 47 | void ConfigureGameList::setConfiguration() { | 51 | void ConfigureGameList::setConfiguration() { |
| 48 | ui->show_unknown->setChecked(UISettings::values.show_unknown); | 52 | ui->show_unknown->setChecked(UISettings::values.show_unknown); |
| @@ -54,10 +58,39 @@ void ConfigureGameList::setConfiguration() { | |||
| 54 | 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)); |
| 55 | } | 59 | } |
| 56 | 60 | ||
| 57 | void ConfigureGameList::applyConfiguration() { | 61 | void ConfigureGameList::changeEvent(QEvent* event) { |
| 58 | UISettings::values.show_unknown = ui->show_unknown->isChecked(); | 62 | if (event->type() == QEvent::LanguageChange) { |
| 59 | UISettings::values.icon_size = ui->icon_size_combobox->currentData().toUInt(); | 63 | RetranslateUI(); |
| 60 | UISettings::values.row_1_text_id = ui->row_1_text_combobox->currentData().toUInt(); | 64 | return; |
| 61 | UISettings::values.row_2_text_id = ui->row_2_text_combobox->currentData().toUInt(); | 65 | } |
| 62 | Settings::Apply(); | 66 | |
| 67 | QWidget::changeEvent(event); | ||
| 68 | } | ||
| 69 | |||
| 70 | void 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 | |||
| 85 | void ConfigureGameList::InitializeIconSizeComboBox() { | ||
| 86 | for (const auto& size : default_icon_sizes) { | ||
| 87 | ui->icon_size_combobox->addItem(size.second, size.first); | ||
| 88 | } | ||
| 89 | } | ||
| 90 | |||
| 91 | void ConfigureGameList::InitializeRowComboBoxes() { | ||
| 92 | for (size_t i = 0; i < row_text_names.size(); ++i) { | ||
| 93 | ui->row_1_text_combobox->addItem(row_text_names[i], QVariant::fromValue(i)); | ||
| 94 | ui->row_2_text_combobox->addItem(row_text_names[i], QVariant::fromValue(i)); | ||
| 95 | } | ||
| 63 | } | 96 | } |
diff --git a/src/yuzu/configuration/configure_gamelist.h b/src/yuzu/configuration/configure_gamelist.h index 94fba6373..ff7406c60 100644 --- a/src/yuzu/configuration/configure_gamelist.h +++ b/src/yuzu/configuration/configure_gamelist.h | |||
| @@ -23,6 +23,11 @@ public: | |||
| 23 | private: | 23 | private: |
| 24 | void setConfiguration(); | 24 | void setConfiguration(); |
| 25 | 25 | ||
| 26 | private: | 26 | void changeEvent(QEvent*) override; |
| 27 | void RetranslateUI(); | ||
| 28 | |||
| 29 | void InitializeIconSizeComboBox(); | ||
| 30 | void InitializeRowComboBoxes(); | ||
| 31 | |||
| 27 | std::unique_ptr<Ui::ConfigureGameList> ui; | 32 | std::unique_ptr<Ui::ConfigureGameList> ui; |
| 28 | }; | 33 | }; |