6 """ |
6 """ |
7 Module implementing the Editor Styles configuration page. |
7 Module implementing the Editor Styles configuration page. |
8 """ |
8 """ |
9 |
9 |
10 from PyQt4.QtCore import pyqtSlot |
10 from PyQt4.QtCore import pyqtSlot |
|
11 from PyQt4.QtGui import QColor, QPalette, QColorDialog |
11 from PyQt4.Qsci import QsciScintilla |
12 from PyQt4.Qsci import QsciScintilla |
12 |
13 |
13 from QScintilla.QsciScintillaCompat import QsciScintillaCompat |
14 from QScintilla.QsciScintillaCompat import QsciScintillaCompat |
14 |
15 |
15 from .ConfigurationPageBase import ConfigurationPageBase |
16 from .ConfigurationPageBase import ConfigurationPageBase |
113 Preferences.getEditorColour) |
114 Preferences.getEditorColour) |
114 self.editorColours["FoldMarkersBackground"] = \ |
115 self.editorColours["FoldMarkersBackground"] = \ |
115 self.initColour("FoldMarkersBackground", self.foldmarkersBackgroundButton, |
116 self.initColour("FoldMarkersBackground", self.foldmarkersBackgroundButton, |
116 Preferences.getEditorColour) |
117 Preferences.getEditorColour) |
117 |
118 |
|
119 self.editorColours["AnnotationsWarningForeground"] = \ |
|
120 QColor(Preferences.getEditorColour("AnnotationsWarningForeground")) |
|
121 self.editorColours["AnnotationsWarningBackground"] = \ |
|
122 QColor(Preferences.getEditorColour("AnnotationsWarningBackground")) |
|
123 self.editorColours["AnnotationsErrorForeground"] = \ |
|
124 QColor(Preferences.getEditorColour("AnnotationsErrorForeground")) |
|
125 self.editorColours["AnnotationsErrorBackground"] = \ |
|
126 QColor(Preferences.getEditorColour("AnnotationsErrorBackground")) |
|
127 |
118 self.eolCheckBox.setChecked(Preferences.getEditor("ShowEOL")) |
128 self.eolCheckBox.setChecked(Preferences.getEditor("ShowEOL")) |
119 self.wrapLongLinesCheckBox.setChecked( |
129 self.wrapLongLinesCheckBox.setChecked( |
120 Preferences.getEditor("WrapLongLines")) |
130 Preferences.getEditor("WrapLongLines")) |
121 |
131 |
122 self.edgeModeCombo.setCurrentIndex( |
132 self.edgeModeCombo.setCurrentIndex( |
147 |
157 |
148 self.whitespaceCheckBox.setChecked( |
158 self.whitespaceCheckBox.setChecked( |
149 Preferences.getEditor("ShowWhitespace")) |
159 Preferences.getEditor("ShowWhitespace")) |
150 self.miniMenuCheckBox.setChecked( |
160 self.miniMenuCheckBox.setChecked( |
151 Preferences.getEditor("MiniContextMenu")) |
161 Preferences.getEditor("MiniContextMenu")) |
|
162 |
|
163 self.enableAnnotationsCheckBox.setChecked( |
|
164 Preferences.getEditor("AnnotationsEnabled")) |
152 |
165 |
153 def save(self): |
166 def save(self): |
154 """ |
167 """ |
155 Public slot to save the Editor Styles configuration. |
168 Public slot to save the Editor Styles configuration. |
156 """ |
169 """ |
201 Preferences.setEditor("ShowWhitespace", |
214 Preferences.setEditor("ShowWhitespace", |
202 self.whitespaceCheckBox.isChecked()) |
215 self.whitespaceCheckBox.isChecked()) |
203 Preferences.setEditor("MiniContextMenu", |
216 Preferences.setEditor("MiniContextMenu", |
204 self.miniMenuCheckBox.isChecked()) |
217 self.miniMenuCheckBox.isChecked()) |
205 |
218 |
|
219 Preferences.setEditor("AnnotationsEnabled", |
|
220 self.enableAnnotationsCheckBox.isChecked()) |
|
221 |
206 for key in list(self.editorColours.keys()): |
222 for key in list(self.editorColours.keys()): |
207 Preferences.setEditorColour(key, self.editorColours[key]) |
223 Preferences.setEditorColour(key, self.editorColours[key]) |
208 |
224 |
209 @pyqtSlot() |
225 @pyqtSlot() |
210 def on_linenumbersFontButton_clicked(self): |
226 def on_linenumbersFontButton_clicked(self): |
376 Public slot to perform some polishing actions. |
392 Public slot to perform some polishing actions. |
377 """ |
393 """ |
378 self.marginsFontSample.setFont(self.marginsFont) |
394 self.marginsFontSample.setFont(self.marginsFont) |
379 self.defaultFontSample.setFont(self.defaultFont) |
395 self.defaultFontSample.setFont(self.defaultFont) |
380 self.monospacedFontSample.setFont(self.monospacedFont) |
396 self.monospacedFontSample.setFont(self.monospacedFont) |
|
397 |
|
398 pl = self.annotationsWarningSample.palette() |
|
399 pl.setColor(QPalette.Text, self.editorColours["AnnotationsWarningForeground"]) |
|
400 pl.setColor(QPalette.Base, self.editorColours["AnnotationsWarningBackground"]) |
|
401 self.annotationsWarningSample.setPalette(pl) |
|
402 self.annotationsWarningSample.repaint() |
|
403 |
|
404 pl = self.annotationsErrorSample.palette() |
|
405 pl.setColor(QPalette.Text, self.editorColours["AnnotationsErrorForeground"]) |
|
406 pl.setColor(QPalette.Base, self.editorColours["AnnotationsErrorBackground"]) |
|
407 self.annotationsErrorSample.setPalette(pl) |
|
408 self.annotationsErrorSample.repaint() |
|
409 |
|
410 @pyqtSlot() |
|
411 def on_annotationsWarningFgButton_clicked(self): |
|
412 """ |
|
413 Private slot to set the foreground colour of the warning annotations. |
|
414 """ |
|
415 colour = QColorDialog.getColor(self.editorColours["AnnotationsWarningForeground"]) |
|
416 if colour.isValid(): |
|
417 pl = self.annotationsWarningSample.palette() |
|
418 pl.setColor(QPalette.Text, colour) |
|
419 self.annotationsWarningSample.setPalette(pl) |
|
420 self.annotationsWarningSample.repaint() |
|
421 self.editorColours["AnnotationsWarningForeground"] = colour |
|
422 |
|
423 @pyqtSlot() |
|
424 def on_annotationsWarningBgButton_clicked(self): |
|
425 """ |
|
426 Private slot to set the background colour of the warning annotations. |
|
427 """ |
|
428 colour = QColorDialog.getColor(self.editorColours["AnnotationsWarningBackground"]) |
|
429 if colour.isValid(): |
|
430 pl = self.annotationsWarningSample.palette() |
|
431 pl.setColor(QPalette.Base, colour) |
|
432 self.annotationsWarningSample.setPalette(pl) |
|
433 self.annotationsWarningSample.repaint() |
|
434 self.editorColours["AnnotationsWarningBackground"] = colour |
|
435 |
|
436 @pyqtSlot() |
|
437 def on_annotationsErrorFgButton_clicked(self): |
|
438 """ |
|
439 Private slot to set the foreground colour of the error annotations. |
|
440 """ |
|
441 colour = QColorDialog.getColor(self.editorColours["AnnotationsErrorForeground"]) |
|
442 if colour.isValid(): |
|
443 pl = self.annotationsErrorSample.palette() |
|
444 pl.setColor(QPalette.Text, colour) |
|
445 self.annotationsErrorSample.setPalette(pl) |
|
446 self.annotationsErrorSample.repaint() |
|
447 self.editorColours["AnnotationsErrorForeground"] = colour |
|
448 |
|
449 @pyqtSlot() |
|
450 def on_annotationsErrorBgButton_clicked(self): |
|
451 """ |
|
452 Private slot to set the background colour of the error annotations. |
|
453 """ |
|
454 colour = QColorDialog.getColor(self.editorColours["AnnotationsErrorBackground"]) |
|
455 if colour.isValid(): |
|
456 pl = self.annotationsErrorSample.palette() |
|
457 pl.setColor(QPalette.Base, colour) |
|
458 self.annotationsErrorSample.setPalette(pl) |
|
459 self.annotationsErrorSample.repaint() |
|
460 self.editorColours["AnnotationsErrorBackground"] = colour |
381 |
461 |
382 def create(dlg): |
462 def create(dlg): |
383 """ |
463 """ |
384 Module function to create the configuration page. |
464 Module function to create the configuration page. |
385 |
465 |