diff options
author | bunnei <bunneidev@gmail.com> | 2018-09-13 00:24:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-13 00:24:11 +0200 |
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 yuzu-938aa5779c924bc84dd7651587382e47a7f03352.tar.gz yuzu-938aa5779c924bc84dd7651587382e47a7f03352.tar.bz2 yuzu-938aa5779c924bc84dd7651587382e47a7f03352.tar.lz yuzu-938aa5779c924bc84dd7651587382e47a7f03352.tar.xz yuzu-938aa5779c924bc84dd7651587382e47a7f03352.tar.zst yuzu-938aa5779c924bc84dd7651587382e47a7f03352.zip |
Diffstat (limited to 'src')
-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 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include "core/core.h" +#include <array> +#include <utility> + +#include "common/common_types.h" #include "core/settings.h" #include "ui_configure_gamelist.h" -#include "ui_settings.h" #include "yuzu/configuration/configure_gamelist.h" +#include "yuzu/ui_settings.h" + +namespace { +constexpr std::array<std::pair<u32, const char*>, 5> default_icon_sizes{{ + std::make_pair(0, QT_TR_NOOP("None")), + std::make_pair(32, QT_TR_NOOP("Small (32x32)")), + std::make_pair(64, QT_TR_NOOP("Standard (64x64)")), + std::make_pair(128, QT_TR_NOOP("Large (128x128)")), + std::make_pair(256, QT_TR_NOOP("Full Size (256x256)")), +}}; + +constexpr std::array<const char*, 4> row_text_names{{ + QT_TR_NOOP("Filename"), + QT_TR_NOOP("Filetype"), + QT_TR_NOOP("Title ID"), + QT_TR_NOOP("Title Name"), +}}; +} // Anonymous namespace ConfigureGameList::ConfigureGameList(QWidget* parent) : QWidget(parent), ui(new Ui::ConfigureGameList) { ui->setupUi(this); - static const std::vector<std::pair<u32, std::string>> default_icon_sizes{ - std::make_pair(0, "None"), std::make_pair(32, "Small"), - std::make_pair(64, "Standard"), std::make_pair(128, "Large"), - std::make_pair(256, "Full Size"), - }; - - for (const auto& size : default_icon_sizes) { - ui->icon_size_combobox->addItem(QString::fromStdString(size.second + " (" + - std::to_string(size.first) + "x" + - std::to_string(size.first) + ")"), - size.first); - } - - static const std::vector<std::string> row_text_names{ - "Filename", - "Filetype", - "Title ID", - "Title Name", - }; - - for (size_t i = 0; i < row_text_names.size(); ++i) { - ui->row_1_text_combobox->addItem(QString::fromStdString(row_text_names[i]), - QVariant::fromValue(i)); - ui->row_2_text_combobox->addItem(QString::fromStdString(row_text_names[i]), - QVariant::fromValue(i)); - } + InitializeIconSizeComboBox(); + InitializeRowComboBoxes(); this->setConfiguration(); } -ConfigureGameList::~ConfigureGameList() {} +ConfigureGameList::~ConfigureGameList() = default; + +void ConfigureGameList::applyConfiguration() { + UISettings::values.show_unknown = ui->show_unknown->isChecked(); + UISettings::values.icon_size = ui->icon_size_combobox->currentData().toUInt(); + UISettings::values.row_1_text_id = ui->row_1_text_combobox->currentData().toUInt(); + UISettings::values.row_2_text_id = ui->row_2_text_combobox->currentData().toUInt(); + Settings::Apply(); +} void ConfigureGameList::setConfiguration() { ui->show_unknown->setChecked(UISettings::values.show_unknown); @@ -54,10 +58,39 @@ void ConfigureGameList::setConfiguration() { ui->row_2_text_combobox->findData(UISettings::values.row_2_text_id)); } -void ConfigureGameList::applyConfiguration() { - UISettings::values.show_unknown = ui->show_unknown->isChecked(); - UISettings::values.icon_size = ui->icon_size_combobox->currentData().toUInt(); - UISettings::values.row_1_text_id = ui->row_1_text_combobox->currentData().toUInt(); - UISettings::values.row_2_text_id = ui->row_2_text_combobox->currentData().toUInt(); - Settings::Apply(); +void ConfigureGameList::changeEvent(QEvent* event) { + if (event->type() == QEvent::LanguageChange) { + RetranslateUI(); + return; + } + + QWidget::changeEvent(event); +} + +void ConfigureGameList::RetranslateUI() { + ui->retranslateUi(this); + + for (int i = 0; i < ui->icon_size_combobox->count(); i++) { + ui->icon_size_combobox->setItemText(i, tr(default_icon_sizes[i].second)); + } + + for (int i = 0; i < ui->row_1_text_combobox->count(); i++) { + const QString name = tr(row_text_names[i]); + + ui->row_1_text_combobox->setItemText(i, name); + ui->row_2_text_combobox->setItemText(i, name); + } +} + +void ConfigureGameList::InitializeIconSizeComboBox() { + for (const auto& size : default_icon_sizes) { + ui->icon_size_combobox->addItem(size.second, size.first); + } +} + +void ConfigureGameList::InitializeRowComboBoxes() { + for (size_t i = 0; i < row_text_names.size(); ++i) { + ui->row_1_text_combobox->addItem(row_text_names[i], QVariant::fromValue(i)); + ui->row_2_text_combobox->addItem(row_text_names[i], QVariant::fromValue(i)); + } } 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: private: void setConfiguration(); -private: + void changeEvent(QEvent*) override; + void RetranslateUI(); + + void InitializeIconSizeComboBox(); + void InitializeRowComboBoxes(); + std::unique_ptr<Ui::ConfigureGameList> ui; }; |