|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2006 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the Editor Styles configuration page. |
|
8 """ |
|
9 |
|
10 from PyQt5.QtCore import pyqtSlot |
|
11 from PyQt5.QtGui import QColor, QPalette |
|
12 from PyQt5.QtWidgets import QColorDialog, QFontDialog |
|
13 from PyQt5.Qsci import QsciScintilla |
|
14 |
|
15 from .ConfigurationPageBase import ConfigurationPageBase |
|
16 from .Ui_EditorStylesPage import Ui_EditorStylesPage |
|
17 |
|
18 import Preferences |
|
19 |
|
20 try: |
|
21 MonospacedFontsOption = QFontDialog.FontDialogOption.MonospacedFonts |
|
22 except AttributeError: |
|
23 MonospacedFontsOption = QFontDialog.FontDialogOptions(0x10) |
|
24 |
|
25 |
|
26 class EditorStylesPage(ConfigurationPageBase, Ui_EditorStylesPage): |
|
27 """ |
|
28 Class implementing the Editor Styles configuration page. |
|
29 """ |
|
30 def __init__(self): |
|
31 """ |
|
32 Constructor |
|
33 """ |
|
34 super().__init__() |
|
35 self.setupUi(self) |
|
36 self.setObjectName("EditorStylesPage") |
|
37 |
|
38 from QScintilla.QsciScintillaCompat import QsciScintillaCompat |
|
39 |
|
40 self.foldStyles = [ |
|
41 QsciScintilla.FoldStyle.PlainFoldStyle, |
|
42 QsciScintilla.FoldStyle.CircledFoldStyle, |
|
43 QsciScintilla.FoldStyle.BoxedFoldStyle, |
|
44 QsciScintilla.FoldStyle.CircledTreeFoldStyle, |
|
45 QsciScintilla.FoldStyle.BoxedTreeFoldStyle, |
|
46 QsciScintillaCompat.ArrowFoldStyle, |
|
47 QsciScintillaCompat.ArrowTreeFoldStyle, |
|
48 ] |
|
49 |
|
50 self.edgeModes = [ |
|
51 QsciScintilla.EdgeMode.EdgeNone, |
|
52 QsciScintilla.EdgeMode.EdgeLine, |
|
53 QsciScintilla.EdgeMode.EdgeBackground |
|
54 ] |
|
55 |
|
56 self.wrapModeComboBox.addItem( |
|
57 self.tr("Disabled"), |
|
58 QsciScintilla.WrapMode.WrapNone) |
|
59 self.wrapModeComboBox.addItem( |
|
60 self.tr("Word Boundary"), |
|
61 QsciScintilla.WrapMode.WrapWord) |
|
62 self.wrapModeComboBox.addItem( |
|
63 self.tr("Character Boundary"), |
|
64 QsciScintilla.WrapMode.WrapCharacter) |
|
65 self.wrapVisualComboBox.addItem( |
|
66 self.tr("No Indicator"), |
|
67 QsciScintilla.WrapVisualFlag.WrapFlagNone) |
|
68 self.wrapVisualComboBox.addItem( |
|
69 self.tr("Indicator by Text"), |
|
70 QsciScintilla.WrapVisualFlag.WrapFlagByText) |
|
71 self.wrapVisualComboBox.addItem( |
|
72 self.tr("Indicator by Margin"), |
|
73 QsciScintilla.WrapVisualFlag.WrapFlagByBorder) |
|
74 self.wrapVisualComboBox.addItem( |
|
75 self.tr("Indicator in Line Number Margin"), |
|
76 QsciScintilla.WrapVisualFlag.WrapFlagInMargin) |
|
77 |
|
78 self.wrapIndentComboBox.addItem( |
|
79 self.tr("Fixed"), QsciScintilla.WrapIndentMode.WrapIndentFixed) |
|
80 self.wrapIndentComboBox.addItem( |
|
81 self.tr("Aligned"), QsciScintilla.WrapIndentMode.WrapIndentSame) |
|
82 self.wrapIndentComboBox.addItem( |
|
83 self.tr("Aligned plus One"), |
|
84 QsciScintilla.WrapIndentMode.WrapIndentIndented) |
|
85 self.wrapIndentComboBox.addItem( |
|
86 self.tr("Aligned plus Two"), |
|
87 QsciScintilla.WrapIndentMode.WrapIndentDeeplyIndented) |
|
88 |
|
89 # set initial values |
|
90 try: |
|
91 self.foldingStyleComboBox.setCurrentIndex( |
|
92 self.foldStyles.index(Preferences.getEditor("FoldingStyle"))) |
|
93 except ValueError: |
|
94 self.foldingStyleComboBox.setCurrentIndex(0) |
|
95 self.marginsFont = Preferences.getEditorOtherFonts("MarginsFont") |
|
96 self.marginsFontSample.setFont(self.marginsFont) |
|
97 self.defaultFont = Preferences.getEditorOtherFonts("DefaultFont") |
|
98 self.defaultFontSample.setFont(self.defaultFont) |
|
99 self.monospacedFont = Preferences.getEditorOtherFonts("MonospacedFont") |
|
100 self.monospacedFontSample.setFont(self.monospacedFont) |
|
101 self.monospacedCheckBox.setChecked( |
|
102 Preferences.getEditor("UseMonospacedFont")) |
|
103 self.linenoCheckBox.setChecked( |
|
104 Preferences.getEditor("LinenoMargin")) |
|
105 self.foldingCheckBox.setChecked( |
|
106 Preferences.getEditor("FoldingMargin")) |
|
107 |
|
108 self.caretlineVisibleCheckBox.setChecked( |
|
109 Preferences.getEditor("CaretLineVisible")) |
|
110 self.caretlineAlwaysVisibleCheckBox.setChecked( |
|
111 Preferences.getEditor("CaretLineAlwaysVisible")) |
|
112 self.caretWidthSpinBox.setValue( |
|
113 Preferences.getEditor("CaretWidth")) |
|
114 self.caretlineFrameWidthSpinBox.setValue( |
|
115 Preferences.getEditor("CaretLineFrameWidth")) |
|
116 self.colourizeSelTextCheckBox.setChecked( |
|
117 Preferences.getEditor("ColourizeSelText")) |
|
118 self.customSelColourCheckBox.setChecked( |
|
119 Preferences.getEditor("CustomSelectionColours")) |
|
120 self.extentSelEolCheckBox.setChecked( |
|
121 Preferences.getEditor("ExtendSelectionToEol")) |
|
122 self.debugMarkerBackgroundCheckBox.setChecked( |
|
123 Preferences.getEditor("LineMarkersBackground")) |
|
124 |
|
125 self.initColour("CaretForeground", self.caretForegroundButton, |
|
126 Preferences.getEditorColour) |
|
127 self.initColour("CaretLineBackground", self.caretlineBackgroundButton, |
|
128 Preferences.getEditorColour, hasAlpha=True) |
|
129 self.initColour("SelectionForeground", self.selectionForegroundButton, |
|
130 Preferences.getEditorColour) |
|
131 self.initColour("SelectionBackground", self.selectionBackgroundButton, |
|
132 Preferences.getEditorColour, hasAlpha=True) |
|
133 self.initColour("CurrentMarker", self.currentLineMarkerButton, |
|
134 Preferences.getEditorColour, hasAlpha=True) |
|
135 self.initColour("ErrorMarker", self.errorMarkerButton, |
|
136 Preferences.getEditorColour, hasAlpha=True) |
|
137 self.initColour("MarginsForeground", self.marginsForegroundButton, |
|
138 Preferences.getEditorColour) |
|
139 self.initColour("MarginsBackground", self.marginsBackgroundButton, |
|
140 Preferences.getEditorColour) |
|
141 self.initColour("FoldmarginBackground", |
|
142 self.foldmarginBackgroundButton, |
|
143 Preferences.getEditorColour) |
|
144 self.initColour("FoldMarkersForeground", |
|
145 self.foldmarkersForegroundButton, |
|
146 Preferences.getEditorColour) |
|
147 self.initColour("FoldMarkersBackground", |
|
148 self.foldmarkersBackgroundButton, |
|
149 Preferences.getEditorColour) |
|
150 |
|
151 self.editorColours = {} |
|
152 self.editorColours["AnnotationsWarningForeground"] = QColor( |
|
153 Preferences.getEditorColour("AnnotationsWarningForeground")) |
|
154 self.editorColours["AnnotationsWarningBackground"] = QColor( |
|
155 Preferences.getEditorColour("AnnotationsWarningBackground")) |
|
156 self.editorColours["AnnotationsErrorForeground"] = QColor( |
|
157 Preferences.getEditorColour("AnnotationsErrorForeground")) |
|
158 self.editorColours["AnnotationsErrorBackground"] = QColor( |
|
159 Preferences.getEditorColour("AnnotationsErrorBackground")) |
|
160 self.editorColours["AnnotationsStyleForeground"] = QColor( |
|
161 Preferences.getEditorColour("AnnotationsStyleForeground")) |
|
162 self.editorColours["AnnotationsStyleBackground"] = QColor( |
|
163 Preferences.getEditorColour("AnnotationsStyleBackground")) |
|
164 |
|
165 self.eolCheckBox.setChecked(Preferences.getEditor("ShowEOL")) |
|
166 self.wrapModeComboBox.setCurrentIndex(self.wrapModeComboBox.findData( |
|
167 Preferences.getEditor("WrapLongLinesMode"))) |
|
168 self.wrapVisualComboBox.setCurrentIndex( |
|
169 self.wrapVisualComboBox.findData( |
|
170 Preferences.getEditor("WrapVisualFlag"))) |
|
171 self.wrapIndentComboBox.setCurrentIndex( |
|
172 self.wrapIndentComboBox.findData( |
|
173 Preferences.getEditor("WrapIndentMode"))) |
|
174 self.wrapStartIndentSpinBox.setValue( |
|
175 Preferences.getEditor("WrapStartIndent")) |
|
176 |
|
177 self.edgeModeCombo.setCurrentIndex( |
|
178 self.edgeModes.index(Preferences.getEditor("EdgeMode"))) |
|
179 self.edgeLineColumnSlider.setValue( |
|
180 Preferences.getEditor("EdgeColumn")) |
|
181 self.initColour( |
|
182 "Edge", self.edgeBackgroundColorButton, |
|
183 Preferences.getEditorColour) |
|
184 |
|
185 self.bracehighlightingCheckBox.setChecked( |
|
186 Preferences.getEditor("BraceHighlighting")) |
|
187 self.initColour("MatchingBrace", self.matchingBracesButton, |
|
188 Preferences.getEditorColour) |
|
189 self.initColour("MatchingBraceBack", self.matchingBracesBackButton, |
|
190 Preferences.getEditorColour) |
|
191 self.initColour("NonmatchingBrace", self.nonmatchingBracesButton, |
|
192 Preferences.getEditorColour) |
|
193 self.initColour("NonmatchingBraceBack", |
|
194 self.nonmatchingBracesBackButton, |
|
195 Preferences.getEditorColour) |
|
196 |
|
197 self.zoomfactorSlider.setValue( |
|
198 Preferences.getEditor("ZoomFactor")) |
|
199 |
|
200 self.whitespaceCheckBox.setChecked( |
|
201 Preferences.getEditor("ShowWhitespace")) |
|
202 self.whitespaceSizeSpinBox.setValue( |
|
203 Preferences.getEditor("WhitespaceSize")) |
|
204 self.initColour("WhitespaceForeground", |
|
205 self.whitespaceForegroundButton, |
|
206 Preferences.getEditorColour) |
|
207 self.initColour("WhitespaceBackground", |
|
208 self.whitespaceBackgroundButton, |
|
209 Preferences.getEditorColour) |
|
210 if not hasattr(QsciScintilla, "setWhitespaceForegroundColor"): |
|
211 self.whitespaceSizeSpinBox.setEnabled(False) |
|
212 self.whitespaceForegroundButton.setEnabled(False) |
|
213 self.whitespaceBackgroundButton.setEnabled(False) |
|
214 |
|
215 self.miniMenuCheckBox.setChecked( |
|
216 Preferences.getEditor("MiniContextMenu")) |
|
217 self.hideFormatButtonsCheckBox.setChecked( |
|
218 Preferences.getEditor("HideFormatButtons")) |
|
219 |
|
220 self.enableAnnotationsCheckBox.setChecked( |
|
221 Preferences.getEditor("AnnotationsEnabled")) |
|
222 |
|
223 self.editAreaOverrideCheckBox.setChecked( |
|
224 Preferences.getEditor("OverrideEditAreaColours")) |
|
225 self.initColour( |
|
226 "EditAreaForeground", self.editAreaForegroundButton, |
|
227 Preferences.getEditorColour) |
|
228 self.initColour( |
|
229 "EditAreaBackground", self.editAreaBackgroundButton, |
|
230 Preferences.getEditorColour) |
|
231 |
|
232 self.enableChangeTraceCheckBox.setChecked( |
|
233 Preferences.getEditor("OnlineChangeTrace")) |
|
234 self.changeTraceTimeoutSpinBox.setValue( |
|
235 Preferences.getEditor("OnlineChangeTraceInterval")) |
|
236 self.initColour("OnlineChangeTraceMarkerUnsaved", |
|
237 self.changeMarkerUnsavedColorButton, |
|
238 Preferences.getEditorColour) |
|
239 self.initColour("OnlineChangeTraceMarkerSaved", |
|
240 self.changeMarkerSavedColorButton, |
|
241 Preferences.getEditorColour) |
|
242 |
|
243 self.markerMapRightCheckBox.setChecked( |
|
244 Preferences.getEditor("ShowMarkerMapOnRight")) |
|
245 self.initColour("BookmarksMap", |
|
246 self.bookmarksMapButton, |
|
247 Preferences.getEditorColour) |
|
248 self.initColour("ErrorsMap", |
|
249 self.errorsMapButton, |
|
250 Preferences.getEditorColour) |
|
251 self.initColour("WarningsMap", |
|
252 self.warningsMapButton, |
|
253 Preferences.getEditorColour) |
|
254 self.initColour("BreakpointsMap", |
|
255 self.breakpointsMapButton, |
|
256 Preferences.getEditorColour) |
|
257 self.initColour("TasksMap", |
|
258 self.tasksMapButton, |
|
259 Preferences.getEditorColour) |
|
260 self.initColour("CoverageMap", |
|
261 self.coverageMapButton, |
|
262 Preferences.getEditorColour) |
|
263 self.initColour("ChangesMap", |
|
264 self.changesMapButton, |
|
265 Preferences.getEditorColour) |
|
266 self.initColour("CurrentMap", |
|
267 self.currentMapButton, |
|
268 Preferences.getEditorColour) |
|
269 self.initColour("SearchMarkersMap", |
|
270 self.searchMarkerMapButton, |
|
271 Preferences.getEditorColour) |
|
272 self.initColour("VcsConflictMarkersMap", |
|
273 self.conflictMarkerMapButton, |
|
274 Preferences.getEditorColour) |
|
275 self.initColour("MarkerMapBackground", |
|
276 self.markerMapBackgroundButton, |
|
277 Preferences.getEditorColour) |
|
278 self.changesMarkerCheckBox.setChecked( |
|
279 Preferences.getEditor("ShowMarkerChanges")) |
|
280 self.coverageMarkerCheckBox.setChecked( |
|
281 Preferences.getEditor("ShowMarkerCoverage")) |
|
282 self.searchMarkerCheckBox.setChecked( |
|
283 Preferences.getEditor("ShowMarkerSearch")) |
|
284 |
|
285 self.indentguidesCheckBox.setChecked( |
|
286 Preferences.getEditor("IndentationGuides")) |
|
287 self.initColour("IndentationGuidesBackground", |
|
288 self.indentationGuidesBackgroundButton, |
|
289 Preferences.getEditorColour) |
|
290 self.initColour("IndentationGuidesForeground", |
|
291 self.indentationGuidesForegroundButton, |
|
292 Preferences.getEditorColour) |
|
293 |
|
294 self.initColour("HighlightMarker", |
|
295 self.highlightingBackgroundButton, |
|
296 Preferences.getEditorColour, |
|
297 hasAlpha=True) |
|
298 |
|
299 def save(self): |
|
300 """ |
|
301 Public slot to save the Editor Styles configuration. |
|
302 """ |
|
303 Preferences.setEditor( |
|
304 "FoldingStyle", |
|
305 self.foldStyles[self.foldingStyleComboBox.currentIndex()]) |
|
306 Preferences.setEditorOtherFonts( |
|
307 "MarginsFont", self.marginsFont) |
|
308 Preferences.setEditorOtherFonts( |
|
309 "DefaultFont", self.defaultFont) |
|
310 Preferences.setEditorOtherFonts( |
|
311 "MonospacedFont", self.monospacedFont) |
|
312 Preferences.setEditor( |
|
313 "UseMonospacedFont", self.monospacedCheckBox.isChecked()) |
|
314 |
|
315 Preferences.setEditor( |
|
316 "LinenoMargin", self.linenoCheckBox.isChecked()) |
|
317 Preferences.setEditor( |
|
318 "FoldingMargin", self.foldingCheckBox.isChecked()) |
|
319 |
|
320 Preferences.setEditor( |
|
321 "CaretLineVisible", self.caretlineVisibleCheckBox.isChecked()) |
|
322 Preferences.setEditor( |
|
323 "CaretLineAlwaysVisible", |
|
324 self.caretlineAlwaysVisibleCheckBox.isChecked()) |
|
325 Preferences.setEditor( |
|
326 "ColourizeSelText", self.colourizeSelTextCheckBox.isChecked()) |
|
327 Preferences.setEditor( |
|
328 "CustomSelectionColours", self.customSelColourCheckBox.isChecked()) |
|
329 Preferences.setEditor( |
|
330 "ExtendSelectionToEol", self.extentSelEolCheckBox.isChecked()) |
|
331 Preferences.setEditor( |
|
332 "LineMarkersBackground", |
|
333 self.debugMarkerBackgroundCheckBox.isChecked()) |
|
334 |
|
335 Preferences.setEditor( |
|
336 "CaretWidth", self.caretWidthSpinBox.value()) |
|
337 Preferences.setEditor( |
|
338 "CaretLineFrameWidth", self.caretlineFrameWidthSpinBox.value()) |
|
339 |
|
340 Preferences.setEditor( |
|
341 "ShowEOL", self.eolCheckBox.isChecked()) |
|
342 Preferences.setEditor( |
|
343 "WrapLongLinesMode", self.wrapModeComboBox.itemData( |
|
344 self.wrapModeComboBox.currentIndex())) |
|
345 Preferences.setEditor( |
|
346 "WrapVisualFlag", self.wrapVisualComboBox.itemData( |
|
347 self.wrapVisualComboBox.currentIndex())) |
|
348 Preferences.setEditor( |
|
349 "WrapIndentMode", self.wrapIndentComboBox.itemData( |
|
350 self.wrapIndentComboBox.currentIndex())) |
|
351 Preferences.setEditor( |
|
352 "WrapStartIndent", self.wrapStartIndentSpinBox.value()) |
|
353 Preferences.setEditor( |
|
354 "EdgeMode", self.edgeModes[self.edgeModeCombo.currentIndex()]) |
|
355 Preferences.setEditor( |
|
356 "EdgeColumn", self.edgeLineColumnSlider.value()) |
|
357 |
|
358 Preferences.setEditor( |
|
359 "BraceHighlighting", self.bracehighlightingCheckBox.isChecked()) |
|
360 |
|
361 Preferences.setEditor( |
|
362 "ZoomFactor", self.zoomfactorSlider.value()) |
|
363 |
|
364 Preferences.setEditor( |
|
365 "ShowWhitespace", self.whitespaceCheckBox.isChecked()) |
|
366 Preferences.setEditor( |
|
367 "WhitespaceSize", self.whitespaceSizeSpinBox.value()) |
|
368 |
|
369 Preferences.setEditor( |
|
370 "MiniContextMenu", self.miniMenuCheckBox.isChecked()) |
|
371 Preferences.setEditor( |
|
372 "HideFormatButtons", self.hideFormatButtonsCheckBox.isChecked()) |
|
373 |
|
374 Preferences.setEditor( |
|
375 "AnnotationsEnabled", self.enableAnnotationsCheckBox.isChecked()) |
|
376 |
|
377 Preferences.setEditor( |
|
378 "OverrideEditAreaColours", |
|
379 self.editAreaOverrideCheckBox.isChecked()) |
|
380 |
|
381 Preferences.setEditor( |
|
382 "OnlineChangeTrace", self.enableChangeTraceCheckBox.isChecked()) |
|
383 Preferences.setEditor( |
|
384 "OnlineChangeTraceInterval", |
|
385 self.changeTraceTimeoutSpinBox.value()) |
|
386 |
|
387 Preferences.setEditor( |
|
388 "IndentationGuides", |
|
389 self.indentguidesCheckBox.isChecked()) |
|
390 |
|
391 Preferences.setEditor( |
|
392 "ShowMarkerMapOnRight", |
|
393 self.markerMapRightCheckBox.isChecked()) |
|
394 Preferences.setEditor( |
|
395 "ShowMarkerChanges", |
|
396 self.changesMarkerCheckBox.isChecked()) |
|
397 Preferences.setEditor( |
|
398 "ShowMarkerCoverage", |
|
399 self.coverageMarkerCheckBox.isChecked()) |
|
400 Preferences.setEditor( |
|
401 "ShowMarkerSearch", |
|
402 self.searchMarkerCheckBox.isChecked()) |
|
403 |
|
404 self.saveColours(Preferences.setEditorColour) |
|
405 for key in list(self.editorColours.keys()): |
|
406 Preferences.setEditorColour(key, self.editorColours[key]) |
|
407 |
|
408 @pyqtSlot() |
|
409 def on_linenumbersFontButton_clicked(self): |
|
410 """ |
|
411 Private method used to select the font for the editor margins. |
|
412 """ |
|
413 self.marginsFont = self.selectFont( |
|
414 self.marginsFontSample, self.marginsFont, |
|
415 options=MonospacedFontsOption) |
|
416 |
|
417 @pyqtSlot() |
|
418 def on_defaultFontButton_clicked(self): |
|
419 """ |
|
420 Private method used to select the default font for the editor. |
|
421 """ |
|
422 self.defaultFont = self.selectFont( |
|
423 self.defaultFontSample, self.defaultFont) |
|
424 |
|
425 @pyqtSlot() |
|
426 def on_monospacedFontButton_clicked(self): |
|
427 """ |
|
428 Private method used to select the font to be used as the monospaced |
|
429 font. |
|
430 """ |
|
431 self.monospacedFont = self.selectFont( |
|
432 self.monospacedFontSample, self.monospacedFont, |
|
433 options=MonospacedFontsOption) |
|
434 |
|
435 def polishPage(self): |
|
436 """ |
|
437 Public slot to perform some polishing actions. |
|
438 """ |
|
439 self.marginsFontSample.setFont(self.marginsFont) |
|
440 self.defaultFontSample.setFont(self.defaultFont) |
|
441 self.monospacedFontSample.setFont(self.monospacedFont) |
|
442 |
|
443 pl = self.annotationsWarningSample.palette() |
|
444 pl.setColor(QPalette.ColorRole.Text, |
|
445 self.editorColours["AnnotationsWarningForeground"]) |
|
446 pl.setColor(QPalette.ColorRole.Base, |
|
447 self.editorColours["AnnotationsWarningBackground"]) |
|
448 self.annotationsWarningSample.setPalette(pl) |
|
449 self.annotationsWarningSample.repaint() |
|
450 |
|
451 pl = self.annotationsErrorSample.palette() |
|
452 pl.setColor(QPalette.ColorRole.Text, |
|
453 self.editorColours["AnnotationsErrorForeground"]) |
|
454 pl.setColor(QPalette.ColorRole.Base, |
|
455 self.editorColours["AnnotationsErrorBackground"]) |
|
456 self.annotationsErrorSample.setPalette(pl) |
|
457 self.annotationsErrorSample.repaint() |
|
458 |
|
459 pl = self.annotationsStyleWarningSample.palette() |
|
460 pl.setColor(QPalette.ColorRole.Text, |
|
461 self.editorColours["AnnotationsStyleForeground"]) |
|
462 pl.setColor(QPalette.ColorRole.Base, |
|
463 self.editorColours["AnnotationsStyleBackground"]) |
|
464 self.annotationsStyleWarningSample.setPalette(pl) |
|
465 self.annotationsStyleWarningSample.repaint() |
|
466 |
|
467 @pyqtSlot() |
|
468 def on_annotationsWarningFgButton_clicked(self): |
|
469 """ |
|
470 Private slot to set the foreground colour of the warning annotations. |
|
471 """ |
|
472 colour = QColorDialog.getColor( |
|
473 self.editorColours["AnnotationsWarningForeground"]) |
|
474 if colour.isValid(): |
|
475 pl = self.annotationsWarningSample.palette() |
|
476 pl.setColor(QPalette.ColorRole.Text, colour) |
|
477 self.annotationsWarningSample.setPalette(pl) |
|
478 self.annotationsWarningSample.repaint() |
|
479 self.editorColours["AnnotationsWarningForeground"] = colour |
|
480 |
|
481 @pyqtSlot() |
|
482 def on_annotationsWarningBgButton_clicked(self): |
|
483 """ |
|
484 Private slot to set the background colour of the warning annotations. |
|
485 """ |
|
486 colour = QColorDialog.getColor( |
|
487 self.editorColours["AnnotationsWarningBackground"]) |
|
488 if colour.isValid(): |
|
489 pl = self.annotationsWarningSample.palette() |
|
490 pl.setColor(QPalette.ColorRole.Base, colour) |
|
491 self.annotationsWarningSample.setPalette(pl) |
|
492 self.annotationsWarningSample.repaint() |
|
493 self.editorColours["AnnotationsWarningBackground"] = colour |
|
494 |
|
495 @pyqtSlot() |
|
496 def on_annotationsErrorFgButton_clicked(self): |
|
497 """ |
|
498 Private slot to set the foreground colour of the error annotations. |
|
499 """ |
|
500 colour = QColorDialog.getColor( |
|
501 self.editorColours["AnnotationsErrorForeground"]) |
|
502 if colour.isValid(): |
|
503 pl = self.annotationsErrorSample.palette() |
|
504 pl.setColor(QPalette.ColorRole.Text, colour) |
|
505 self.annotationsErrorSample.setPalette(pl) |
|
506 self.annotationsErrorSample.repaint() |
|
507 self.editorColours["AnnotationsErrorForeground"] = colour |
|
508 |
|
509 @pyqtSlot() |
|
510 def on_annotationsErrorBgButton_clicked(self): |
|
511 """ |
|
512 Private slot to set the background colour of the error annotations. |
|
513 """ |
|
514 colour = QColorDialog.getColor( |
|
515 self.editorColours["AnnotationsErrorBackground"]) |
|
516 if colour.isValid(): |
|
517 pl = self.annotationsErrorSample.palette() |
|
518 pl.setColor(QPalette.ColorRole.Base, colour) |
|
519 self.annotationsErrorSample.setPalette(pl) |
|
520 self.annotationsErrorSample.repaint() |
|
521 self.editorColours["AnnotationsErrorBackground"] = colour |
|
522 |
|
523 @pyqtSlot() |
|
524 def on_annotationsStyleWarningFgButton_clicked(self): |
|
525 """ |
|
526 Private slot to set the foreground colour of the style annotations. |
|
527 """ |
|
528 colour = QColorDialog.getColor( |
|
529 self.editorColours["AnnotationsStyleForeground"]) |
|
530 if colour.isValid(): |
|
531 pl = self.annotationsStyleWarningSample.palette() |
|
532 pl.setColor(QPalette.ColorRole.Text, colour) |
|
533 self.annotationsStyleWarningSample.setPalette(pl) |
|
534 self.annotationsStyleWarningSample.repaint() |
|
535 self.editorColours["AnnotationsStyleForeground"] = colour |
|
536 |
|
537 @pyqtSlot() |
|
538 def on_annotationsStyleWarningBgButton_clicked(self): |
|
539 """ |
|
540 Private slot to set the background colour of the style annotations. |
|
541 """ |
|
542 colour = QColorDialog.getColor( |
|
543 self.editorColours["AnnotationsStyleBackground"]) |
|
544 if colour.isValid(): |
|
545 pl = self.annotationsStyleWarningSample.palette() |
|
546 pl.setColor(QPalette.ColorRole.Base, colour) |
|
547 self.annotationsStyleWarningSample.setPalette(pl) |
|
548 self.annotationsStyleWarningSample.repaint() |
|
549 self.editorColours["AnnotationsStyleackground"] = colour |
|
550 |
|
551 |
|
552 def create(dlg): |
|
553 """ |
|
554 Module function to create the configuration page. |
|
555 |
|
556 @param dlg reference to the configuration dialog |
|
557 @return reference to the instantiated page (ConfigurationPageBase) |
|
558 """ |
|
559 page = EditorStylesPage() |
|
560 return page |