Skip to content

Commit 45b045d

Browse files
committedMay 22, 2018
Fix missing color settings for python console / script editor
1 parent 6d87a4c commit 45b045d

File tree

6 files changed

+330
-39
lines changed

6 files changed

+330
-39
lines changed
 

‎python/console/console_editor.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,9 @@ def __init__(self, parent=None):
100100
self.setFont(font)
101101
self.setMarginsFont(font)
102102
# Margin 0 is used for line numbers
103-
# fm = QFontMetrics(font)
104103
fontmetrics = QFontMetrics(font)
105-
self.setMarginsFont(font)
106104
self.setMarginWidth(0, fontmetrics.width("0000") + 5)
107105
self.setMarginLineNumbers(0, True)
108-
self.setMarginsForegroundColor(QColor("#3E3EE3"))
109-
self.setMarginsBackgroundColor(QColor("#f9f9f9"))
110106
self.setCaretLineVisible(True)
111107
self.setCaretWidth(2)
112108

@@ -117,17 +113,14 @@ def __init__(self, parent=None):
117113
# self.setMinimumWidth(300)
118114

119115
self.setBraceMatching(QsciScintilla.SloppyBraceMatch)
120-
self.setMatchedBraceBackgroundColor(QColor("#b7f907"))
121116

122117
# Folding
123118
self.setFolding(QsciScintilla.PlainFoldStyle)
124-
self.setFoldMarginColors(QColor("#f4f4f4"), QColor("#f4f4f4"))
125119
# self.setWrapMode(QsciScintilla.WrapWord)
126120

127121
# Edge Mode
128122
self.setEdgeMode(QsciScintilla.EdgeLine)
129123
self.setEdgeColumn(80)
130-
self.setEdgeColor(QColor("#FF0000"))
131124

132125
# self.setWrapMode(QsciScintilla.WrapCharacter)
133126
self.setWhitespaceVisibility(QsciScintilla.WsVisibleAfterIndent)
@@ -182,6 +175,18 @@ def __init__(self, parent=None):
182175
self.modificationAttempted.connect(self.fileReadOnly)
183176

184177
def settingsEditor(self):
178+
self.setSelectionForegroundColor(QColor(self.settings.value("pythonConsole/selectionForegroundColorEditor", QColor("#2e3436"))))
179+
self.setSelectionBackgroundColor(QColor(self.settings.value("pythonConsole/selectionBackgroundColorEditor", QColor("#babdb6"))))
180+
self.setMatchedBraceBackgroundColor(QColor(self.settings.value("pythonConsole/matchedBraceBackgroundColorEditor", QColor("#b7f907"))))
181+
self.setMatchedBraceForegroundColor(QColor(self.settings.value("pythonConsole/matchedBraceForegroundColorEditor", QColor("#000000"))))
182+
self.setMarginsForegroundColor(QColor(self.settings.value("pythonConsole/marginForegroundColorEditor", QColor("#3E3EE3"))))
183+
self.setMarginsBackgroundColor(QColor(self.settings.value("pythonConsole/marginBackgroundColorEditor", QColor("#f9f9f9"))))
184+
self.setIndentationGuidesForegroundColor(QColor(self.settings.value("pythonConsole/marginForegroundColorEditor", QColor("#3E3EE3"))))
185+
self.setIndentationGuidesBackgroundColor(QColor(self.settings.value("pythonConsole/marginBackgroundColorEditor", QColor("#f9f9f9"))))
186+
self.setEdgeColor(QColor(self.settings.value("pythonConsole/edgeColorEditor", QColor("#FF0000"))))
187+
foldColor = QColor(self.settings.value("pythonConsole/foldColorEditor", QColor("#f4f4f4")))
188+
self.setFoldMarginColors(foldColor, foldColor)
189+
185190
# Set Python lexer
186191
self.setLexers()
187192
threshold = self.settings.value("pythonConsole/autoCompThresholdEditor", 2, type=int)
@@ -234,6 +239,7 @@ def setLexers(self):
234239
self.lexer.setDefaultFont(font)
235240
self.lexer.setDefaultColor(QColor(self.settings.value("pythonConsole/defaultFontColorEditor", QColor(Qt.black))))
236241
self.lexer.setColor(QColor(self.settings.value("pythonConsole/commentFontColorEditor", QColor(Qt.gray))), 1)
242+
self.lexer.setColor(QColor(self.settings.value("pythonConsole/numberFontColorEditor", QColor("#4e9a06"))), 2)
237243
self.lexer.setColor(QColor(self.settings.value("pythonConsole/keywordFontColorEditor", QColor(Qt.darkGreen))), 5)
238244
self.lexer.setColor(QColor(self.settings.value("pythonConsole/classFontColorEditor", QColor(Qt.blue))), 8)
239245
self.lexer.setColor(QColor(self.settings.value("pythonConsole/methodFontColorEditor", QColor(Qt.darkGray))), 9)

