6import QtQuick.Controls as QQC2
8import org.kde.kirigami as Kirigami
9import org.kde.kirigami.delegates as KirigamiDelegates
10import org.kde.sonnet as Sonnet
11import org.kde.kirigamiaddons.formcard as FormCard
12import org.kde.kirigamiaddons.delegates as Delegates
14FormCard.FormCardPage {
17 readonly property Sonnet.Settings settings: Sonnet.Settings {
21 readonly property Kirigami.PageRow pageStack: QQC2.ApplicationWindow.window.pageStack
23 function add(word: string): void {
24 const dictionary = root.settings.currentIgnoreList;
25 dictionary.push(word);
26 root.settings.currentIgnoreList = dictionary;
29 function
remove(word:
string): void {
30 root.settings.currentIgnoreList = root.settings.currentIgnoreList.
filter((value, _, _) => {
31 return value !== word;
36 Layout.topMargin:
Kirigami.Units.largeSpacing * 2
40 checked: root.settings.checkerEnabledByDefault
41 text:
i18ndc(
"kirigami-addons6",
"@label:checkbox",
"Enable automatic spell checking")
43 root.settings.checkerEnabledByDefault = checked;
49 below: enable; above: skipUppercase
54 checked: root.settings.skipUppercase
55 text:
i18ndc(
"kirigami-addons6",
"@label:checkbox",
"Ignore uppercase words")
57 root.settings.skipUppercase = checked;
63 below: skipUppercase; above: skipRunTogether
68 checked: root.settings.skipRunTogether
69 text:
i18ndc(
"kirigami-addons6",
"@label:checkbox",
"Ignore hyphenated words")
71 root.settings.skipRunTogether = checked;
77 below: skipRunTogether; above: autodetectLanguageCheckbox
81 id: autodetectLanguageCheckbox
82 checked: root.settings.autodetectLanguage
83 text:
i18ndc(
"kirigami-addons6",
"@label:checkbox",
"Detect language automatically")
85 root.settings.autodetectLanguage = checked;
91 below: autodetectLanguageCheckbox; above: selectedDefaultLanguage
95 id: selectedDefaultLanguage
96 text:
i18ndc(
"kirigami-addons6",
"@label:listbox",
"Selected default language:")
97 model: isEmpty ? [{
"display":
i18ndc(
"kirigami-addons6",
"No selected language",
"None")}] : root.settings.dictionaryModel
99 valueRole:
"languageCode"
100 property bool isEmpty:
false
101 Component.onCompleted: {
102 if (root.settings.dictionaryModel.rowCount() === 0) {
105 currentIndex = indexOfValue(root.settings.defaultLanguage);
108 onActivated: root.settings.defaultLanguage = currentValue;
112 below: selectedDefaultLanguage; above: spellCheckingLanguage
116 id: spellCheckingLanguage
117 text:
i18ndc(
"kirigami-addons6",
"@label:listbox",
"Additional Spell Checking Languages")
118 description: i18nd("kirigami-addons6", "%1 will provide spell checking and suggestions for the languages listed here when autodetection is enabled.",
Qt.application.displayName)
119 onClicked: root.pageStack.pushDialogLayer(spellCheckingLanguageList, {}, {
120 width: root.pageStack.width -
Kirigami.Units.gridUnit * 5,
121 height: root.pageStack.height -
Kirigami.Units.gridUnit * 5,
126 below: spellCheckingLanguage; above: personalDictionary
130 id: personalDictionary
131 text:
i18ndc(
"kirigami-addons6",
"@action:button",
"Open Personal Dictionary")
132 onClicked: root.pageStack.pushDialogLayer(dictionaryPage, {}, {
133 width: root.pageStack.width -
Kirigami.Units.gridUnit * 5,
134 height: root.pageStack.height -
Kirigami.Units.gridUnit * 5,
140 id: spellCheckingLanguageList
143 title:
i18ndc(
"kirigami-addons6",
"@title:window",
"Spell checking languages")
144 enabled: autodetectLanguageCheckbox.checked
147 model: root.settings.dictionaryModel
148 delegate: KirigamiDelegates.CheckSubtitleDelegate {
149 width: ListView.view.width
153 onTriggered: model.checked = checked
155 Accessible.description: model.isDefault ?
i18nd(
"kirigami-addons6",
"Default Language") :
''
156 checked: model.checked
158 icon.source: model.isDefault ?
"favorite" : undefined
167 title:
i18ndc(
"kirigami-addons6",
"@title:window",
"Spell checking dictionary")
169 contentItem: RowLayout {
172 Layout.fillWidth: true
173 Accessible.
name: placeholderText
174 placeholderText:
i18ndc(
"kirigami-addons6",
"Placeholder message",
"Add a new word to your personal dictionary…")
177 text:
i18ndc(
"kirigami-addons6",
"@action:button",
"Add Word")
178 icon.
name:
"list-add"
179 enabled: dictionaryField.text.length > 0
181 root.add(dictionaryField.text);
182 dictionaryField.
clear();
184 root.settings.save();
187 Layout.rightMargin:
Kirigami.Units.largeSpacing
192 topMargin: Math.round(
Kirigami.Units.smallSpacing / 2)
193 bottomMargin: Math.round(
Kirigami.Units.smallSpacing / 2)
195 model: root.settings.currentIgnoreList
196 delegate: Delegates.RoundedItemDelegate {
199 required
property string modelData
203 contentItem: RowLayout {
204 spacing:
Kirigami.Units.smallSpacing
206 Delegates.DefaultContentItem {
207 itemDelegate: wordDelegate
208 Layout.fillWidth:
true
212 text:
i18ndc(
"kirigami-addons6",
"@action:button",
"Delete word")
214 display: QQC2.ToolButton.IconOnly
216 root.
remove(wordDelegate.modelData);
218 root.settings.save();
222 QQC2.ToolTip.text: text
223 QQC2.ToolTip.visible: hovered
224 QQC2.ToolTip.delay:
Kirigami.ToolTip.toolTipDelay
QString i18ndc(const char *domain, const char *context, const char *text, const TYPE &arg...)
QString i18nd(const char *domain, const char *text, const TYPE &arg...)
QString name(StandardAction id)
QString & remove(QChar ch, Qt::CaseSensitivity cs)
QFuture< void > filter(QThreadPool *pool, Sequence &sequence, KeepFunctor &&filterFunction)