mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 11:00:44 -06:00
preferencesdialog: Add country flag to language combo box
See issue #182.
This commit is contained in:
@@ -101,6 +101,7 @@ set(SQLB_FORMS
|
||||
|
||||
set(SQLB_RESOURCES
|
||||
src/icons/icons.qrc
|
||||
src/translations/flags/flags.qrc
|
||||
)
|
||||
|
||||
set(SQLB_MISC
|
||||
|
||||
@@ -255,7 +255,6 @@ void PreferencesDialog::removeExtension()
|
||||
|
||||
void PreferencesDialog::fillLanguageBox()
|
||||
{
|
||||
// Use the path relative to the main executable
|
||||
QDir translationsDir(QCoreApplication::applicationDirPath() + "/translations",
|
||||
"sqlb_*.qm");
|
||||
|
||||
@@ -263,9 +262,17 @@ void PreferencesDialog::fillLanguageBox()
|
||||
|
||||
// Add default language
|
||||
if (systemLocale.name() == "en_US")
|
||||
ui->languageComboBox->addItem("English (United States) [System Language]","en_US");
|
||||
{
|
||||
ui->languageComboBox->addItem(QIcon(":/flags/en_US"),
|
||||
"English (United States) [System Language]",
|
||||
"en_US");
|
||||
}
|
||||
else
|
||||
ui->languageComboBox->addItem("English (United States) [Default Language]","en_US");
|
||||
{
|
||||
ui->languageComboBox->addItem(QIcon(":/flags/en_US"),
|
||||
"English (United States) [Default Language]",
|
||||
"en_US");
|
||||
}
|
||||
|
||||
foreach(const QFileInfo &file, translationsDir.entryInfoList())
|
||||
{
|
||||
@@ -281,7 +288,7 @@ void PreferencesDialog::fillLanguageBox()
|
||||
if (locale == systemLocale)
|
||||
language += " [System language]";
|
||||
|
||||
ui->languageComboBox->addItem(language, locale.name());
|
||||
ui->languageComboBox->addItem(QIcon(":/flags/" + locale.name()), language, locale.name());
|
||||
}
|
||||
|
||||
ui->languageComboBox->model()->sort(0);
|
||||
@@ -296,9 +303,10 @@ void PreferencesDialog::fillLanguageBox()
|
||||
|
||||
QString chosenLanguage = ui->languageComboBox->itemText(index);
|
||||
QVariant chosenLocale = ui->languageComboBox->itemData(index);
|
||||
QIcon chosenIcon = ui->languageComboBox->itemIcon(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->insertItem(0, chosenIcon, chosenLanguage, chosenLocale);
|
||||
ui->languageComboBox->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>290</width>
|
||||
<width>316</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
@@ -83,11 +83,17 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QComboBox::AdjustToMinimumContentsLength</enum>
|
||||
<enum>QComboBox::AdjustToContents</enum>
|
||||
</property>
|
||||
<property name="minimumContentsLength">
|
||||
<number>35</number>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>15</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
||||
@@ -71,7 +71,8 @@ SOURCES += \
|
||||
Application.cpp \
|
||||
CipherDialog.cpp
|
||||
|
||||
RESOURCES += icons/icons.qrc
|
||||
RESOURCES += icons/icons.qrc \
|
||||
translations/flags/flags.qrc
|
||||
|
||||
FORMS += \
|
||||
MainWindow.ui \
|
||||
|
||||
BIN
src/translations/flags/cn.png
Normal file
BIN
src/translations/flags/cn.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.1 KiB |
BIN
src/translations/flags/de.png
Normal file
BIN
src/translations/flags/de.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.9 KiB |
9
src/translations/flags/flags.qrc
Normal file
9
src/translations/flags/flags.qrc
Normal file
@@ -0,0 +1,9 @@
|
||||
<RCC>
|
||||
<qresource prefix="/flags">
|
||||
<file alias="de_DE">de.png</file>
|
||||
<file alias="en_US">us.png</file>
|
||||
<file alias="fr_FR">fr.png</file>
|
||||
<file alias="ru_RU">ru.png</file>
|
||||
<file alias="zh_CN">cn.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
BIN
src/translations/flags/fr.png
Normal file
BIN
src/translations/flags/fr.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.0 KiB |
BIN
src/translations/flags/ru.png
Normal file
BIN
src/translations/flags/ru.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.0 KiB |
BIN
src/translations/flags/us.png
Normal file
BIN
src/translations/flags/us.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.3 KiB |
Reference in New Issue
Block a user