Preferences/ConfigurationPages/EditorSpellCheckingPage.py

changeset 4576
a258569d44db
parent 4021
195a471c327b
child 4631
5c1a96925da4
equal deleted inserted replaced
4575:464a6b049f89 4576:a258569d44db
7 Module implementing the Editor Spellchecking configuration page. 7 Module implementing the Editor Spellchecking configuration page.
8 """ 8 """
9 9
10 from __future__ import unicode_literals 10 from __future__ import unicode_literals
11 11
12 from PyQt5.QtCore import pyqtSlot 12 from E5Gui.E5PathPicker import E5PathPickerModes
13
14 from E5Gui.E5Completers import E5FileCompleter
15 from E5Gui import E5FileDialog
16 13
17 from .ConfigurationPageBase import ConfigurationPageBase 14 from .ConfigurationPageBase import ConfigurationPageBase
18 from .Ui_EditorSpellCheckingPage import Ui_EditorSpellCheckingPage 15 from .Ui_EditorSpellCheckingPage import Ui_EditorSpellCheckingPage
19 16
20 import Preferences 17 import Preferences
21 import Utilities
22 import UI.PixmapCache
23 18
24 19
25 class EditorSpellCheckingPage(ConfigurationPageBase, 20 class EditorSpellCheckingPage(ConfigurationPageBase,
26 Ui_EditorSpellCheckingPage): 21 Ui_EditorSpellCheckingPage):
27 """ 22 """
33 """ 28 """
34 super(EditorSpellCheckingPage, self).__init__() 29 super(EditorSpellCheckingPage, self).__init__()
35 self.setupUi(self) 30 self.setupUi(self)
36 self.setObjectName("EditorSpellCheckingPage") 31 self.setObjectName("EditorSpellCheckingPage")
37 32
38 self.pwlButton.setIcon(UI.PixmapCache.getIcon("open.png")) 33 self.pwlPicker.setMode(E5PathPickerModes.OpenFileMode)
39 self.pelButton.setIcon(UI.PixmapCache.getIcon("open.png")) 34 self.pwlPicker.setFilters(self.tr(
35 "Dictionary File (*.dic);;All Files (*)"))
36
37 self.pelPicker.setMode(E5PathPickerModes.OpenFileMode)
38 self.pelPicker.setFilters(self.tr(
39 "Dictionary File (*.dic);;All Files (*)"))
40 40
41 from QScintilla.SpellChecker import SpellChecker 41 from QScintilla.SpellChecker import SpellChecker
42 languages = sorted(SpellChecker.getAvailableLanguages()) 42 languages = sorted(SpellChecker.getAvailableLanguages())
43 self.defaultLanguageCombo.addItems(languages) 43 self.defaultLanguageCombo.addItems(languages)
44 if languages: 44 if languages:
45 self.errorLabel.hide() 45 self.errorLabel.hide()
46 else: 46 else:
47 self.spellingFrame.setEnabled(False) 47 self.spellingFrame.setEnabled(False)
48
49 self.pwlFileCompleter = E5FileCompleter(self.pwlEdit, showHidden=True)
50 self.pelFileCompleter = E5FileCompleter(self.pelEdit, showHidden=True)
51 48
52 # set initial values 49 # set initial values
53 self.checkingEnabledCheckBox.setChecked( 50 self.checkingEnabledCheckBox.setChecked(
54 Preferences.getEditor("SpellCheckingEnabled")) 51 Preferences.getEditor("SpellCheckingEnabled"))
55 52
64 61
65 self.initColour( 62 self.initColour(
66 "SpellingMarkers", self.spellingMarkerButton, 63 "SpellingMarkers", self.spellingMarkerButton,
67 Preferences.getEditorColour, hasAlpha=True) 64 Preferences.getEditorColour, hasAlpha=True)
68 65
69 self.pwlEdit.setText( 66 self.pwlPicker.setText(
70 Preferences.getEditor("SpellCheckingPersonalWordList")) 67 Preferences.getEditor("SpellCheckingPersonalWordList"))
71 self.pelEdit.setText( 68 self.pelPicker.setText(
72 Preferences.getEditor("SpellCheckingPersonalExcludeList")) 69 Preferences.getEditor("SpellCheckingPersonalExcludeList"))
73 70
74 if self.spellingFrame.isEnabled(): 71 if self.spellingFrame.isEnabled():
75 self.enabledCheckBox.setChecked( 72 self.enabledCheckBox.setChecked(
76 Preferences.getEditor("AutoSpellCheckingEnabled")) 73 Preferences.getEditor("AutoSpellCheckingEnabled"))
96 "SpellCheckingMinWordSize", self.minimumWordSizeSlider.value()) 93 "SpellCheckingMinWordSize", self.minimumWordSizeSlider.value())
97 94
98 self.saveColours(Preferences.setEditorColour) 95 self.saveColours(Preferences.setEditorColour)
99 96
100 Preferences.setEditor( 97 Preferences.setEditor(
101 "SpellCheckingPersonalWordList", self.pwlEdit.text()) 98 "SpellCheckingPersonalWordList", self.pwlPicker.text())
102 Preferences.setEditor( 99 Preferences.setEditor(
103 "SpellCheckingPersonalExcludeList", self.pelEdit.text()) 100 "SpellCheckingPersonalExcludeList", self.pelPicker.text())
104 101
105 Preferences.setEditor( 102 Preferences.setEditor(
106 "AutoSpellCheckingEnabled", self.enabledCheckBox.isChecked()) 103 "AutoSpellCheckingEnabled", self.enabledCheckBox.isChecked())
107 Preferences.setEditor( 104 Preferences.setEditor(
108 "AutoSpellCheckChunkSize", self.chunkSizeSpinBox.value()) 105 "AutoSpellCheckChunkSize", self.chunkSizeSpinBox.value())
109
110 @pyqtSlot()
111 def on_pwlButton_clicked(self):
112 """
113 Private method to select the personal word list file.
114 """
115 file = E5FileDialog.getOpenFileName(
116 self,
117 self.tr("Select personal word list"),
118 self.pwlEdit.text(),
119 self.tr("Dictionary File (*.dic);;All Files (*)"))
120
121 if file:
122 self.pwlEdit.setText(Utilities.toNativeSeparators(file))
123
124 @pyqtSlot()
125 def on_pelButton_clicked(self):
126 """
127 Private method to select the personal exclude list file.
128 """
129 file = E5FileDialog.getOpenFileName(
130 self,
131 self.tr("Select personal exclude list"),
132 self.pelEdit.text(),
133 self.tr("Dictionary File (*.dic);;All Files (*)"))
134
135 if file:
136 self.pelEdit.setText(Utilities.toNativeSeparators(file))
137 106
138 107
139 def create(dlg): 108 def create(dlg):
140 """ 109 """
141 Module function to create the configuration page. 110 Module function to create the configuration page.

eric ide

mercurial