preferencesdialog: Add country flag to language combo box

See issue #182.
This commit is contained in:
Samir Aguiar
2015-02-13 23:49:33 +01:00
parent 774e428b30
commit a5d6e6df7a
10 changed files with 33 additions and 8 deletions

View File

@@ -101,6 +101,7 @@ set(SQLB_FORMS
set(SQLB_RESOURCES
src/icons/icons.qrc
src/translations/flags/flags.qrc
)
set(SQLB_MISC

View File

@@ -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);
}

View File

@@ -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>

View File

@@ -71,7 +71,8 @@ SOURCES += \
Application.cpp \
CipherDialog.cpp
RESOURCES += icons/icons.qrc
RESOURCES += icons/icons.qrc \
translations/flags/flags.qrc
FORMS += \
MainWindow.ui \

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

View 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>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB