mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-05-11 14:30:17 -05:00
preferencesdialog: Suffix to identify system and default languages
Also, move the selected language to the top of the language combo box.
This commit is contained in:
@@ -259,20 +259,28 @@ void PreferencesDialog::fillLanguageBox()
|
||||
QDir translationsDir(QCoreApplication::applicationDirPath() + "/translations",
|
||||
"sqlb_*.qm");
|
||||
|
||||
QLocale systemLocale = QLocale::system();
|
||||
|
||||
// Add default language
|
||||
ui->languageComboBox->addItem("English (United States)", "en_US");
|
||||
if (systemLocale.name() == "en_US")
|
||||
ui->languageComboBox->addItem("English (United States) [System Language]","en_US");
|
||||
else
|
||||
ui->languageComboBox->addItem("English (United States) [Default Language]","en_US");
|
||||
|
||||
foreach(const QFileInfo &file, translationsDir.entryInfoList())
|
||||
{
|
||||
QLocale locale(file.baseName().remove("sqlb_"));
|
||||
|
||||
// Prevent invalid locales from being added to the box
|
||||
// Skip invalid locales
|
||||
if(locale.name() == "C")
|
||||
continue;
|
||||
|
||||
QString language = QLocale::languageToString(locale.language()) + " (" +
|
||||
QLocale::countryToString(locale.country()) + ")";
|
||||
|
||||
if (locale == systemLocale)
|
||||
language += " [System language]";
|
||||
|
||||
ui->languageComboBox->addItem(language, locale.name());
|
||||
}
|
||||
|
||||
@@ -286,5 +294,11 @@ void PreferencesDialog::fillLanguageBox()
|
||||
if(index < 0)
|
||||
index = ui->languageComboBox->findData("en_US", Qt::UserRole, Qt::MatchExactly);
|
||||
|
||||
ui->languageComboBox->setCurrentIndex(index);
|
||||
QString chosenLanguage = ui->languageComboBox->itemText(index);
|
||||
QVariant chosenLocale = ui->languageComboBox->itemData(index);
|
||||
|
||||
// There's no "move" method, so we remove and add the chosen language again at the top
|
||||
ui->languageComboBox->removeItem(index);
|
||||
ui->languageComboBox->insertItem(0, chosenLanguage, chosenLocale);
|
||||
ui->languageComboBox->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<width>290</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
@@ -86,7 +86,7 @@
|
||||
<enum>QComboBox::AdjustToMinimumContentsLength</enum>
|
||||
</property>
|
||||
<property name="minimumContentsLength">
|
||||
<number>20</number>
|
||||
<number>35</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
Reference in New Issue
Block a user