Skip to content

Commit

Permalink
Merge pull request #1024 from lassoan/fix-language-sorting
Browse files Browse the repository at this point in the history
BUG: Fix sorting of languages in ctkLanguageComboBox
  • Loading branch information
pieper authored Feb 7, 2022
2 parents 7b48c48 + 49b567c commit 652df69
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions Libs/Widgets/ctkLanguageComboBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,15 @@ void ctkLanguageComboBoxPrivate::updateLanguageItems()
else
{
languagesFound.insert(locale.language());
}
}
}
}

// Set language items in combobox
// Set language items in combobox
q->clear();
foreach(QString localeCode, localeCodes)
{
QLocale locale(localeCode);
bool showCountry = languagesWithMultipleLocalesFound.contains(locale.language());
foreach(QString localeCode, localeCodes)
{
QLocale locale(localeCode);
bool showCountry = languagesWithMultipleLocalesFound.contains(locale.language());
QIcon icon;
QString text;
QVariant data;
Expand All @@ -130,7 +130,12 @@ void ctkLanguageComboBoxPrivate::updateLanguageItems()
{
q->insertItem(q->count(), icon, text, data);
}
}
}

// Items are inserted based on order in file folders (usually locale name,
// so Spanish - "es" would be displayed above Finnish "fi"). To fix that
// we now sort based on the displayed text.
q->model()->sort(0, Qt::AscendingOrder);

// Restore selection
q->setCurrentIndex(q->findData(selectedLocaleCode));
Expand Down Expand Up @@ -223,7 +228,7 @@ QString ctkLanguageComboBox::defaultLanguage() const
// ----------------------------------------------------------------------------
void ctkLanguageComboBox::setDefaultLanguage(const QString& localeCode)
{
Q_D(ctkLanguageComboBox);
Q_D(ctkLanguageComboBox);
d->DefaultLanguage = localeCode;
d->updateLanguageItems();
}
Expand Down

0 comments on commit 652df69

Please sign in to comment.