Project/SpellingPropertiesDialog.py

changeset 4582
3a1d1d4c6f4f
parent 4021
195a471c327b
child 4631
5c1a96925da4
equal deleted inserted replaced
4581:76999ca7bbf1 4582:3a1d1d4c6f4f
7 Module implementing the Spelling Properties dialog. 7 Module implementing the Spelling Properties dialog.
8 """ 8 """
9 9
10 from __future__ import unicode_literals 10 from __future__ import unicode_literals
11 11
12 import os
13
14 from PyQt5.QtCore import pyqtSlot
15 from PyQt5.QtWidgets import QDialog 12 from PyQt5.QtWidgets import QDialog
16 13
17 from E5Gui.E5Completers import E5FileCompleter 14 from E5Gui.E5PathPicker import E5PathPickerModes
18 from E5Gui import E5FileDialog
19 15
20 from .Ui_SpellingPropertiesDialog import Ui_SpellingPropertiesDialog 16 from .Ui_SpellingPropertiesDialog import Ui_SpellingPropertiesDialog
21 17
22 import Utilities
23 import Preferences 18 import Preferences
24 import UI.PixmapCache
25 19
26 20
27 class SpellingPropertiesDialog(QDialog, Ui_SpellingPropertiesDialog): 21 class SpellingPropertiesDialog(QDialog, Ui_SpellingPropertiesDialog):
28 """ 22 """
29 Class implementing the Spelling Properties dialog. 23 Class implementing the Spelling Properties dialog.
37 @param parent parent widget of this dialog (QWidget) 31 @param parent parent widget of this dialog (QWidget)
38 """ 32 """
39 super(SpellingPropertiesDialog, self).__init__(parent) 33 super(SpellingPropertiesDialog, self).__init__(parent)
40 self.setupUi(self) 34 self.setupUi(self)
41 35
42 self.pwlButton.setIcon(UI.PixmapCache.getIcon("open.png")) 36 self.pwlPicker.setMode(E5PathPickerModes.SaveFileMode)
43 self.pelButton.setIcon(UI.PixmapCache.getIcon("open.png")) 37 self.pwlPicker.setDefaultDirectory(project.ppath)
38 self.pwlPicker.setFilters(self.tr(
39 "Dictionary File (*.dic);;All Files (*)"))
40
41 self.pelPicker.setMode(E5PathPickerModes.SaveFileMode)
42 self.pelPicker.setDefaultDirectory(project.ppath)
43 self.pelPicker.setFilters(self.tr(
44 "Dictionary File (*.dic);;All Files (*)"))
44 45
45 self.project = project 46 self.project = project
46 self.parent = parent 47 self.parent = parent
47
48 self.pwlCompleter = E5FileCompleter(self.pwlEdit)
49 self.pelCompleter = E5FileCompleter(self.pelEdit)
50 48
51 from QScintilla.SpellChecker import SpellChecker 49 from QScintilla.SpellChecker import SpellChecker
52 self.spellingComboBox.addItem(self.tr("<default>")) 50 self.spellingComboBox.addItem(self.tr("<default>"))
53 self.spellingComboBox.addItems( 51 self.spellingComboBox.addItems(
54 sorted(SpellChecker.getAvailableLanguages())) 52 sorted(SpellChecker.getAvailableLanguages()))
67 self.project.pdata["SPELLLANGUAGE"][0]) 65 self.project.pdata["SPELLLANGUAGE"][0])
68 if index == -1: 66 if index == -1:
69 index = 0 67 index = 0
70 self.spellingComboBox.setCurrentIndex(index) 68 self.spellingComboBox.setCurrentIndex(index)
71 if self.project.pdata["SPELLWORDS"][0]: 69 if self.project.pdata["SPELLWORDS"][0]:
72 self.pwlEdit.setText(Utilities.toNativeSeparators( 70 self.pwlPicker.setText(self.project.pdata["SPELLWORDS"][0])
73 self.project.pdata["SPELLWORDS"][0]))
74 if self.project.pdata["SPELLEXCLUDES"][0]: 71 if self.project.pdata["SPELLEXCLUDES"][0]:
75 self.pelEdit.setText(Utilities.toNativeSeparators( 72 self.pelPicker.setText(self.project.pdata["SPELLEXCLUDES"][0])
76 self.project.pdata["SPELLEXCLUDES"][0]))
77
78 @pyqtSlot()
79 def on_pwlButton_clicked(self):
80 """
81 Private slot to select the project word list file.
82 """
83 pwl = Utilities.fromNativeSeparators(self.pwlEdit.text())
84 if not pwl:
85 pwl = self.project.ppath
86 elif not os.path.isabs(pwl):
87 pwl = Utilities.fromNativeSeparators(
88 os.path.join(self.project.ppath, pwl))
89 file = E5FileDialog.getOpenFileName(
90 self,
91 self.tr("Select project word list"),
92 pwl,
93 self.tr("Dictionary File (*.dic);;All Files (*)"))
94
95 if file:
96 self.pwlEdit.setText(self.project.getRelativePath(
97 Utilities.toNativeSeparators(file)))
98
99 @pyqtSlot()
100 def on_pelButton_clicked(self):
101 """
102 Private slot to select the project exclude list file.
103 """
104 pel = Utilities.fromNativeSeparators(self.pelEdit.text())
105 if not pel:
106 pel = self.project.ppath
107 elif not os.path.isabs(pel):
108 pel = Utilities.fromNativeSeparators(
109 os.path.join(self.project.ppath, pel))
110 file = E5FileDialog.getOpenFileName(
111 self,
112 self.tr("Select project exclude list"),
113 pel,
114 self.tr("Dictionary File (*.dic);;All Files (*)"))
115
116 if file:
117 self.pelEdit.setText(self.project.getRelativePath(
118 Utilities.toNativeSeparators(file)))
119 73
120 def storeData(self): 74 def storeData(self):
121 """ 75 """
122 Public method to store the entered/modified data. 76 Public method to store the entered/modified data.
123 """ 77 """
126 [Preferences.getEditor("SpellCheckingDefaultLanguage")] 80 [Preferences.getEditor("SpellCheckingDefaultLanguage")]
127 else: 81 else:
128 self.project.pdata["SPELLLANGUAGE"] = \ 82 self.project.pdata["SPELLLANGUAGE"] = \
129 [self.spellingComboBox.currentText()] 83 [self.spellingComboBox.currentText()]
130 self.project.pdata["SPELLWORDS"] = \ 84 self.project.pdata["SPELLWORDS"] = \
131 [self.project.getRelativePath(self.pwlEdit.text())] 85 [self.project.getRelativePath(self.pwlPicker.text())]
132 self.project.pdata["SPELLEXCLUDES"] = \ 86 self.project.pdata["SPELLEXCLUDES"] = \
133 [self.project.getRelativePath(self.pelEdit.text())] 87 [self.project.getRelativePath(self.pelPicker.text())]

eric ide

mercurial