From f4be7333556e6c6a12f77276dc5bef1895a44bff Mon Sep 17 00:00:00 2001 From: Tobias Date: Mon, 31 Aug 2020 21:13:24 +0200 Subject: [PATCH] citra_qt: Backport review comments from the yuzu translation PR (#5465) --- README.md | 2 +- src/citra_qt/CMakeLists.txt | 2 +- src/citra_qt/configuration/configure_ui.cpp | 37 +++++++++++---------- src/citra_qt/configuration/configure_ui.h | 1 + 4 files changed, 23 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 90c9bf15f..15ffb9aa9 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Most of the development happens on GitHub. It's also where [our central reposito If you want to contribute please take a look at the [Contributor's Guide](https://github.com/citra-emu/citra/wiki/Contributing) and [Developer Information](https://github.com/citra-emu/citra/wiki/Developer-Information). You should also contact any of the developers in the forum in order to know about the current state of the emulator because the [TODO list](https://docs.google.com/document/d/1SWIop0uBI9IW8VGg97TAtoT_CHNoP42FzYmvG1F4QDA) isn't maintained anymore. -If you want to contribute to the user interface translation, please checkout [citra project on transifex](https://www.transifex.com/citra/citra). We centralize the translation work there, and periodically upstream translation. +If you want to contribute to the user interface translation, please check out the [citra project on transifex](https://www.transifex.com/citra/citra). We centralize the translation work there, and periodically upstream translations. ### Building diff --git a/src/citra_qt/CMakeLists.txt b/src/citra_qt/CMakeLists.txt index 9d1fba475..24c2ca601 100644 --- a/src/citra_qt/CMakeLists.txt +++ b/src/citra_qt/CMakeLists.txt @@ -223,8 +223,8 @@ target_sources(citra-qt PRIVATE ${COMPAT_LIST} ${ICONS} - ${THEMES} ${LANGUAGES} + ${THEMES} ) if (APPLE) diff --git a/src/citra_qt/configuration/configure_ui.cpp b/src/citra_qt/configuration/configure_ui.cpp index 88f0d0893..a29185959 100644 --- a/src/citra_qt/configuration/configure_ui.cpp +++ b/src/citra_qt/configuration/configure_ui.cpp @@ -9,23 +9,7 @@ ConfigureUi::ConfigureUi(QWidget* parent) : QWidget(parent), ui(new Ui::ConfigureUi) { ui->setupUi(this); - ui->language_combobox->addItem(tr(""), QString{}); - ui->language_combobox->addItem(tr("English"), QStringLiteral("en")); - QDirIterator it(QStringLiteral(":/languages"), QDirIterator::NoIteratorFlags); - while (it.hasNext()) { - QString locale = it.next(); - locale.truncate(locale.lastIndexOf(QLatin1Char{'.'})); - locale.remove(0, locale.lastIndexOf(QLatin1Char{'/'}) + 1); - QString lang = QLocale::languageToString(QLocale(locale).language()); - ui->language_combobox->addItem(lang, locale); - } - - // Unlike other configuration changes, interface language changes need to be reflected on the - // interface immediately. This is done by passing a signal to the main window, and then - // retranslating when passing back. - connect(ui->language_combobox, - static_cast(&QComboBox::currentIndexChanged), this, - &ConfigureUi::OnLanguageChanged); + InitializeLanguageComboBox(); for (const auto& theme : UISettings::themes) { ui->theme_combobox->addItem(QString::fromUtf8(theme.first), @@ -37,6 +21,25 @@ ConfigureUi::ConfigureUi(QWidget* parent) : QWidget(parent), ui(new Ui::Configur ConfigureUi::~ConfigureUi() = default; +void ConfigureUi::InitializeLanguageComboBox() { + ui->language_combobox->addItem(tr(""), QString{}); + ui->language_combobox->addItem(tr("English"), QStringLiteral("en")); + QDirIterator it(QStringLiteral(":/languages"), QDirIterator::NoIteratorFlags); + while (it.hasNext()) { + QString locale = it.next(); + locale.truncate(locale.lastIndexOf(QLatin1Char{'.'})); + locale.remove(0, locale.lastIndexOf(QLatin1Char{'/'}) + 1); + const QString lang = QLocale::languageToString(QLocale(locale).language()); + ui->language_combobox->addItem(lang, locale); + } + + // Unlike other configuration changes, interface language changes need to be reflected on the + // interface immediately. This is done by passing a signal to the main window, and then + // retranslating when passing back. + connect(ui->language_combobox, qOverload(&QComboBox::currentIndexChanged), this, + &ConfigureUi::OnLanguageChanged); +} + void ConfigureUi::SetConfiguration() { ui->theme_combobox->setCurrentIndex(ui->theme_combobox->findData(UISettings::values.theme)); ui->language_combobox->setCurrentIndex( diff --git a/src/citra_qt/configuration/configure_ui.h b/src/citra_qt/configuration/configure_ui.h index 8b0a11833..288087e54 100644 --- a/src/citra_qt/configuration/configure_ui.h +++ b/src/citra_qt/configuration/configure_ui.h @@ -18,6 +18,7 @@ public: explicit ConfigureUi(QWidget* parent = nullptr); ~ConfigureUi() override; + void InitializeLanguageComboBox(); void ApplyConfiguration(); void RetranslateUI(); void SetConfiguration();