‎python/console/console_output.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,6 @@ def __init__(self, parent=None):
126126
self.setMarginsFont(font)
127127
self.setMarginWidth(1, "00000")
128128
self.setMarginLineNumbers(1, True)
129-
self.setMarginsForegroundColor(QColor("#3E3EE3"))
130-
self.setMarginsBackgroundColor(QColor("#f9f9f9"))
131129
self.setCaretLineVisible(True)
132130
self.setCaretWidth(0)
133131

@@ -161,6 +159,11 @@ def insertInitText(self):
161159
def refreshSettingsOutput(self):
162160
# Set Python lexer
163161
self.setLexers()
162+
self.setSelectionForegroundColor(QColor(self.settings.value("pythonConsole/selectionForegroundColor", QColor("#2e3436"))))
163+
self.setSelectionBackgroundColor(QColor(self.settings.value("pythonConsole/selectionBackgroundColor", QColor("#babdb6"))))
164+
self.setMatchedBraceBackgroundColor(QColor(self.settings.value("pythonConsole/matchedBraceColor", QColor("#b7f907"))))
165+
self.setMarginsForegroundColor(QColor(self.settings.value("pythonConsole/marginForegroundColor", QColor("#3E3EE3"))))
166+
self.setMarginsBackgroundColor(QColor(self.settings.value("pythonConsole/marginBackgroundColor", QColor("#f9f9f9"))))
164167
caretLineColor = self.settings.value("pythonConsole/caretLineColor", QColor("#fcf3ed"))
165168
cursorColor = self.settings.value("pythonConsole/cursorColor", QColor(Qt.black))
166169
self.setCaretLineBackgroundColor(caretLineColor)
@@ -181,6 +184,7 @@ def setLexers(self):
181184
self.lexer.setDefaultFont(font)
182185
self.lexer.setDefaultColor(QColor(self.settings.value("pythonConsole/defaultFontColor", QColor(Qt.black))))
183186
self.lexer.setColor(QColor(self.settings.value("pythonConsole/commentFontColor", QColor(Qt.gray))), 1)
187+
self.lexer.setColor(QColor(self.settings.value("pythonConsole/numberFontColorEditor", QColor("#4e9a06"))), 2)
184188
self.lexer.setColor(QColor(self.settings.value("pythonConsole/keywordFontColor", QColor(Qt.darkGreen))), 5)
185189
self.lexer.setColor(QColor(self.settings.value("pythonConsole/classFontColor", QColor(Qt.blue))), 8)
186190
self.lexer.setColor(QColor(self.settings.value("pythonConsole/methodFontColor", QColor(Qt.darkGray))), 9)

‎python/console/console_sci.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ def __init__(self, parent=None):
7878
# Brace matching: enable for a brace immediately before or after
7979
# the current position
8080
self.setBraceMatching(QsciScintilla.SloppyBraceMatch)
81-
self.setMatchedBraceBackgroundColor(QColor("#b7f907"))
8281

8382
# Current line visible with special background color
8483
self.setCaretWidth(2)
@@ -138,6 +137,10 @@ def refreshSettingsShell(self):
138137

139138
cursorColor = self.settings.value("pythonConsole/cursorColor", QColor(Qt.black))
140139
self.setCaretForegroundColor(cursorColor)
140+
self.setSelectionForegroundColor(QColor(self.settings.value("pythonConsole/selectionForegroundColor", QColor("#2e3436"))))
141+
self.setSelectionBackgroundColor(QColor(self.settings.value("pythonConsole/selectionBackgroundColor", QColor("#babdb6"))))
142+
self.setMatchedBraceBackgroundColor(QColor(self.settings.value("pythonConsole/matchedBraceBackgroundColor", QColor("#b7f907"))))
143+
self.setMatchedBraceForegroundColor(QColor(self.settings.value("pythonConsole/matchedBraceForegroundColor", QColor("#000000"))))
141144

