From d1e88c40d8077784a340977a7818d66843c2b176 Mon Sep 17 00:00:00 2001 From: DanielSvoboda Date: Fri, 14 Feb 2025 02:23:11 -0300 Subject: [PATCH] Displays translation in interface, not logs or config (#2424) Release/Nightly async/sync --- src/qt_gui/settings_dialog.cpp | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/qt_gui/settings_dialog.cpp b/src/qt_gui/settings_dialog.cpp index 63b5bb384..d34dd0856 100644 --- a/src/qt_gui/settings_dialog.cpp +++ b/src/qt_gui/settings_dialog.cpp @@ -58,6 +58,7 @@ QStringList languageNames = {"Arabic", const QVector languageIndexes = {21, 23, 14, 6, 18, 1, 12, 22, 2, 4, 25, 24, 29, 5, 0, 9, 15, 16, 17, 7, 26, 8, 11, 20, 3, 13, 27, 10, 19, 30, 28}; +QMap channelMap; SettingsDialog::SettingsDialog(std::span physical_devices, std::shared_ptr m_compat_info, @@ -71,6 +72,8 @@ SettingsDialog::SettingsDialog(std::span physical_devices, ui->buttonBox->button(QDialogButtonBox::StandardButton::Close)->setFocus(); + channelMap = {{tr("Release"), "Release"}, {tr("Nightly"), "Nightly"}}; + // Add list of available GPUs ui->graphicsAdapterBox->addItem(tr("Auto Select")); // -1, auto selection for (const auto& device : physical_devices) { @@ -149,7 +152,11 @@ SettingsDialog::SettingsDialog(std::span physical_devices, #endif connect(ui->updateComboBox, &QComboBox::currentTextChanged, this, - [](const QString& channel) { Config::setUpdateChannel(channel.toStdString()); }); + [this](const QString& channel) { + if (channelMap.contains(channel)) { + Config::setUpdateChannel(channelMap.value(channel).toStdString()); + } + }); connect(ui->checkUpdateButton, &QPushButton::clicked, this, []() { auto checkUpdate = new CheckUpdate(true); @@ -373,8 +380,9 @@ void SettingsDialog::LoadValuesFromConfig() { toml::find_or(data, "General", "separateUpdateEnabled", false)); ui->gameSizeCheckBox->setChecked(toml::find_or(data, "GUI", "loadGameSizeEnabled", true)); ui->showSplashCheckBox->setChecked(toml::find_or(data, "General", "showSplash", false)); - ui->logTypeComboBox->setCurrentText( - QString::fromStdString(toml::find_or(data, "General", "logType", "async"))); + std::string logType = Config::getLogType(); + ui->logTypeComboBox->setCurrentText(logType == "async" ? tr("async") + : (logType == "sync" ? tr("sync") : "")); ui->logFilterLineEdit->setText( QString::fromStdString(toml::find_or(data, "General", "logFilter", ""))); ui->userNameLineEdit->setText( @@ -405,15 +413,12 @@ void SettingsDialog::LoadValuesFromConfig() { ui->updateCheckBox->setChecked(toml::find_or(data, "General", "autoUpdate", false)); ui->changelogCheckBox->setChecked( toml::find_or(data, "General", "alwaysShowChangelog", false)); - std::string updateChannel = toml::find_or(data, "General", "updateChannel", ""); - if (updateChannel != "Release" && updateChannel != "Nightly") { - if (Common::isRelease) { - updateChannel = "Release"; - } else { - updateChannel = "Nightly"; - } - } - ui->updateComboBox->setCurrentText(QString::fromStdString(updateChannel)); + + QString updateChannel = QString::fromStdString(Config::getUpdateChannel()); + ui->updateComboBox->setCurrentText( + channelMap.key(updateChannel != "Release" && updateChannel != "Nightly" + ? (Common::isRelease ? "Release" : "Nightly") + : updateChannel)); #endif std::string chooseHomeTab = toml::find_or(data, "General", "chooseHomeTab", ""); @@ -637,7 +642,7 @@ void SettingsDialog::UpdateSettings() { Config::setisTrophyPopupDisabled(ui->disableTrophycheckBox->isChecked()); Config::setPlayBGM(ui->playBGMCheckBox->isChecked()); Config::setAllowHDR(ui->enableHDRCheckBox->isChecked()); - Config::setLogType(ui->logTypeComboBox->currentText().toStdString()); + Config::setLogType((ui->logTypeComboBox->currentText() == tr("async") ? "async" : "sync")); Config::setLogFilter(ui->logFilterLineEdit->text().toStdString()); Config::setUserName(ui->userNameLineEdit->text().toStdString()); Config::setTrophyKey(ui->trophyKeyLineEdit->text().toStdString()); @@ -666,7 +671,7 @@ void SettingsDialog::UpdateSettings() { Config::setCopyGPUCmdBuffers(ui->copyGPUBuffersCheckBox->isChecked()); Config::setAutoUpdate(ui->updateCheckBox->isChecked()); Config::setAlwaysShowChangelog(ui->changelogCheckBox->isChecked()); - Config::setUpdateChannel(ui->updateComboBox->currentText().toStdString()); + Config::setUpdateChannel(channelMap.value(ui->updateComboBox->currentText()).toStdString()); Config::setChooseHomeTab(ui->chooseHomeTabComboBox->currentText().toStdString()); Config::setCompatibilityEnabled(ui->enableCompatibilityCheckBox->isChecked()); Config::setCheckCompatibilityOnStartup(ui->checkCompatibilityOnStartupCheckBox->isChecked());