diff options
Diffstat (limited to 'src/yuzu/configuration/configure_ui.cpp')
-rw-r--r-- | src/yuzu/configuration/configure_ui.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/yuzu/configuration/configure_ui.cpp b/src/yuzu/configuration/configure_ui.cpp index 94424ee44b..3058f25099 100644 --- a/src/yuzu/configuration/configure_ui.cpp +++ b/src/yuzu/configuration/configure_ui.cpp @@ -5,6 +5,7 @@ #include <array> #include <utility> +#include <QDirIterator> #include "common/common_types.h" #include "core/settings.h" #include "ui_configure_ui.h" @@ -28,6 +29,23 @@ constexpr std::array row_text_names{ ConfigureUi::ConfigureUi(QWidget* parent) : QWidget(parent), ui(new Ui::ConfigureUi) { ui->setupUi(this); + ui->language_combobox->addItem(tr("<System>"), 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<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, + &ConfigureUi::OnLanguageChanged); for (const auto& theme : UISettings::themes) { ui->theme_combobox->addItem(QString::fromUtf8(theme.first), @@ -72,6 +90,8 @@ void ConfigureUi::RequestGameListUpdate() { void ConfigureUi::SetConfiguration() { ui->theme_combobox->setCurrentIndex(ui->theme_combobox->findData(UISettings::values.theme)); + ui->language_combobox->setCurrentIndex( + ui->language_combobox->findData(UISettings::values.language)); ui->show_add_ons->setChecked(UISettings::values.show_add_ons); ui->icon_size_combobox->setCurrentIndex( ui->icon_size_combobox->findData(UISettings::values.icon_size)); @@ -147,3 +167,10 @@ void ConfigureUi::UpdateSecondRowComboBox(bool init) { ui->row_2_text_combobox->removeItem( ui->row_2_text_combobox->findData(ui->row_1_text_combobox->currentData())); } + +void ConfigureUi::OnLanguageChanged(int index) { + if (index == -1) + return; + + emit LanguageChanged(ui->language_combobox->itemData(index).toString()); +} |