142145
# Sets minimum height for input area based of font metric
143146
self._setMinimumHeight()
@@ -187,6 +190,7 @@ def setLexers(self):
187190
self.lexer.setDefaultFont(font)
188191
self.lexer.setDefaultColor(QColor(self.settings.value("pythonConsole/defaultFontColor", QColor(Qt.black))))
189192
self.lexer.setColor(QColor(self.settings.value("pythonConsole/commentFontColor", QColor(Qt.gray))), 1)
193+
self.lexer.setColor(QColor(self.settings.value("pythonConsole/numberFontColorEditor", QColor("#4e9a06"))), 2)
190194
self.lexer.setColor(QColor(self.settings.value("pythonConsole/keywordFontColor", QColor(Qt.darkGreen))), 5)
191195
self.lexer.setColor(QColor(self.settings.value("pythonConsole/classFontColor", QColor(Qt.blue))), 8)
192196
self.lexer.setColor(QColor(self.settings.value("pythonConsole/methodFontColor", QColor(Qt.darkGray))), 9)

‎python/console/console_settings.py

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ def saveSettings(self):
199199
settings.setValue("pythonConsole/keywordFontColorEditor", self.keywordFontColorEditor.color())
200200
settings.setValue("pythonConsole/decorFontColor", self.decorFontColor.color())
201201
settings.setValue("pythonConsole/decorFontColorEditor", self.decorFontColorEditor.color())
202+
settings.setValue("pythonConsole/numberFontColor", self.numberFontColor.color())
203+
settings.setValue("pythonConsole/numberFontColorEditor", self.numberFontColorEditor.color())
202204
settings.setValue("pythonConsole/methodFontColor", self.methodFontColor.color())
203205
settings.setValue("pythonConsole/methodFontColorEditor", self.methodFontColorEditor.color())
204206
settings.setValue("pythonConsole/commentFontColor", self.commentFontColor.color())
@@ -223,6 +225,20 @@ def saveSettings(self):
223225
settings.setValue("pythonConsole/tripleDoubleQuoteFontColor", self.tripleDoubleQuoteFontColor.color())
224226
settings.setValue("pythonConsole/tripleDoubleQuoteFontColorEditor",
225227
self.tripleDoubleQuoteFontColorEditor.color())
228+
settings.setValue("pythonConsole/edgeColorEditor", self.edgeColorEditor.color())
229+
settings.setValue("pythonConsole/marginBackgroundColor", self.marginBackgroundColor.color())
230+
settings.setValue("pythonConsole/marginBackgroundColorEditor", self.marginBackgroundColorEditor.color())
231+
settings.setValue("pythonConsole/marginForegroundColor", self.marginForegroundColor.color())
232+
settings.setValue("pythonConsole/marginForegroundColorEditor", self.marginForegroundColorEditor.color())
233+
settings.setValue("pythonConsole/foldColorEditor", self.foldColorEditor.color())
234+
settings.setValue("pythonConsole/selectionBackgroundColor", self.selectionBackgroundColor.color())
235+
settings.setValue("pythonConsole/selectionBackgroundColorEditor", self.selectionBackgroundColorEditor.color())
236+
settings.setValue("pythonConsole/selectionForegroundColor", self.selectionForegroundColor.color())
237+
settings.setValue("pythonConsole/selectionForegroundColorEditor", self.selectionForegroundColorEditor.color())
238+
settings.setValue("pythonConsole/matchedBraceBackgroundColor", self.matchedBraceBackgroundColor.color())
239+
settings.setValue("pythonConsole/matchedBraceBackgroundColorEditor", self.matchedBraceBackgroundColorEditor.color())
240+
settings.setValue("pythonConsole/matchedBraceForegroundColor", self.matchedBraceForegroundColor.color())
241+
settings.setValue("pythonConsole/matchedBraceForegroundColorEditor", self.matchedBraceForegroundColorEditor.color())
226242

