Merge pull request #466 from DanielSvoboda/alphabetical-order-console-language

Alphabetical order console language
This commit is contained in:
georgemoralis 2024-08-18 23:37:34 +03:00 committed by GitHub
commit 09b71a9a3f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 54 additions and 155 deletions

View File

@ -1,9 +1,44 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <QCompleter>
#include "settings_dialog.h"
#include "ui_settings_dialog.h"
QStringList languageNames = {"Arabic",
"Czech",
"Danish",
"Dutch",
"English (United Kingdom)",
"English (United States)",
"Finnish",
"French (Canada)",
"French (France)",
"German",
"Greek",
"Hungarian",
"Indonesian",
"Italian",
"Japanese",
"Korean",
"Norwegian",
"Polish",
"Portuguese (Brazil)",
"Portuguese (Portugal)",
"Romanian",
"Russian",
"Simplified Chinese",
"Spanish (Latin America)",
"Spanish (Spain)",
"Swedish",
"Thai",
"Traditional Chinese",
"Turkish",
"Vietnamese"};
const QVector<int> 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, 28};
SettingsDialog::SettingsDialog(std::span<const QString> physical_devices, QWidget* parent)
: QDialog(parent), ui(new Ui::SettingsDialog) {
ui->setupUi(this);
@ -18,6 +53,12 @@ SettingsDialog::SettingsDialog(std::span<const QString> physical_devices, QWidge
ui->graphicsAdapterBox->addItem(device);
}
ui->consoleLanguageComboBox->addItems(languageNames);
QCompleter* completer = new QCompleter(languageNames, this);
completer->setCaseSensitivity(Qt::CaseInsensitive);
ui->consoleLanguageComboBox->setCompleter(completer);
LoadValuesFromConfig();
connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &QWidget::close);
@ -44,8 +85,13 @@ SettingsDialog::SettingsDialog(std::span<const QString> physical_devices, QWidge
connect(ui->userNameLineEdit, &QLineEdit::textChanged, this,
[](const QString& text) { Config::setUserName(text.toStdString()); });
connect(ui->consoleLanguageComboBox, &QComboBox::currentIndexChanged, this,
[](int index) { Config::setLanguage(index); });
connect(ui->consoleLanguageComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, [this](int index) {
if (index >= 0 && index < languageIndexes.size()) {
int languageCode = languageIndexes[index];
Config::setLanguage(languageCode);
}
});
connect(ui->fullscreenCheckBox, &QCheckBox::stateChanged, this,
[](int val) { Config::setFullscreenMode(val); });
@ -106,8 +152,11 @@ SettingsDialog::SettingsDialog(std::span<const QString> physical_devices, QWidge
}
void SettingsDialog::LoadValuesFromConfig() {
ui->consoleLanguageComboBox->setCurrentIndex(Config::GetLanguage());
ui->consoleLanguageComboBox->setCurrentIndex(
std::distance(
languageIndexes.begin(),
std::find(languageIndexes.begin(), languageIndexes.end(), Config::GetLanguage())) %
languageIndexes.size());
ui->graphicsAdapterBox->setCurrentIndex(Config::getGpuId() + 1);
ui->widthSpinBox->setValue(Config::getScreenWidth());
ui->heightSpinBox->setValue(Config::getScreenHeight());

View File

@ -113,156 +113,6 @@
<layout class="QVBoxLayout" name="settingsLayout">
<item>
<widget class="QComboBox" name="consoleLanguageComboBox">
<item>
<property name="text">
<string>Japanese</string>
</property>
</item>
<item>
<property name="text">
<string>English (United States)</string>
</property>
</item>
<item>
<property name="text">
<string>French (France)</string>
</property>
</item>
<item>
<property name="text">
<string>Spanish (Spain)</string>
</property>
</item>
<item>
<property name="text">
<string>German</string>
</property>
</item>
<item>
<property name="text">
<string>Italian</string>
</property>
</item>
<item>
<property name="text">
<string>Dutch</string>
</property>
</item>
<item>
<property name="text">
<string>Portuguese (Portugal)</string>
</property>
</item>
<item>
<property name="text">
<string>Russian</string>
</property>
</item>
<item>
<property name="text">
<string>Korean</string>
</property>
</item>
<item>
<property name="text">
<string>Traditional Chinese</string>
</property>
</item>
<item>
<property name="text">
<string>Simplified Chinese</string>
</property>
</item>
<item>
<property name="text">
<string>Finnish</string>
</property>
</item>
<item>
<property name="text">
<string>Swedish</string>
</property>
</item>
<item>
<property name="text">
<string>Danish</string>
</property>
</item>
<item>
<property name="text">
<string>Norwegian</string>
</property>
</item>
<item>
<property name="text">
<string>Polish</string>
</property>
</item>
<item>
<property name="text">
<string>Portuguese (Brazil)</string>
</property>
</item>
<item>
<property name="text">
<string>English (United Kingdom)</string>
</property>
</item>
<item>
<property name="text">
<string>Turkish</string>
</property>
</item>
<item>
<property name="text">
<string>Spanish (Latin America)</string>
</property>
</item>
<item>
<property name="text">
<string>Arabic</string>
</property>
</item>
<item>
<property name="text">
<string>French (Canada)</string>
</property>
</item>
<item>
<property name="text">
<string>Czech</string>
</property>
</item>
<item>
<property name="text">
<string>Hungarian</string>
</property>
</item>
<item>
<property name="text">
<string>Greek</string>
</property>
</item>
<item>
<property name="text">
<string>Romanian</string>
</property>
</item>
<item>
<property name="text">
<string>Thai</string>
</property>
</item>
<item>
<property name="text">
<string>Vietnamese</string>
</property>
</item>
<item>
<property name="text">
<string>Indonesian</string>
</property>
</item>
</widget>
</item>
</layout>