diff --git a/src/qt_gui/settings_dialog.cpp b/src/qt_gui/settings_dialog.cpp index c2962ebf9..1598b0640 100644 --- a/src/qt_gui/settings_dialog.cpp +++ b/src/qt_gui/settings_dialog.cpp @@ -59,6 +59,9 @@ 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; +QMap logTypeMap; +QMap fullscreenModeMap; +QMap chooseHomeTabMap; SettingsDialog::SettingsDialog(std::span physical_devices, std::shared_ptr m_compat_info, @@ -73,6 +76,12 @@ SettingsDialog::SettingsDialog(std::span physical_devices, ui->buttonBox->button(QDialogButtonBox::StandardButton::Close)->setFocus(); channelMap = {{tr("Release"), "Release"}, {tr("Nightly"), "Nightly"}}; + logTypeMap = {{tr("async"), "async"}, {tr("sync"), "sync"}}; + fullscreenModeMap = {{tr("Borderless"), "Borderless"}, {tr("True"), "True"}}; + chooseHomeTabMap = {{tr("General"), "General"}, {tr("GUI"), "GUI"}, + {tr("Graphics"), "Graphics"}, {tr("User"), "User"}, + {tr("Input"), "Input"}, {tr("Paths"), "Paths"}, + {tr("Debug"), "Debug"}}; // Add list of available GPUs ui->graphicsAdapterBox->addItem(tr("Auto Select")); // -1, auto selection @@ -374,15 +383,19 @@ void SettingsDialog::LoadValuesFromConfig() { ui->discordRPCCheckbox->setChecked( toml::find_or(data, "General", "enableDiscordRPC", true)); ui->fullscreenCheckBox->setChecked(toml::find_or(data, "General", "Fullscreen", false)); - ui->fullscreenModeComboBox->setCurrentText(QString::fromStdString( - toml::find_or(data, "General", "FullscreenMode", "Borderless"))); + QString translatedText_FullscreenMode = + fullscreenModeMap.key(QString::fromStdString(Config::getFullscreenMode())); + if (!translatedText_FullscreenMode.isEmpty()) { + ui->fullscreenModeComboBox->setCurrentText(translatedText_FullscreenMode); + } ui->separateUpdatesCheckBox->setChecked( 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)); - std::string logType = Config::getLogType(); - ui->logTypeComboBox->setCurrentText(logType == "async" ? tr("async") - : (logType == "sync" ? tr("sync") : "")); + QString translatedText_logType = logTypeMap.key(QString::fromStdString(Config::getLogType())); + if (!translatedText_logType.isEmpty()) { + ui->logTypeComboBox->setCurrentText(translatedText_logType); + } ui->logFilterLineEdit->setText( QString::fromStdString(toml::find_or(data, "General", "logFilter", ""))); ui->userNameLineEdit->setText( @@ -421,13 +434,19 @@ void SettingsDialog::LoadValuesFromConfig() { : updateChannel)); #endif - std::string chooseHomeTab = toml::find_or(data, "General", "chooseHomeTab", ""); - ui->chooseHomeTabComboBox->setCurrentText(QString::fromStdString(chooseHomeTab)); + std::string chooseHomeTab = + toml::find_or(data, "General", "chooseHomeTab", "General"); + QString translatedText = chooseHomeTabMap.key(QString::fromStdString(chooseHomeTab)); + if (translatedText.isEmpty()) { + translatedText = tr("General"); + } + ui->chooseHomeTabComboBox->setCurrentText(translatedText); + QStringList tabNames = {tr("General"), tr("GUI"), tr("Graphics"), tr("User"), tr("Input"), tr("Paths"), tr("Debug")}; - QString chooseHomeTabQString = QString::fromStdString(chooseHomeTab); - int indexTab = tabNames.indexOf(chooseHomeTabQString); - indexTab = (indexTab == -1) ? 0 : indexTab; + int indexTab = tabNames.indexOf(translatedText); + if (indexTab == -1) + indexTab = 0; ui->tabWidgetSettings->setCurrentIndex(indexTab); QString backButtonBehavior = QString::fromStdString( @@ -634,12 +653,13 @@ void SettingsDialog::UpdateSettings() { const QVector TouchPadIndex = {"left", "center", "right", "none"}; Config::setBackButtonBehavior(TouchPadIndex[ui->backButtonBehaviorComboBox->currentIndex()]); Config::setIsFullscreen(ui->fullscreenCheckBox->isChecked()); - Config::setFullscreenMode(ui->fullscreenModeComboBox->currentText().toStdString()); + Config::setFullscreenMode( + fullscreenModeMap.value(ui->fullscreenModeComboBox->currentText()).toStdString()); Config::setIsMotionControlsEnabled(ui->motionControlsCheckBox->isChecked()); Config::setisTrophyPopupDisabled(ui->disableTrophycheckBox->isChecked()); Config::setPlayBGM(ui->playBGMCheckBox->isChecked()); Config::setAllowHDR(ui->enableHDRCheckBox->isChecked()); - Config::setLogType((ui->logTypeComboBox->currentText() == tr("async") ? "async" : "sync")); + Config::setLogType(logTypeMap.value(ui->logTypeComboBox->currentText()).toStdString()); Config::setLogFilter(ui->logFilterLineEdit->text().toStdString()); Config::setUserName(ui->userNameLineEdit->text().toStdString()); Config::setTrophyKey(ui->trophyKeyLineEdit->text().toStdString()); @@ -669,7 +689,8 @@ void SettingsDialog::UpdateSettings() { Config::setAutoUpdate(ui->updateCheckBox->isChecked()); Config::setAlwaysShowChangelog(ui->changelogCheckBox->isChecked()); Config::setUpdateChannel(channelMap.value(ui->updateComboBox->currentText()).toStdString()); - Config::setChooseHomeTab(ui->chooseHomeTabComboBox->currentText().toStdString()); + Config::setChooseHomeTab( + chooseHomeTabMap.value(ui->chooseHomeTabComboBox->currentText()).toStdString()); Config::setCompatibilityEnabled(ui->enableCompatibilityCheckBox->isChecked()); Config::setCheckCompatibilityOnStartup(ui->checkCompatibilityOnStartupCheckBox->isChecked()); Config::setBackgroundImageOpacity(ui->backgroundImageOpacitySlider->value());