227243
def restoreSettings(self):
228244
settings = QgsSettings()
@@ -289,7 +305,10 @@ def restoreSettings(self):
289305
QColor(settings.value("pythonConsole/methodFontColorEditor", QColor(Qt.darkGray))))
290306
self.decorFontColor.setColor(QColor(settings.value("pythonConsole/decorFontColor", QColor(Qt.darkBlue))))
291307
self.decorFontColorEditor.setColor(
292-
QColor(settings.value("pythonConsole/decorFontColorEditor", QColor(Qt.darkBlue))))
308+
QColor(settings.value("pythonConsole/decorFontColorEditor", QColor("#4e9a06"))))
309+
self.numberFontColor.setColor(QColor(settings.value("pythonConsole/numberFontColor", QColor("#4e9a06"))))
310+
self.numberFontColorEditor.setColor(
311+
QColor(settings.value("pythonConsole/numberFontColorEditor", QColor(Qt.darkBlue))))
293312
self.commentFontColor.setColor(QColor(settings.value("pythonConsole/commentFontColor", QColor(Qt.gray))))
294313
self.commentFontColorEditor.setColor(
295314
QColor(settings.value("pythonConsole/commentFontColorEditor", QColor(Qt.gray))))
@@ -322,13 +341,28 @@ def restoreSettings(self):
322341
settings.value("pythonConsole/tripleDoubleQuoteFontColor", QColor(Qt.blue)))
323342
self.tripleDoubleQuoteFontColorEditor.setColor(
324343
settings.value("pythonConsole/tripleDoubleQuoteFontColorEditor", QColor(Qt.blue)))
344+
self.edgeColorEditor.setColor(settings.value("pythonConsole/edgeColorEditor", QColor("#FF0000")))
345+
self.marginBackgroundColor.setColor(settings.value("pythonConsole/marginBackgroundColor", QColor("#f9f9f9")))
346+
self.marginBackgroundColorEditor.setColor(settings.value("pythonConsole/marginBackgroundColorEditor", QColor("#f9f9f9")))
347+
self.marginForegroundColor.setColor(settings.value("pythonConsole/marginForegroundColor", QColor("#3E3EE3")))
348+
self.marginForegroundColorEditor.setColor(settings.value("pythonConsole/marginForegroundColorEditor", QColor("#3E3EE3")))
349+
self.foldColorEditor.setColor(settings.value("pythonConsole/foldColorEditor", QColor("#f4f4f4")))
350+
self.selectionForegroundColor.setColor(settings.value("pythonConsole/selectionForegroundColor", QColor("#2e3436")))
351+
self.selectionForegroundColorEditor.setColor(settings.value("pythonConsole/selectionForegroundColorEditor", QColor("#2e3436")))
352+
self.selectionBackgroundColor.setColor(settings.value("pythonConsole/selectionBackgroundColor", QColor("#babdb6")))
353+
self.selectionBackgroundColorEditor.setColor(settings.value("pythonConsole/selectionBackgroundColorEditor", QColor("#babdb6")))
354+
self.matchedBraceForegroundColor.setColor(settings.value("pythonConsole/matchedBraceForegroundColor", QColor("#000000")))
355+
self.matchedBraceForegroundColorEditor.setColor(settings.value("pythonConsole/matchedBraceForegroundColorEditor", QColor("#000000")))
356+
self.matchedBraceBackgroundColor.setColor(settings.value("pythonConsole/matchedBraceBackgroundColor", QColor("#b7f907")))
357+
self.matchedBraceBackgroundColorEditor.setColor(settings.value("pythonConsole/matchedBraceBackgroundColorEditor", QColor("#b7f907")))
325358

326359
def _resetFontColor(self):
327360
self.defaultFontColor.setColor(QColor(Qt.black))
328361
self.keywordFontColor.setColor(QColor(Qt.darkGreen))
329362
self.classFontColor.setColor(QColor(Qt.blue))
330363
self.methodFontColor.setColor(QColor(Qt.darkGray))
331364
self.decorFontColor.setColor(QColor(Qt.darkBlue))
365+
self.numFontColor.setColor(QColor("#4e9a06"))
332366
self.commentFontColor.setColor(QColor(Qt.gray))
333367
self.commentBlockFontColor.setColor(QColor(Qt.gray))
334368
self.stderrFontColor.setColor(QColor(Qt.red))
@@ -339,13 +373,20 @@ def _resetFontColor(self):
339373
self.doubleQuoteFontColor.setColor(QColor(Qt.blue))
340374
self.tripleSingleQuoteFontColor.setColor(QColor(Qt.blue))
341375
self.tripleDoubleQuoteFontColor.setColor(QColor(Qt.blue))
376+
self.marginBackgroundColor.setColor(QColor("#f9f9f9"))
377+
self.marginForegroundColor.setColor(QColor("#3E3EE3"))
378+
self.selectionBackgroundColor.setColor(QColor("#babdb6"))
379+
self.selectionForegroundColor.setColor(QColor("#2e3436"))
380+
self.matchedBraceBackgroundColor.setColor(QColor("#b7f907"))
381+
self.matchedBraceForegroundColor.setColor(QColor("#000000"))
342382

