Skip to content
Permalink
Browse files

Fix missing color settings for python console / script editor

  • Loading branch information
nirvn committed May 22, 2018
1 parent 6d87a4c commit 45b045d212a139e6f4d4018cb41e5eef4aa412d6
@@ -100,13 +100,9 @@ def __init__(self, parent=None):
self.setFont(font)
self.setMarginsFont(font)
# Margin 0 is used for line numbers
# fm = QFontMetrics(font)
fontmetrics = QFontMetrics(font)
self.setMarginsFont(font)
self.setMarginWidth(0, fontmetrics.width("0000") + 5)
self.setMarginLineNumbers(0, True)
self.setMarginsForegroundColor(QColor("#3E3EE3"))
self.setMarginsBackgroundColor(QColor("#f9f9f9"))
self.setCaretLineVisible(True)
self.setCaretWidth(2)

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

self.setBraceMatching(QsciScintilla.SloppyBraceMatch)
self.setMatchedBraceBackgroundColor(QColor("#b7f907"))

# Folding
self.setFolding(QsciScintilla.PlainFoldStyle)
self.setFoldMarginColors(QColor("#f4f4f4"), QColor("#f4f4f4"))
# self.setWrapMode(QsciScintilla.WrapWord)

# Edge Mode
self.setEdgeMode(QsciScintilla.EdgeLine)
self.setEdgeColumn(80)
self.setEdgeColor(QColor("#FF0000"))

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

def settingsEditor(self):
self.setSelectionForegroundColor(QColor(self.settings.value("pythonConsole/selectionForegroundColorEditor", QColor("#2e3436"))))
self.setSelectionBackgroundColor(QColor(self.settings.value("pythonConsole/selectionBackgroundColorEditor", QColor("#babdb6"))))
self.setMatchedBraceBackgroundColor(QColor(self.settings.value("pythonConsole/matchedBraceBackgroundColorEditor", QColor("#b7f907"))))
self.setMatchedBraceForegroundColor(QColor(self.settings.value("pythonConsole/matchedBraceForegroundColorEditor", QColor("#000000"))))
self.setMarginsForegroundColor(QColor(self.settings.value("pythonConsole/marginForegroundColorEditor", QColor("#3E3EE3"))))
self.setMarginsBackgroundColor(QColor(self.settings.value("pythonConsole/marginBackgroundColorEditor", QColor("#f9f9f9"))))
self.setIndentationGuidesForegroundColor(QColor(self.settings.value("pythonConsole/marginForegroundColorEditor", QColor("#3E3EE3"))))
self.setIndentationGuidesBackgroundColor(QColor(self.settings.value("pythonConsole/marginBackgroundColorEditor", QColor("#f9f9f9"))))
self.setEdgeColor(QColor(self.settings.value("pythonConsole/edgeColorEditor", QColor("#FF0000"))))
foldColor = QColor(self.settings.value("pythonConsole/foldColorEditor", QColor("#f4f4f4")))
self.setFoldMarginColors(foldColor, foldColor)

# Set Python lexer
self.setLexers()
threshold = self.settings.value("pythonConsole/autoCompThresholdEditor", 2, type=int)
@@ -234,6 +239,7 @@ def setLexers(self):
self.lexer.setDefaultFont(font)
self.lexer.setDefaultColor(QColor(self.settings.value("pythonConsole/defaultFontColorEditor", QColor(Qt.black))))
self.lexer.setColor(QColor(self.settings.value("pythonConsole/commentFontColorEditor", QColor(Qt.gray))), 1)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/numberFontColorEditor", QColor("#4e9a06"))), 2)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/keywordFontColorEditor", QColor(Qt.darkGreen))), 5)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/classFontColorEditor", QColor(Qt.blue))), 8)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/methodFontColorEditor", QColor(Qt.darkGray))), 9)
@@ -126,8 +126,6 @@ def __init__(self, parent=None):
self.setMarginsFont(font)
self.setMarginWidth(1, "00000")
self.setMarginLineNumbers(1, True)
self.setMarginsForegroundColor(QColor("#3E3EE3"))
self.setMarginsBackgroundColor(QColor("#f9f9f9"))
self.setCaretLineVisible(True)
self.setCaretWidth(0)

