diff --git a/src/lib/preferences/preferences.cpp b/src/lib/preferences/preferences.cpp
index d82662308..46fa16b80 100644
--- a/src/lib/preferences/preferences.cpp
+++ b/src/lib/preferences/preferences.cpp
@@ -436,19 +436,29 @@ Preferences::Preferences(BrowserWindow* window)
const QStringList files = dir.entryList({QSL("*.bdic")});
for (const QString &file : files) {
const QString lang = file.left(file.size() - 5);
- if (!ui->spellcheckLanguages->findItems(lang, Qt::MatchExactly).isEmpty()) {
+ const QString langName = createLanguageItem(lang);
+ if (!ui->spellcheckLanguages->findItems(langName, Qt::MatchExactly).isEmpty()) {
continue;
}
QListWidgetItem *item = new QListWidgetItem;
- item->setText(createLanguageItem(lang));
+ item->setText(langName);
item->setData(Qt::UserRole, lang);
ui->spellcheckLanguages->addItem(item);
- if (spellcheckLanguages.contains(lang)) {
- ui->spellcheckLanguages->setCurrentItem(item, QItemSelectionModel::Select);
- }
}
}
+ int topIndex = 0;
+ for (const QString &lang : spellcheckLanguages) {
+ const auto items = ui->spellcheckLanguages->findItems(createLanguageItem(lang), Qt::MatchExactly);
+ if (items.isEmpty()) {
+ continue;
+ }
+ QListWidgetItem *item = items.at(0);
+ ui->spellcheckLanguages->takeItem(ui->spellcheckLanguages->row(item));
+ ui->spellcheckLanguages->insertItem(topIndex++, item);
+ ui->spellcheckLanguages->setCurrentItem(item, QItemSelectionModel::Select);
+ }
+
if (ui->spellcheckLanguages->count() == 0) {
ui->spellcheckLanguages->hide();
} else {
@@ -1003,8 +1013,11 @@ void Preferences::saveSettings()
settings.beginGroup(QSL("SpellCheck"));
settings.setValue("Enabled", ui->spellcheckEnabled->isChecked());
QStringList languages;
- for (QListWidgetItem *item : ui->spellcheckLanguages->selectedItems()) {
- languages.append(item->data(Qt::UserRole).toString());
+ for (int i = 0; i < ui->spellcheckLanguages->count(); ++i) {
+ QListWidgetItem *item = ui->spellcheckLanguages->item(i);
+ if (item->isSelected()) {
+ languages.append(item->data(Qt::UserRole).toString());
+ }
}
settings.setValue("Languages", languages);
settings.endGroup();
diff --git a/src/lib/preferences/preferences.ui b/src/lib/preferences/preferences.ui
index f2d3df085..4f5609f27 100644
--- a/src/lib/preferences/preferences.ui
+++ b/src/lib/preferences/preferences.ui
@@ -2424,8 +2424,8 @@
0
0
- 96
- 28
+ 560
+ 80
@@ -2444,6 +2444,12 @@
100
+
+ true
+
+
+ QAbstractItemView::InternalMove
+
QAbstractItemView::MultiSelection