343383
def _resetFontColorEditor(self):
344384
self.defaultFontColorEditor.setColor(QColor(Qt.black))
345385
self.keywordFontColorEditor.setColor(QColor(Qt.darkGreen))
346386
self.classFontColorEditor.setColor(QColor(Qt.blue))
347387
self.methodFontColorEditor.setColor(QColor(Qt.darkGray))
348388
self.decorFontColorEditor.setColor(QColor(Qt.darkBlue))
389+
self.numFontColorEditor.setColor(QColor("#4e9a06"))
349390
self.commentFontColorEditor.setColor(QColor(Qt.gray))
350391
self.commentBlockFontColorEditor.setColor(QColor(Qt.gray))
351392
self.paperBackgroundColorEditor.setColor(QColor(Qt.white))
@@ -355,6 +396,14 @@ def _resetFontColorEditor(self):
355396
self.doubleQuoteFontColorEditor.setColor(QColor(Qt.blue))
356397
self.tripleSingleQuoteFontColorEditor.setColor(QColor(Qt.blue))
357398
self.tripleDoubleQuoteFontColorEditor.setColor(QColor(Qt.blue))
399+
self.edgeColorEditor.setColor(QColor("#FF0000"))
400+
self.marginBackgroundColorEditor.setColor(QColor("#f9f9f9"))
401+
self.marginForegroundColorEditor.setColor(QColor("#3E3EE3"))
402+
self.foldColorEditor.setColor(QColor("#f4f4f4"))
403+
self.selectionBackgroundColorEditor.setColor(QColor("#babdb6"))
404+
self.selectionForegroundColorEditor.setColor(QColor("#2e3436"))
405+
self.matchedBraceBackgroundColorEditor.setColor(QColor("#b7f907"))
406+
self.matchedBraceForegroundColorEditor.setColor(QColor("#000000"))
358407

359408
def reject(self):
360409
self.restoreSettings()

‎python/console/console_settings.ui

