108 Preferences.setEditor("EOLMode", QsciScintilla.EolWindows) |
114 Preferences.setEditor("EOLMode", QsciScintilla.EolWindows) |
109 elif self.crRadioButton.isChecked(): |
115 elif self.crRadioButton.isChecked(): |
110 Preferences.setEditor("EOLMode", QsciScintilla.EolMac) |
116 Preferences.setEditor("EOLMode", QsciScintilla.EolMac) |
111 elif self.lfRadioButton.isChecked(): |
117 elif self.lfRadioButton.isChecked(): |
112 Preferences.setEditor("EOLMode", QsciScintilla.EolUnix) |
118 Preferences.setEditor("EOLMode", QsciScintilla.EolUnix) |
|
119 |
|
120 self.__extractFileFilters() |
|
121 Preferences.setEditor("AdditionalOpenFilters", self.openFileFilters) |
|
122 Preferences.setEditor("AdditionalSaveFilters", self.saveFileFilters) |
|
123 |
|
124 def __setDefaultFiltersLists(self, keepSelection = False): |
|
125 """ |
|
126 Private slot to set the default file filter combo boxes. |
|
127 """ |
|
128 if keepSelection: |
|
129 selectedOpenFilter = self.openFilesFilterComboBox.currentText() |
|
130 selectedSaveFilter = self.saveFilesFilterComboBox.currentText() |
|
131 |
|
132 openFileFiltersList = \ |
|
133 QScintilla.Lexers.getOpenFileFiltersList(False, withAdditional = False) + \ |
|
134 self.openFileFilters |
|
135 openFileFiltersList.sort() |
|
136 self.openFilesFilterComboBox.addItems(openFileFiltersList) |
|
137 saveFileFiltersList = \ |
|
138 QScintilla.Lexers.getSaveFileFiltersList(False, withAdditional = False) + \ |
|
139 self.saveFileFilters |
|
140 saveFileFiltersList.sort() |
|
141 self.saveFilesFilterComboBox.addItems(saveFileFiltersList) |
|
142 |
|
143 if keepSelection: |
|
144 self.openFilesFilterComboBox.setCurrentIndex( |
|
145 self.openFilesFilterComboBox.findText(selectedOpenFilter)) |
|
146 self.saveFilesFilterComboBox.setCurrentIndex( |
|
147 self.saveFilesFilterComboBox.findText(selectedSaveFilter)) |
|
148 |
|
149 def __extractFileFilters(self): |
|
150 """ |
|
151 Private method to extract the file filters. |
|
152 """ |
|
153 filters = [] |
|
154 for row in range(self.fileFiltersList.count()): |
|
155 filters.append(self.fileFiltersList.item(row).text()) |
|
156 if self.__showsOpenFilters: |
|
157 self.openFileFilters = filters |
|
158 else: |
|
159 self.saveFileFilters = filters |
|
160 |
|
161 def __checkFileFilter(self, filter): |
|
162 """ |
|
163 Private method to check a file filter for validity. |
|
164 |
|
165 @param filter file filter pattern to check (string) |
|
166 @return flag indicating validity (boolean) |
|
167 """ |
|
168 if not self.__showsOpenFilters and \ |
|
169 filter.count("*") != 1: |
|
170 E5MessageBox.critical(self, |
|
171 self.trUtf8("Add File Filter"), |
|
172 self.trUtf8("""A Save File Filter must contain exactly one""" |
|
173 """ wildcard pattern. Yours contains {0}.""")\ |
|
174 .format(filter.count("*"))) |
|
175 return False |
|
176 |
|
177 if filter.count("*") == 0: |
|
178 E5MessageBox.critical(self, |
|
179 self.trUtf8("Add File Filter"), |
|
180 self.trUtf8("""A File Filter must contain at least one""" |
|
181 """ wildcard pattern.""")\ |
|
182 .format(filter.count("*"))) |
|
183 return False |
|
184 |
|
185 return True |
|
186 |
|
187 @pyqtSlot() |
|
188 def on_addFileFilterButton_clicked(self): |
|
189 """ |
|
190 Private slot to add a file filter to the list. |
|
191 """ |
|
192 filter, ok = QInputDialog.getText( |
|
193 self, |
|
194 self.trUtf8("Add File Filter"), |
|
195 self.trUtf8("Enter the file filter entry:"), |
|
196 QLineEdit.Normal) |
|
197 if ok and filter: |
|
198 if self.__checkFileFilter(filter): |
|
199 self.fileFiltersList.addItem(filter) |
|
200 self.__extractFileFilters() |
|
201 self.__setDefaultFiltersLists(keepSelection = True) |
|
202 |
|
203 @pyqtSlot() |
|
204 def on_editFileFilterButton_clicked(self): |
|
205 """ |
|
206 Slot documentation goes here. |
|
207 """ |
|
208 # TODO: not implemented yet |
|
209 raise NotImplementedError |
|
210 |
|
211 @pyqtSlot() |
|
212 def on_deleteFileFilterButton_clicked(self): |
|
213 """ |
|
214 Slot documentation goes here. |
|
215 """ |
|
216 # TODO: not implemented yet |
|
217 raise NotImplementedError |
|
218 |
|
219 @pyqtSlot(bool) |
|
220 def on_openFiltersButton_toggled(self, checked): |
|
221 """ |
|
222 Private slot to switch the list of file filters. |
|
223 """ |
|
224 self.__extractFileFilters() |
|
225 self.__showsOpenFilters = checked |
|
226 self.fileFiltersList.clear() |
|
227 if checked: |
|
228 self.fileFiltersList.addItems(self.openFileFilters) |
|
229 else: |
|
230 self.fileFiltersList.addItems(self.saveFileFilters) |
|
231 |
|
232 @pyqtSlot(QListWidgetItem, QListWidgetItem) |
|
233 def on_fileFiltersList_currentItemChanged(self, current, previous): |
|
234 """ |
|
235 Private slot to set the state of the edit and delete buttons. |
|
236 |
|
237 @param current new current item (QListWidgetItem) |
|
238 @param previous previous current item (QListWidgetItem) |
|
239 """ |
|
240 self.editFileFilterButton.setEnabled(current is not None) |
|
241 self.deleteFileFilterButton.setEnabled(current is not None) |
113 |
242 |
114 def create(dlg): |
243 def create(dlg): |
115 """ |
244 """ |
116 Module function to create the configuration page. |
245 Module function to create the configuration page. |
117 |
246 |