Preferences/ConfigurationPages/EditorStylesPage.py

changeset 2230
2b1b9265156c
parent 2164
d67b14a3f884
child 2261
f4bb5648fc29
equal deleted inserted replaced
2229:78539385a8df 2230:2b1b9265156c
44 self.edgeModes = [ 44 self.edgeModes = [
45 QsciScintilla.EdgeNone, 45 QsciScintilla.EdgeNone,
46 QsciScintilla.EdgeLine, 46 QsciScintilla.EdgeLine,
47 QsciScintilla.EdgeBackground 47 QsciScintilla.EdgeBackground
48 ] 48 ]
49
50 self.editorColours = {}
51 49
52 # set initial values 50 # set initial values
53 try: 51 try:
54 self.foldingStyleComboBox.setCurrentIndex( 52 self.foldingStyleComboBox.setCurrentIndex(
55 self.foldStyles.index(Preferences.getEditor("FoldingStyle"))) 53 self.foldStyles.index(Preferences.getEditor("FoldingStyle")))
81 self.customSelColourCheckBox.setChecked( 79 self.customSelColourCheckBox.setChecked(
82 Preferences.getEditor("CustomSelectionColours")) 80 Preferences.getEditor("CustomSelectionColours"))
83 self.extentSelEolCheckBox.setChecked( 81 self.extentSelEolCheckBox.setChecked(
84 Preferences.getEditor("ExtendSelectionToEol")) 82 Preferences.getEditor("ExtendSelectionToEol"))
85 83
86 self.editorColours["CaretForeground"] = \ 84 self.initColour("CaretForeground", self.caretForegroundButton,
87 self.initColour("CaretForeground", self.caretForegroundButton, 85 Preferences.getEditorColour)
88 Preferences.getEditorColour) 86 self.initColour("CaretLineBackground", self.caretlineBackgroundButton,
89 self.editorColours["CaretLineBackground"] = \ 87 Preferences.getEditorColour, hasAlpha=True)
90 self.initColour("CaretLineBackground", self.caretlineBackgroundButton, 88 self.initColour("SelectionForeground", self.selectionForegroundButton,
91 Preferences.getEditorColour) 89 Preferences.getEditorColour)
92 self.editorColours["SelectionForeground"] = \ 90 self.initColour("SelectionBackground", self.selectionBackgroundButton,
93 self.initColour("SelectionForeground", self.selectionForegroundButton, 91 Preferences.getEditorColour, hasAlpha=True)
94 Preferences.getEditorColour) 92 self.initColour("CurrentMarker", self.currentLineMarkerButton,
95 self.editorColours["SelectionBackground"] = \ 93 Preferences.getEditorColour, hasAlpha=True)
96 self.initColour("SelectionBackground", self.selectionBackgroundButton, 94 self.initColour("ErrorMarker", self.errorMarkerButton,
97 Preferences.getEditorColour) 95 Preferences.getEditorColour, hasAlpha=True)
98 self.editorColours["CurrentMarker"] = \ 96 self.initColour("MarginsForeground", self.marginsForegroundButton,
99 self.initColour("CurrentMarker", self.currentLineMarkerButton, 97 Preferences.getEditorColour)
100 Preferences.getEditorColour) 98 self.initColour("MarginsBackground", self.marginsBackgroundButton,
101 self.editorColours["ErrorMarker"] = \ 99 Preferences.getEditorColour)
102 self.initColour("ErrorMarker", self.errorMarkerButton, 100 self.initColour("FoldmarginBackground", self.foldmarginBackgroundButton,
103 Preferences.getEditorColour) 101 Preferences.getEditorColour)
104 self.editorColours["MarginsForeground"] = \ 102 self.initColour("FoldMarkersForeground", self.foldmarkersForegroundButton,
105 self.initColour("MarginsForeground", self.marginsForegroundButton, 103 Preferences.getEditorColour)
106 Preferences.getEditorColour) 104 self.initColour("FoldMarkersBackground", self.foldmarkersBackgroundButton,
107 self.editorColours["MarginsBackground"] = \ 105 Preferences.getEditorColour)
108 self.initColour("MarginsBackground", self.marginsBackgroundButton, 106
109 Preferences.getEditorColour) 107 self.editorColours = {}
110 self.editorColours["FoldmarginBackground"] = \
111 self.initColour("FoldmarginBackground", self.foldmarginBackgroundButton,
112 Preferences.getEditorColour)
113 self.editorColours["FoldMarkersForeground"] = \
114 self.initColour("FoldMarkersForeground", self.foldmarkersForegroundButton,
115 Preferences.getEditorColour)
116 self.editorColours["FoldMarkersBackground"] = \
117 self.initColour("FoldMarkersBackground", self.foldmarkersBackgroundButton,
118 Preferences.getEditorColour)
119
120 self.editorColours["AnnotationsWarningForeground"] = \ 108 self.editorColours["AnnotationsWarningForeground"] = \
121 QColor(Preferences.getEditorColour("AnnotationsWarningForeground")) 109 QColor(Preferences.getEditorColour("AnnotationsWarningForeground"))
122 self.editorColours["AnnotationsWarningBackground"] = \ 110 self.editorColours["AnnotationsWarningBackground"] = \
123 QColor(Preferences.getEditorColour("AnnotationsWarningBackground")) 111 QColor(Preferences.getEditorColour("AnnotationsWarningBackground"))
124 self.editorColours["AnnotationsErrorForeground"] = \ 112 self.editorColours["AnnotationsErrorForeground"] = \
132 120
133 self.edgeModeCombo.setCurrentIndex( 121 self.edgeModeCombo.setCurrentIndex(
134 self.edgeModes.index(Preferences.getEditor("EdgeMode"))) 122 self.edgeModes.index(Preferences.getEditor("EdgeMode")))
135 self.edgeLineColumnSlider.setValue( 123 self.edgeLineColumnSlider.setValue(
136 Preferences.getEditor("EdgeColumn")) 124 Preferences.getEditor("EdgeColumn"))
137 self.editorColours["Edge"] = \ 125 self.initColour("Edge", self.edgeBackgroundColorButton,
138 self.initColour("Edge", self.edgeBackgroundColorButton, 126 Preferences.getEditorColour)
139 Preferences.getEditorColour)
140 127
141 self.bracehighlightingCheckBox.setChecked( 128 self.bracehighlightingCheckBox.setChecked(
142 Preferences.getEditor("BraceHighlighting")) 129 Preferences.getEditor("BraceHighlighting"))
143 self.editorColours["MatchingBrace"] = \ 130 self.initColour("MatchingBrace", self.matchingBracesButton,
144 self.initColour("MatchingBrace", self.matchingBracesButton, 131 Preferences.getEditorColour)
145 Preferences.getEditorColour) 132 self.initColour("MatchingBraceBack", self.matchingBracesBackButton,
146 self.editorColours["MatchingBraceBack"] = \ 133 Preferences.getEditorColour)
147 self.initColour("MatchingBraceBack", self.matchingBracesBackButton, 134 self.initColour("NonmatchingBrace", self.nonmatchingBracesButton,
148 Preferences.getEditorColour) 135 Preferences.getEditorColour)
149 self.editorColours["NonmatchingBrace"] = \ 136 self.initColour("NonmatchingBraceBack", self.nonmatchingBracesBackButton,
150 self.initColour("NonmatchingBrace", self.nonmatchingBracesButton, 137 Preferences.getEditorColour)
151 Preferences.getEditorColour)
152 self.editorColours["NonmatchingBraceBack"] = \
153 self.initColour("NonmatchingBraceBack", self.nonmatchingBracesBackButton,
154 Preferences.getEditorColour)
155 138
156 self.zoomfactorSlider.setValue( 139 self.zoomfactorSlider.setValue(
157 Preferences.getEditor("ZoomFactor")) 140 Preferences.getEditor("ZoomFactor"))
158 141
159 self.whitespaceCheckBox.setChecked( 142 self.whitespaceCheckBox.setChecked(
160 Preferences.getEditor("ShowWhitespace")) 143 Preferences.getEditor("ShowWhitespace"))
161 self.whitespaceSizeSpinBox.setValue( 144 self.whitespaceSizeSpinBox.setValue(
162 Preferences.getEditor("WhitespaceSize")) 145 Preferences.getEditor("WhitespaceSize"))
163 self.editorColours["WhitespaceForeground"] = \ 146 self.initColour("WhitespaceForeground", self.whitespaceForegroundButton,
164 self.initColour("WhitespaceForeground", self.whitespaceForegroundButton, 147 Preferences.getEditorColour)
165 Preferences.getEditorColour) 148 self.initColour("WhitespaceBackground", self.whitespaceBackgroundButton,
166 self.editorColours["WhitespaceBackground"] = \ 149 Preferences.getEditorColour)
167 self.initColour("WhitespaceBackground", self.whitespaceBackgroundButton,
168 Preferences.getEditorColour)
169 if not hasattr(QsciScintilla, "setWhitespaceForegroundColor"): 150 if not hasattr(QsciScintilla, "setWhitespaceForegroundColor"):
170 self.whitespaceSizeSpinBox.setEnabled(False) 151 self.whitespaceSizeSpinBox.setEnabled(False)
171 self.whitespaceForegroundButton.setEnabled(False) 152 self.whitespaceForegroundButton.setEnabled(False)
172 self.whitespaceBackgroundButton.setEnabled(False) 153 self.whitespaceBackgroundButton.setEnabled(False)
173 154
177 self.enableAnnotationsCheckBox.setChecked( 158 self.enableAnnotationsCheckBox.setChecked(
178 Preferences.getEditor("AnnotationsEnabled")) 159 Preferences.getEditor("AnnotationsEnabled"))
179 160
180 self.editAreaOverrideCheckBox.setChecked( 161 self.editAreaOverrideCheckBox.setChecked(
181 Preferences.getEditor("OverrideEditAreaColours")) 162 Preferences.getEditor("OverrideEditAreaColours"))
182 self.editorColours["EditAreaForeground"] = \ 163 self.initColour("EditAreaForeground", self.editAreaForegroundButton,
183 self.initColour("EditAreaForeground", self.editAreaForegroundButton, 164 Preferences.getEditorColour)
184 Preferences.getEditorColour) 165 self.initColour("EditAreaBackground", self.editAreaBackgroundButton,
185 self.editorColours["EditAreaBackground"] = \ 166 Preferences.getEditorColour)
186 self.initColour("EditAreaBackground", self.editAreaBackgroundButton,
187 Preferences.getEditorColour)
188 167
189 self.enableChangeTraceCheckBox.setChecked( 168 self.enableChangeTraceCheckBox.setChecked(
190 Preferences.getEditor("OnlineChangeTrace")) 169 Preferences.getEditor("OnlineChangeTrace"))
191 self.changeTraceTimeoutSpinBox.setValue( 170 self.changeTraceTimeoutSpinBox.setValue(
192 Preferences.getEditor("OnlineChangeTraceInterval")) 171 Preferences.getEditor("OnlineChangeTraceInterval"))
193 self.editorColours["OnlineChangeTraceMarkerUnsaved"] = \ 172 self.initColour("OnlineChangeTraceMarkerUnsaved",
194 self.initColour("OnlineChangeTraceMarkerUnsaved", 173 self.changeMarkerUnsavedColorButton,
195 self.changeMarkerUnsavedColorButton, 174 Preferences.getEditorColour)
196 Preferences.getEditorColour) 175 self.initColour("OnlineChangeTraceMarkerSaved",
197 self.editorColours["OnlineChangeTraceMarkerSaved"] = \ 176 self.changeMarkerSavedColorButton,
198 self.initColour("OnlineChangeTraceMarkerSaved", 177 Preferences.getEditorColour)
199 self.changeMarkerSavedColorButton,
200 Preferences.getEditorColour)
201 178
202 def save(self): 179 def save(self):
203 """ 180 """
204 Public slot to save the Editor Styles configuration. 181 Public slot to save the Editor Styles configuration.
205 """ 182 """
264 Preferences.setEditor("OnlineChangeTrace", 241 Preferences.setEditor("OnlineChangeTrace",
265 self.enableChangeTraceCheckBox.isChecked()) 242 self.enableChangeTraceCheckBox.isChecked())
266 Preferences.setEditor("OnlineChangeTraceInterval", 243 Preferences.setEditor("OnlineChangeTraceInterval",
267 self.changeTraceTimeoutSpinBox.value()) 244 self.changeTraceTimeoutSpinBox.value())
268 245
246 self.saveColours(Preferences.setEditorColour)
269 for key in list(self.editorColours.keys()): 247 for key in list(self.editorColours.keys()):
270 Preferences.setEditorColour(key, self.editorColours[key]) 248 Preferences.setEditorColour(key, self.editorColours[key])
271 249
272 @pyqtSlot() 250 @pyqtSlot()
273 def on_linenumbersFontButton_clicked(self): 251 def on_linenumbersFontButton_clicked(self):
288 """ 266 """
289 Private method used to select the font to be used as the monospaced font. 267 Private method used to select the font to be used as the monospaced font.
290 """ 268 """
291 self.monospacedFont = \ 269 self.monospacedFont = \
292 self.selectFont(self.monospacedFontSample, self.monospacedFont) 270 self.selectFont(self.monospacedFontSample, self.monospacedFont)
293
294 @pyqtSlot()
295 def on_caretForegroundButton_clicked(self):
296 """
297 Private slot to set the foreground colour of the caret.
298 """
299 self.editorColours["CaretForeground"] = \
300 self.selectColour(self.caretForegroundButton,
301 self.editorColours["CaretForeground"])
302
303 @pyqtSlot()
304 def on_caretlineBackgroundButton_clicked(self):
305 """
306 Private slot to set the background colour of the caretline.
307 """
308 self.editorColours["CaretLineBackground"] = \
309 self.selectColour(self.caretlineBackgroundButton,
310 self.editorColours["CaretLineBackground"], True)
311
312 @pyqtSlot()
313 def on_selectionForegroundButton_clicked(self):
314 """
315 Private slot to set the foreground colour of the selection.
316 """
317 self.editorColours["SelectionForeground"] = \
318 self.selectColour(self.selectionForegroundButton,
319 self.editorColours["SelectionForeground"])
320
321 @pyqtSlot()
322 def on_selectionBackgroundButton_clicked(self):
323 """
324 Private slot to set the background colour of the selection.
325 """
326 self.editorColours["SelectionBackground"] = \
327 self.selectColour(self.selectionBackgroundButton,
328 self.editorColours["SelectionBackground"], True)
329
330 @pyqtSlot()
331 def on_currentLineMarkerButton_clicked(self):
332 """
333 Private slot to set the colour for the highlight of the current line.
334 """
335 self.editorColours["CurrentMarker"] = \
336 self.selectColour(self.currentLineMarkerButton,
337 self.editorColours["CurrentMarker"], True)
338
339 @pyqtSlot()
340 def on_errorMarkerButton_clicked(self):
341 """
342 Private slot to set the colour for the highlight of the error line.
343 """
344 self.editorColours["ErrorMarker"] = \
345 self.selectColour(self.errorMarkerButton,
346 self.editorColours["ErrorMarker"], True)
347
348 @pyqtSlot()
349 def on_marginsForegroundButton_clicked(self):
350 """
351 Private slot to set the foreground colour for the margins.
352 """
353 self.editorColours["MarginsForeground"] = \
354 self.selectColour(self.marginsForegroundButton,
355 self.editorColours["MarginsForeground"])
356
357 @pyqtSlot()
358 def on_marginsBackgroundButton_clicked(self):
359 """
360 Private slot to set the background colour for the margins.
361 """
362 self.editorColours["MarginsBackground"] = \
363 self.selectColour(self.marginsBackgroundButton,
364 self.editorColours["MarginsBackground"])
365
366 @pyqtSlot()
367 def on_foldmarginBackgroundButton_clicked(self):
368 """
369 Private slot to set the background colour for the foldmargin.
370 """
371 self.editorColours["FoldmarginBackground"] = \
372 self.selectColour(self.foldmarginBackgroundButton,
373 self.editorColours["FoldmarginBackground"])
374
375 @pyqtSlot()
376 def on_edgeBackgroundColorButton_clicked(self):
377 """
378 Private slot to set the colour for the edge background or line.
379 """
380 self.editorColours["Edge"] = \
381 self.selectColour(self.edgeBackgroundColorButton, self.editorColours["Edge"])
382
383 @pyqtSlot()
384 def on_matchingBracesButton_clicked(self):
385 """
386 Private slot to set the colour for highlighting matching braces.
387 """
388 self.editorColours["MatchingBrace"] = \
389 self.selectColour(self.matchingBracesButton,
390 self.editorColours["MatchingBrace"])
391
392 @pyqtSlot()
393 def on_matchingBracesBackButton_clicked(self):
394 """
395 Private slot to set the background colour for highlighting matching braces.
396 """
397 self.editorColours["MatchingBraceBack"] = \
398 self.selectColour(self.matchingBracesBackButton,
399 self.editorColours["MatchingBraceBack"])
400
401 @pyqtSlot()
402 def on_nonmatchingBracesButton_clicked(self):
403 """
404 Private slot to set the colour for highlighting nonmatching braces.
405 """
406 self.editorColours["NonmatchingBrace"] = \
407 self.selectColour(self.nonmatchingBracesButton,
408 self.editorColours["NonmatchingBrace"])
409
410 @pyqtSlot()
411 def on_nonmatchingBracesBackButton_clicked(self):
412 """
413 Private slot to set the background colour for highlighting nonmatching braces.
414 """
415 self.editorColours["NonmatchingBraceBack"] = \
416 self.selectColour(self.nonmatchingBracesBackButton,
417 self.editorColours["NonmatchingBraceBack"])
418
419 @pyqtSlot()
420 def on_foldmarkersForegroundButton_clicked(self):
421 """
422 Private slot to set the foreground colour for the foldmarkers.
423 """
424 self.editorColours["FoldMarkersForeground"] = \
425 self.selectColour(self.foldmarkersForegroundButton,
426 self.editorColours["FoldMarkersForeground"])
427
428 @pyqtSlot()
429 def on_foldmarkersBackgroundButton_clicked(self):
430 """
431 Private slot to set the background colour for the margins.
432 """
433 self.editorColours["FoldMarkersBackground"] = \
434 self.selectColour(self.foldmarkersBackgroundButton,
435 self.editorColours["FoldMarkersBackground"])
436 271
437 def polishPage(self): 272 def polishPage(self):
438 """ 273 """
439 Public slot to perform some polishing actions. 274 Public slot to perform some polishing actions.
440 """ 275 """
503 pl = self.annotationsErrorSample.palette() 338 pl = self.annotationsErrorSample.palette()
504 pl.setColor(QPalette.Base, colour) 339 pl.setColor(QPalette.Base, colour)
505 self.annotationsErrorSample.setPalette(pl) 340 self.annotationsErrorSample.setPalette(pl)
506 self.annotationsErrorSample.repaint() 341 self.annotationsErrorSample.repaint()
507 self.editorColours["AnnotationsErrorBackground"] = colour 342 self.editorColours["AnnotationsErrorBackground"] = colour
508
509 @pyqtSlot()
510 def on_whitespaceForegroundButton_clicked(self):
511 """
512 Private slot to set the foreground colour of visible whitespace.
513 """
514 self.editorColours["WhitespaceForeground"] = \
515 self.selectColour(self.whitespaceForegroundButton,
516 self.editorColours["WhitespaceForeground"])
517
518 @pyqtSlot()
519 def on_whitespaceBackgroundButton_clicked(self):
520 """
521 Private slot to set the background colour of visible whitespace.
522 """
523 self.editorColours["WhitespaceBackground"] = \
524 self.selectColour(self.whitespaceBackgroundButton,
525 self.editorColours["WhitespaceBackground"])
526
527 @pyqtSlot()
528 def on_editAreaForegroundButton_clicked(self):
529 """
530 Private slot to set the foreground colour of the edit area.
531 """
532 self.editorColours["EditAreaForeground"] = \
533 self.selectColour(self.editAreaForegroundButton,
534 self.editorColours["EditAreaForeground"])
535
536 @pyqtSlot()
537 def on_editAreaBackgroundButton_clicked(self):
538 """
539 Private slot to set the background colour of the edit area.
540 """
541 self.editorColours["EditAreaBackground"] = \
542 self.selectColour(self.editAreaBackgroundButton,
543 self.editorColours["EditAreaBackground"])
544
545 @pyqtSlot()
546 def on_changeMarkerUnsavedColorButton_clicked(self):
547 """
548 Private slot to set the colour of the change marker for unsaved changes.
549 """
550 self.editorColours["OnlineChangeTraceMarkerUnsaved"] = \
551 self.selectColour(self.changeMarkerUnsavedColorButton,
552 self.editorColours["OnlineChangeTraceMarkerUnsaved"])
553
554 @pyqtSlot()
555 def on_changeMarkerSavedColorButton_clicked(self):
556 """
557 Private slot to set the colour of the change marker for saved changes.
558 """
559 self.editorColours["OnlineChangeTraceMarkerSaved"] = \
560 self.selectColour(self.changeMarkerSavedColorButton,
561 self.editorColours["OnlineChangeTraceMarkerSaved"])
562 343
563 344
564 def create(dlg): 345 def create(dlg):
565 """ 346 """
566 Module function to create the configuration page. 347 Module function to create the configuration page.

eric ide

mercurial