Lines changed: 238 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
<rect>
1010
<x>0</x>
1111
<y>0</y>
12-
<width>995</width>
13-
<height>630</height>
12+
<width>1055</width>
13+
<height>720</height>
1414
</rect>
1515
</property>
1616
<property name="sizePolicy">
@@ -313,41 +313,55 @@
313313
</widget>
314314
</item>
315315
<item row="1" column="4">
316+
<widget class="QLabel" name="label_55">
317+
<property name="text">
318+
<string>Number</string>
319+
</property>
320+
</widget>
321+
</item>
322+
<item row="1" column="5">
323+
<widget class="QgsColorButton" name="numberFontColor">
324+
<property name="text">
325+
<string/>
326+
</property>
327+
</widget>
328+
</item>
329+
<item row="2" column="0">
316330
<widget class="QLabel" name="label_19">
317331
<property name="text">
318332
<string>Comment</string>
319333
</property>
320334
</widget>
321335
</item>
322-
<item row="1" column="5">
336+
<item row="2" column="1">
323337
<widget class="QgsColorButton" name="commentFontColor">
324338
<property name="text">
325339
<string/>
326340
</property>
327341
</widget>
328342
</item>
329-
<item row="2" column="0">
343+
<item row="2" column="2">
330344
<widget class="QLabel" name="label_20">
331345
<property name="text">
332346
<string>Comment block</string>
333347
</property>
334348
</widget>
335349
</item>
336-
<item row="2" column="1">
350+
<item row="2" column="3">
337351
<widget class="QgsColorButton" name="commentBlockFontColor">
338352
<property name="text">
339353
<string/>
340354
</property>
341355
</widget>
342356
</item>
343-
<item row="2" column="2">
357+
<item row="4" column="4">
344358
<widget class="QLabel" name="label_24">
345359
<property name="text">
346360
<string>Cursor</string>
347361
</property>
348362
</widget>
349363
</item>
350-
<item row="2" column="3">
364+
<item row="4" column="5">
351365
<widget class="QgsColorButton" name="cursorColor">
352366
<property name="text">
353367
<string/>
@@ -438,20 +452,104 @@
438452
</property>
439453
</widget>
440454
</item>
441-
<item row="4" column="4">
455+
<item row="5" column="0">
456+
<widget class="QLabel" name="label_42">
457+
<property name="text">
458+
<string>Margin background</string>
459+
</property>
460+
</widget>
461+
</item>
462+
<item row="5" column="1">
463+
<widget class="QgsColorButton" name="marginBackgroundColor">
464+
<property name="text">
465+
<string/>
466+
</property>
467+
</widget>
468+
</item>
469+
<item row="5" column="2">
470+
<widget class="QLabel" name="label_43">
471+
<property name="text">
472+
<string>Margin foreground</string>
473+
</property>
474+
</widget>
475+
</item>
476+
<item row="5" column="3">
477+
<widget class="QgsColorButton" name="marginForegroundColor">
478+
<property name="text">
479+
<string/>
480+
</property>
481+
</widget>
482+
</item>
483+
<item row="5" column="4">
442484
<widget class="QLabel" name="label_14">
443485
<property name="text">
444486
<string>Error</string>
445487
</property>
446488
</widget>
447489
</item>
448-
<item row="4" column="5">
490+
<item row="5" column="5">
449491
<widget class="QgsColorButton" name="stderrFontColor">
450492
<property name="text">
451493
<string/>
452494
</property>
453495
</widget>
454496
</item>
497+
<item row="6" column="0">
498+
<widget class="QLabel" name="label_48">
499+
<property name="text">
500+
<string>Selection background</string>
501+
</property>
502+
</widget>
503+
</item>
504+
<item row="6" column="1">
505+
<widget class="QgsColorButton" name="selectionBackgroundColor">
506+
<property name="text">
507+
<string/>
508+
</property>
509+
</widget>
510+
</item>
511+
<item row="6" column="2">
512+
<widget class="QLabel" name="label_49">
513+
<property name="text">
514+
<string>Selection foreground</string>
515+
</property>
516+
</widget>
517+
</item>
518+
<item row="6" column="3">
519+
<widget class="QgsColorButton" name="selectionForegroundColor">
520+
<property name="text">
521+
<string/>
522+
</property>
523+
</widget>
524+
</item>
525+
<item row="7" column="0">
526+
<widget class="QLabel" name="label_50">
527+
<property name="text">
528+
<string>Brace background</string>
529+
</property>
530+
</widget>
531+
</item>
532+
<item row="7" column="1">
533+
<widget class="QgsColorButton" name="matchedBraceBackgroundColor">
534+
<property name="text">
535+
<string/>
536+
</property>
537+
</widget>
538+
</item>
539+
<item row="7" column="2">
540+
<widget class="QLabel" name="label_60">
541+
<property name="text">
542+
<string>Brace foreground</string>
543+
</property>
544+
</widget>
545+
</item>
546+
<item row="7" column="3">
547+
<widget class="QgsColorButton" name="matchedBraceForegroundColor">
548+
<property name="text">
549+
<string/>
550+
</property>
551+
</widget>
552+
</item>
455553
</layout>
456554
</item>
457555
<item row="1" column="1">
@@ -841,41 +939,55 @@
841939
</widget>
842940
</item>
843941
<item row="1" column="4">
942+
<widget class="QLabel" name="label_56">
943+
<property name="text">
944+
<string>Number</string>
945+
</property>
946+
</widget>
947+
</item>
948+
<item row="1" column="5">
949+
<widget class="QgsColorButton" name="numberFontColorEditor">
950+
<property name="text">
951+
<string/>
952+
</property>
953+
</widget>
954+
</item>
955+
<item row="2" column="0">
844956
<widget class="QLabel" name="label_10">
845957
<property name="text">
846958
<string>Comment</string>
847959
</property>
848960
</widget>
849961
</item>
850-
<item row="1" column="5">
962+
<item row="2" column="1">
851963
<widget class="QgsColorButton" name="commentFontColorEditor">
852964
<property name="text">
853965
<string/>
854966
</property>
855967
</widget>
856968
</item>
857-
<item row="2" column="0">
969+
<item row="2" column="2">
858970
<widget class="QLabel" name="label_12">
859971
<property name="text">
860972
<string>Comment block</string>
861973
</property>
862974
</widget>
863975
</item>
864-
<item row="2" column="1">
976+
<item row="2" column="3">
865977
<widget class="QgsColorButton" name="commentBlockFontColorEditor">
866978
<property name="text">
867979
<string/>
868980
</property>
869981
</widget>
870982
</item>
871-
<item row="2" column="2">
983+
<item row="4" column="4">
872984
<widget class="QLabel" name="label_25">
873985
<property name="text">
874986
<string>Cursor</string>
875987
</property>
876988
</widget>
877989
</item>
878-
<item row="2" column="3">
990+
<item row="4" column="5">
879991
<widget class="QgsColorButton" name="cursorColorEditor">
880992
<property name="text">
881993
<string/>
@@ -952,6 +1064,118 @@
9521064
</property>
9531065
</widget>
9541066
</item>
1067+
<item row="5" column="4">
1068+
<widget class="QLabel" name="label_40">
1069+
<property name="text">
1070+
<string>Edge</string>
1071+
</property>
1072+
</widget>
1073+
</item>
1074+
<item row="5" column="5">
1075+
<widget class="QgsColorButton" name="edgeColorEditor">
1076+
<property name="text">
1077+
<string/>
1078+
</property>
1079+
</widget>
1080+
</item>
1081+
<item row="5" column="0">
1082+
<widget class="QLabel" name="label_45">
1083+
<property name="text">
1084+
<string>Margin background</string>
1085+
</property>
1086+
</widget>
1087+
</item>
1088+
<item row="5" column="1">
1089+
<widget class="QgsColorButton" name="marginBackgroundColorEditor">
1090+
<property name="text">
1091+
<string/>
1092+
</property>
1093+
</widget>
1094+
</item>
1095+
<item row="5" column="2">
1096+
<widget class="QLabel" name="label_46">
1097+
<property name="text">
1098+
<string>Margin foreground</string>
1099+
</property>
1100+
</widget>
1101+
</item>
1102+
<item row="5" column="3">
1103+
<widget class="QgsColorButton" name="marginForegroundColorEditor">
1104+
<property name="text">
1105+
<string/>
1106+
</property>
1107+
</widget>
1108+
</item>
1109+
<item row="6" column="4">
1110+
<widget class="QLabel" name="label_47">
1111+
<property name="text">
1112+
<string>Fold guide</string>
1113+
</property>
1114+
</widget>
1115+
</item>
1116+
<item row="6" column="5">
1117+
<widget class="QgsColorButton" name="foldColorEditor">
1118+
<property name="text">
1119+
<string/>
1120+
</property>
1121+
</widget>
1122+
</item>
1123+
<item row="6" column="0">
1124+
<widget class="QLabel" name="label_51">
1125+
<property name="text">
1126+
<string>Selection background</string>
1127+
</property>
1128+
</widget>
1129+
</item>
1130+
<item row="6" column="1">
1131+
<widget class="QgsColorButton" name="selectionBackgroundColorEditor">
1132+
<property name="text">
1133+
<string/>
1134+
</property>
1135+
</widget>
1136+
</item>
1137+
<item row="6" column="2">
1138+
<widget class="QLabel" name="label_52">
1139+
<property name="text">
1140+
<string>Selection foreground</string>
1141+
</property>
1142+
</widget>
1143+
</item>
1144+
<item row="6" column="3">
1145+
<widget class="QgsColorButton" name="selectionForegroundColorEditor">
1146+
<property name="text">
1147+
<string/>
1148+
</property>
1149+
</widget>
1150+
</item>
1151+
<item row="7" column="0">
1152+
<widget class="QLabel" name="label_53">
1153+
<property name="text">
1154+
<string>Brace background</string>
1155+
</property>
1156+
</widget>
1157+
</item>
1158+
<item row="7" column="1">
1159+
<widget class="QgsColorButton" name="matchedBraceBackgroundColorEditor">
1160+
<property name="text">
1161+
<string/>
1162+
</property>
1163+
</widget>
1164+
</item>
1165+
<item row="7" column="2">
1166+
<widget class="QLabel" name="label_61">
1167+
<property name="text">
1168+
<string>Brace foreground</string>
1169+
</property>
1170+
</widget>
1171+
</item>
1172+
<item row="7" column="3">
1173+
<widget class="QgsColorButton" name="matchedBraceForegroundColorEditor">
1174+
<property name="text">
1175+
<string/>
1176+
</property>
1177+
</widget>
1178+
</item>
9551179
<item row="3" column="4">
9561180
<widget class="QLabel" name="label_21">
9571181
<property name="text">

