mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +01:00
SpellCheck: Support multiple languages
This commit is contained in:
parent
868a0ba84e
commit
24be6708e2
@ -409,7 +409,7 @@ Preferences::Preferences(BrowserWindow* window)
|
||||
//SPELLCHECK
|
||||
settings.beginGroup(QSL("SpellCheck"));
|
||||
ui->spellcheckEnabled->setChecked(settings.value(QSL("Enabled"), false).toBool());
|
||||
const QString spellcheckLanguage = settings.value(QSL("Language")).toString();
|
||||
const QStringList spellcheckLanguages = settings.value(QSL("Languages")).toStringList();
|
||||
settings.endGroup();
|
||||
|
||||
const QStringList dictionariesDirs = {
|
||||
@ -429,15 +429,18 @@ Preferences::Preferences(BrowserWindow* window)
|
||||
const QStringList files = dir.entryList({QSL("*.bdic")});
|
||||
for (const QString &file : files) {
|
||||
const QString lang = file.left(file.size() - 5);
|
||||
ui->spellcheckLanguage->addItem(createLanguageItem(lang), lang);
|
||||
if (lang == spellcheckLanguage) {
|
||||
ui->spellcheckLanguage->setCurrentIndex(ui->spellcheckLanguage->count() - 1);
|
||||
QListWidgetItem *item = new QListWidgetItem;
|
||||
item->setText(createLanguageItem(lang));
|
||||
item->setData(Qt::UserRole, lang);
|
||||
ui->spellcheckLanguages->addItem(item);
|
||||
if (spellcheckLanguages.contains(lang)) {
|
||||
ui->spellcheckLanguages->setCurrentItem(item, QItemSelectionModel::Select);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ui->spellcheckLanguage->count() == 0) {
|
||||
ui->spellcheckLanguage->hide();
|
||||
if (ui->spellcheckLanguages->count() == 0) {
|
||||
ui->spellcheckLanguages->hide();
|
||||
} else {
|
||||
ui->spellcheckNoLanguages->hide();
|
||||
}
|
||||
@ -1003,7 +1006,11 @@ void Preferences::saveSettings()
|
||||
//SPELLCHECK
|
||||
settings.beginGroup(QSL("SpellCheck"));
|
||||
settings.setValue("Enabled", ui->spellcheckEnabled->isChecked());
|
||||
settings.setValue("Language", ui->spellcheckLanguage->currentData().toString());
|
||||
QStringList languages;
|
||||
for (QListWidgetItem *item : ui->spellcheckLanguages->selectedItems()) {
|
||||
languages.append(item->data(Qt::UserRole).toString());
|
||||
}
|
||||
settings.setValue("Languages", languages);
|
||||
settings.endGroup();
|
||||
#endif
|
||||
|
||||
|
@ -2282,20 +2282,7 @@
|
||||
</widget>
|
||||
<widget class="QWidget" name="spellcheckPage">
|
||||
<layout class="QGridLayout" name="gridLayout_20">
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Language:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="4">
|
||||
<item row="3" column="6">
|
||||
<spacer name="horizontalSpacer_16">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
@ -2308,17 +2295,10 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<widget class="QLabel" name="spellcheckNoLanguages">
|
||||
<property name="text">
|
||||
<string>No languages found</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1" colspan="4">
|
||||
<item row="7" column="1" colspan="6">
|
||||
<widget class="QLabel" name="label_40">
|
||||
<property name="text">
|
||||
<string>For more informations about Spell Check, please see <a href="https://github.com/QupZilla/qupzilla/wiki/Spell-Check">wiki</a>.</string>
|
||||
<string>For more information about Spell Check, please see <a href="https://github.com/QupZilla/qupzilla/wiki/Spell-Check">wiki</a>.</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
@ -2328,7 +2308,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<item row="9" column="1">
|
||||
<spacer name="verticalSpacer_17">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@ -2341,10 +2321,7 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QComboBox" name="spellcheckLanguage"/>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<item row="4" column="4">
|
||||
<spacer name="verticalSpacer_18">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@ -2360,28 +2337,28 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="5">
|
||||
<item row="0" column="0" colspan="7">
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="text">
|
||||
<string><b>Spell Check options</b></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="4">
|
||||
<item row="1" column="1" colspan="6">
|
||||
<widget class="QCheckBox" name="spellcheckEnabled">
|
||||
<property name="text">
|
||||
<string>Enable Spell Check</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1" colspan="4">
|
||||
<item row="5" column="1" colspan="6">
|
||||
<widget class="QLabel" name="label_48">
|
||||
<property name="text">
|
||||
<string><b>Dictionary directories</b></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1" colspan="4">
|
||||
<item row="6" column="1" colspan="6">
|
||||
<widget class="QScrollArea" name="spellcheckDirectoriesScrollArea">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Maximum">
|
||||
@ -2409,6 +2386,26 @@
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QListWidget" name="spellcheckLanguages">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::MultiSelection</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QLabel" name="spellcheckNoLanguages">
|
||||
<property name="text">
|
||||
<string>No languages found</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="otherPage">
|
||||
|
Loading…
Reference in New Issue
Block a user