@@ -161,6 +159,11 @@ def insertInitText(self):
def refreshSettingsOutput(self):
# Set Python lexer
self.setLexers()
self.setSelectionForegroundColor(QColor(self.settings.value("pythonConsole/selectionForegroundColor", QColor("#2e3436"))))
self.setSelectionBackgroundColor(QColor(self.settings.value("pythonConsole/selectionBackgroundColor", QColor("#babdb6"))))
self.setMatchedBraceBackgroundColor(QColor(self.settings.value("pythonConsole/matchedBraceColor", QColor("#b7f907"))))
self.setMarginsForegroundColor(QColor(self.settings.value("pythonConsole/marginForegroundColor", QColor("#3E3EE3"))))
self.setMarginsBackgroundColor(QColor(self.settings.value("pythonConsole/marginBackgroundColor", QColor("#f9f9f9"))))
caretLineColor = self.settings.value("pythonConsole/caretLineColor", QColor("#fcf3ed"))
cursorColor = self.settings.value("pythonConsole/cursorColor", QColor(Qt.black))
self.setCaretLineBackgroundColor(caretLineColor)
@@ -181,6 +184,7 @@ def setLexers(self):
self.lexer.setDefaultFont(font)
self.lexer.setDefaultColor(QColor(self.settings.value("pythonConsole/defaultFontColor", QColor(Qt.black))))
self.lexer.setColor(QColor(self.settings.value("pythonConsole/commentFontColor", QColor(Qt.gray))), 1)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/numberFontColorEditor", QColor("#4e9a06"))), 2)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/keywordFontColor", QColor(Qt.darkGreen))), 5)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/classFontColor", QColor(Qt.blue))), 8)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/methodFontColor", QColor(Qt.darkGray))), 9)
@@ -78,7 +78,6 @@ def __init__(self, parent=None):
# Brace matching: enable for a brace immediately before or after
# the current position
self.setBraceMatching(QsciScintilla.SloppyBraceMatch)
self.setMatchedBraceBackgroundColor(QColor("#b7f907"))

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

cursorColor = self.settings.value("pythonConsole/cursorColor", QColor(Qt.black))
self.setCaretForegroundColor(cursorColor)
self.setSelectionForegroundColor(QColor(self.settings.value("pythonConsole/selectionForegroundColor", QColor("#2e3436"))))
self.setSelectionBackgroundColor(QColor(self.settings.value("pythonConsole/selectionBackgroundColor", QColor("#babdb6"))))
self.setMatchedBraceBackgroundColor(QColor(self.settings.value("pythonConsole/matchedBraceBackgroundColor", QColor("#b7f907"))))
self.setMatchedBraceForegroundColor(QColor(self.settings.value("pythonConsole/matchedBraceForegroundColor", QColor("#000000"))))