‎python/plugins/processing/script/ScriptEdit.py

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import os
2929

3030
from qgis.PyQt.QtCore import Qt
31-
from qgis.PyQt.QtGui import QFont, QColor, QKeySequence, QFontDatabase
31+
from qgis.PyQt.QtGui import QFont, QColor, QKeySequence, QFontDatabase, QFontMetrics
3232
from qgis.PyQt.QtWidgets import QShortcut
3333
from qgis.core import QgsApplication, QgsSettings
3434

@@ -50,32 +50,34 @@ def setCommonOptions(self):
5050
# Enable non-ASCII characters
5151
self.setUtf8(True)
5252

53+
settings = QgsSettings()
54+
5355
# Default font
54-
font = QFont()
55-
font.setFamily('Courier')
56-
font.setFixedPitch(True)
57-
font.setPointSize(20)
56+
font = QFontDatabase.systemFont(QFontDatabase.FixedFont)
5857
self.setFont(font)
5958
self.setMarginsFont(font)
6059

6160
self.setBraceMatching(QsciScintilla.SloppyBraceMatch)
62-
self.setMatchedBraceBackgroundColor(QColor("#b7f907"))
61+
self.setMatchedBraceBackgroundColor(QColor(settings.value("pythonConsole/matchedBraceBackgroundColorEditor", QColor("#b7f907"))))
62+
self.setMatchedBraceForegroundColor(QColor(settings.value("pythonConsole/matchedBraceForegroundColorEditor", QColor("#000000"))))
6363

6464
#self.setWrapMode(QsciScintilla.WrapWord)
6565
#self.setWrapVisualFlags(QsciScintilla.WrapFlagByText,
6666
# QsciScintilla.WrapFlagNone, 4)
6767

68-
self.setSelectionForegroundColor(QColor('#2e3436'))
69-
self.setSelectionBackgroundColor(QColor('#babdb6'))
68+
self.setSelectionForegroundColor(QColor(settings.value("pythonConsole/selectionForegroundColorEditor", QColor("#2e3436"))))
69+
self.setSelectionBackgroundColor(QColor(settings.value("pythonConsole/selectionBackgroundColorEditor", QColor("#babdb6"))))
7070

7171
# Show line numbers
72-
self.setMarginWidth(1, '000')
72+
fontmetrics = QFontMetrics(font)
73+
self.setMarginWidth(1, fontmetrics.width("0000") + 5)
7374
self.setMarginLineNumbers(1, True)
74-
self.setMarginsForegroundColor(QColor("#3E3EE3"))
75-
self.setMarginsBackgroundColor(QColor("#f9f9f9"))
75+
self.setMarginsForegroundColor(QColor(settings.value("pythonConsole/marginForegroundColorEditor", QColor("#3E3EE3"))))
76+
self.setMarginsBackgroundColor(QColor(settings.value("pythonConsole/marginBackgroundColorEditor", QColor("#f9f9f9"))))
77+
self.setIndentationGuidesForegroundColor(QColor(settings.value("pythonConsole/marginForegroundColorEditor", QColor("#3E3EE3"))))
78+
self.setIndentationGuidesBackgroundColor(QColor(settings.value("pythonConsole/marginBackgroundColorEditor", QColor("#f9f9f9"))))
7679

7780
# Highlight current line
78-
settings = QgsSettings()
7981
caretLineColorEditor = settings.value("pythonConsole/caretLineColorEditor", QColor("#fcf3ed"))
8082
cursorColorEditor = settings.value("pythonConsole/cursorColorEditor", QColor(Qt.black))
8183
self.setCaretLineVisible(True)
@@ -85,12 +87,13 @@ def setCommonOptions(self):
8587

8688
# Folding
8789
self.setFolding(QsciScintilla.PlainFoldStyle)
88-
self.setFoldMarginColors(QColor("#f4f4f4"), QColor("#f4f4f4"))
90+
foldColor = QColor(settings.value("pythonConsole/foldColorEditor", QColor("#f4f4f4")))
91+
self.setFoldMarginColors(foldColor, foldColor)
8992

9093
# Mark column 80 with vertical line
9194
self.setEdgeMode(QsciScintilla.EdgeLine)
9295
self.setEdgeColumn(80)
93-
self.setEdgeColor(QColor("#FF0000"))
96+
self.setEdgeColor(QColor(settings.value("pythonConsole/edgeColorEditor", QColor("#FF0000"))))
9497

9598
# Indentation
9699
self.setAutoIndent(True)
@@ -169,6 +172,7 @@ def initLexer(self):
169172
self.lexer.setDefaultFont(font)
170173
self.lexer.setDefaultColor(QColor(settings.value("pythonConsole/defaultFontColorEditor", QColor(Qt.black))))
171174
self.lexer.setColor(QColor(settings.value("pythonConsole/commentFontColorEditor", QColor(Qt.gray))), 1)
175+
self.lexer.setColor(QColor(settings.value("pythonConsole/numberFontColorEditor", QColor(Qt.gray))), 2)
172176
self.lexer.setColor(QColor(settings.value("pythonConsole/keywordFontColorEditor", QColor(Qt.darkGreen))), 5)
173177
self.lexer.setColor(QColor(settings.value("pythonConsole/classFontColorEditor", QColor(Qt.blue))), 8)
174178
self.lexer.setColor(QColor(settings.value("pythonConsole/methodFontColorEditor", QColor(Qt.darkGray))), 9)

0 commit comments

Comments
 (0)
Please sign in to comment.