# Sets minimum height for input area based of font metric
self._setMinimumHeight()
@@ -187,6 +190,7 @@ def setLexers(self):
self.lexer.setDefaultFont(font)
self.lexer.setDefaultColor(QColor(self.settings.value("pythonConsole/defaultFontColor", QColor(Qt.black))))
self.lexer.setColor(QColor(self.settings.value("pythonConsole/commentFontColor", QColor(Qt.gray))), 1)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/numberFontColorEditor", QColor("#4e9a06"))), 2)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/keywordFontColor", QColor(Qt.darkGreen))), 5)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/classFontColor", QColor(Qt.blue))), 8)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/methodFontColor", QColor(Qt.darkGray))), 9)
@@ -199,6 +199,8 @@ def saveSettings(self):
settings.setValue("pythonConsole/keywordFontColorEditor", self.keywordFontColorEditor.color())
settings.setValue("pythonConsole/decorFontColor", self.decorFontColor.color())
settings.setValue("pythonConsole/decorFontColorEditor", self.decorFontColorEditor.color())
settings.setValue("pythonConsole/numberFontColor", self.numberFontColor.color())
settings.setValue("pythonConsole/numberFontColorEditor", self.numberFontColorEditor.color())
settings.setValue("pythonConsole/methodFontColor", self.methodFontColor.color())
settings.setValue("pythonConsole/methodFontColorEditor", self.methodFontColorEditor.color())
settings.setValue("pythonConsole/commentFontColor", self.commentFontColor.color())
@@ -223,6 +225,20 @@ def saveSettings(self):
settings.setValue("pythonConsole/tripleDoubleQuoteFontColor", self.tripleDoubleQuoteFontColor.color())
settings.setValue("pythonConsole/tripleDoubleQuoteFontColorEditor",
self.tripleDoubleQuoteFontColorEditor.color())
settings.setValue("pythonConsole/edgeColorEditor", self.edgeColorEditor.color())
settings.setValue("pythonConsole/marginBackgroundColor", self.marginBackgroundColor.color())
settings.setValue("pythonConsole/marginBackgroundColorEditor", self.marginBackgroundColorEditor.color())
settings.setValue("pythonConsole/marginForegroundColor", self.marginForegroundColor.color())
settings.setValue("pythonConsole/marginForegroundColorEditor", self.marginForegroundColorEditor.color())
settings.setValue("pythonConsole/foldColorEditor", self.foldColorEditor.color())
settings.setValue("pythonConsole/selectionBackgroundColor", self.selectionBackgroundColor.color())
settings.setValue("pythonConsole/selectionBackgroundColorEditor", self.selectionBackgroundColorEditor.color())
settings.setValue("pythonConsole/selectionForegroundColor", self.selectionForegroundColor.color())
settings.setValue("pythonConsole/selectionForegroundColorEditor", self.selectionForegroundColorEditor.color())
settings.setValue("pythonConsole/matchedBraceBackgroundColor", self.matchedBraceBackgroundColor.color())
settings.setValue("pythonConsole/matchedBraceBackgroundColorEditor", self.matchedBraceBackgroundColorEditor.color())
settings.setValue("pythonConsole/matchedBraceForegroundColor", self.matchedBraceForegroundColor.color())
settings.setValue("pythonConsole/matchedBraceForegroundColorEditor", self.matchedBraceForegroundColorEditor.color())

def restoreSettings(self):
settings = QgsSettings()
@@ -289,7 +305,10 @@ def restoreSettings(self):
QColor(settings.value("pythonConsole/methodFontColorEditor", QColor(Qt.darkGray))))
self.decorFontColor.setColor(QColor(settings.value("pythonConsole/decorFontColor", QColor(Qt.darkBlue))))
self.decorFontColorEditor.setColor(
QColor(settings.value("pythonConsole/decorFontColorEditor", QColor(Qt.darkBlue))))
QColor(settings.value("pythonConsole/decorFontColorEditor", QColor("#4e9a06"))))
self.numberFontColor.setColor(QColor(settings.value("pythonConsole/numberFontColor", QColor("#4e9a06"))))
self.numberFontColorEditor.setColor(
QColor(settings.value("pythonConsole/numberFontColorEditor", QColor(Qt.darkBlue))))
self.commentFontColor.setColor(QColor(settings.value("pythonConsole/commentFontColor", QColor(Qt.gray))))
self.commentFontColorEditor.setColor(
QColor(settings.value("pythonConsole/commentFontColorEditor", QColor(Qt.gray))))
@@ -322,13 +341,28 @@ def restoreSettings(self):
settings.value("pythonConsole/tripleDoubleQuoteFontColor", QColor(Qt.blue)))
self.tripleDoubleQuoteFontColorEditor.setColor(
settings.value("pythonConsole/tripleDoubleQuoteFontColorEditor", QColor(Qt.blue)))
self.edgeColorEditor.setColor(settings.value("pythonConsole/edgeColorEditor", QColor("#FF0000")))
self.marginBackgroundColor.setColor(settings.value("pythonConsole/marginBackgroundColor", QColor("#f9f9f9")))
self.marginBackgroundColorEditor.setColor(settings.value("pythonConsole/marginBackgroundColorEditor", QColor("#f9f9f9")))
self.marginForegroundColor.setColor(settings.value("pythonConsole/marginForegroundColor", QColor("#3E3EE3")))
self.marginForegroundColorEditor.setColor(settings.value("pythonConsole/marginForegroundColorEditor", QColor("#3E3EE3")))
self.foldColorEditor.setColor(settings.value("pythonConsole/foldColorEditor", QColor("#f4f4f4")))
self.selectionForegroundColor.setColor(settings.value("pythonConsole/selectionForegroundColor", QColor("#2e3436")))
self.selectionForegroundColorEditor.setColor(settings.value("pythonConsole/selectionForegroundColorEditor", QColor("#2e3436")))
self.selectionBackgroundColor.setColor(settings.value("pythonConsole/selectionBackgroundColor", QColor("#babdb6")))
self.selectionBackgroundColorEditor.setColor(settings.value("pythonConsole/selectionBackgroundColorEditor", QColor("#babdb6")))
self.matchedBraceForegroundColor.setColor(settings.value("pythonConsole/matchedBraceForegroundColor", QColor("#000000")))
self.matchedBraceForegroundColorEditor.setColor(settings.value("pythonConsole/matchedBraceForegroundColorEditor", QColor("#000000")))
self.matchedBraceBackgroundColor.setColor(settings.value("pythonConsole/matchedBraceBackgroundColor", QColor("#b7f907")))
self.matchedBraceBackgroundColorEditor.setColor(settings.value("pythonConsole/matchedBraceBackgroundColorEditor", QColor("#b7f907")))

def _resetFontColor(self):
self.defaultFontColor.setColor(QColor(Qt.black))
self.keywordFontColor.setColor(QColor(Qt.darkGreen))
self.classFontColor.setColor(QColor(Qt.blue))
self.methodFontColor.setColor(QColor(Qt.darkGray))
self.decorFontColor.setColor(QColor(Qt.darkBlue))
self.numFontColor.setColor(QColor("#4e9a06"))
self.commentFontColor.setColor(QColor(Qt.gray))
self.commentBlockFontColor.setColor(QColor(Qt.gray))
self.stderrFontColor.setColor(QColor(Qt.red))
@@ -339,13 +373,20 @@ def _resetFontColor(self):
self.doubleQuoteFontColor.setColor(QColor(Qt.blue))
self.tripleSingleQuoteFontColor.setColor(QColor(Qt.blue))
self.tripleDoubleQuoteFontColor.setColor(QColor(Qt.blue))
self.marginBackgroundColor.setColor(QColor("#f9f9f9"))
self.marginForegroundColor.setColor(QColor("#3E3EE3"))
self.selectionBackgroundColor.setColor(QColor("#babdb6"))
self.selectionForegroundColor.setColor(QColor("#2e3436"))
self.matchedBraceBackgroundColor.setColor(QColor("#b7f907"))
self.matchedBraceForegroundColor.setColor(QColor("#000000"))

def _resetFontColorEditor(self):
self.defaultFontColorEditor.setColor(QColor(Qt.black))
self.keywordFontColorEditor.setColor(QColor(Qt.darkGreen))
self.classFontColorEditor.setColor(QColor(Qt.blue))
self.methodFontColorEditor.setColor(QColor(Qt.darkGray))
self.decorFontColorEditor.setColor(QColor(Qt.darkBlue))
self.numFontColorEditor.setColor(QColor("#4e9a06"))
self.commentFontColorEditor.setColor(QColor(Qt.gray))
self.commentBlockFontColorEditor.setColor(QColor(Qt.gray))
self.paperBackgroundColorEditor.setColor(QColor(Qt.white))
@@ -355,6 +396,14 @@ def _resetFontColorEditor(self):
self.doubleQuoteFontColorEditor.setColor(QColor(Qt.blue))
self.tripleSingleQuoteFontColorEditor.setColor(QColor(Qt.blue))
self.tripleDoubleQuoteFontColorEditor.setColor(QColor(Qt.blue))
self.edgeColorEditor.setColor(QColor("#FF0000"))
self.marginBackgroundColorEditor.setColor(QColor("#f9f9f9"))
self.marginForegroundColorEditor.setColor(QColor("#3E3EE3"))
self.foldColorEditor.setColor(QColor("#f4f4f4"))
self.selectionBackgroundColorEditor.setColor(QColor("#babdb6"))
self.selectionForegroundColorEditor.setColor(QColor("#2e3436"))
self.matchedBraceBackgroundColorEditor.setColor(QColor("#b7f907"))
self.matchedBraceForegroundColorEditor.setColor(QColor("#000000"))

def reject(self):
self.restoreSettings()

0 comments on commit 45b045d

Please sign in to comment.
You can’t perform that action at this time.