--- a/Preferences/__init__.py Fri Jun 23 18:46:40 2017 +0200 +++ b/Preferences/__init__.py Sat Jun 24 12:15:03 2017 +0200 @@ -1415,6 +1415,17 @@ hexEditorDefaults["Font"] = "Courier,10,-1,5,50,0,0,0,0,0" else: hexEditorDefaults["Font"] = "Monospace,10,-1,5,50,0,0,0,0,0" + + # defaults for Diff colors + diffColourDefaults = { + "TextColor": QColor(0, 0, 0), + "AddedColor": QColor(190, 237, 190), + "RemovedColor": QColor(237, 190, 190), + "ReplacedColor": QColor(190, 190, 237), + "ContextColor": QColor(255, 220, 168), + "HeaderColor": QColor(237, 237, 190), + "BadWhitespaceColor": QColor(255, 0, 0, 192), + } def readToolGroups(prefClass=Prefs): @@ -3452,6 +3463,40 @@ prefClass.settings.setValue("HexEditor/" + key, value.toString()) else: prefClass.settings.setValue("HexEditor/" + key, value) + + +def getDiffColour(key, prefClass=Prefs): + """ + Module function to retrieve the colours for the diff highlighter. + + @param key the key of the value to get + @param prefClass preferences class used as the storage area + @return the requested editor colour + """ + col = prefClass.settings.value("Diff/" + key) + if col is not None: + if len(col) == 9: + # color string with alpha + return QColor.fromRgba(int(col[1:], 16)) + else: + return QColor(col) + else: + return prefClass.diffColourDefaults[key] + + +def setDiffColour(key, value, prefClass=Prefs): + """ + Module function to store the diff highlighter colours. + + @param key the key of the colour to be set + @param value the colour to be set + @param prefClass preferences class used as the storage area + """ + if value.alpha() < 255: + val = "#{0:8x}".format(value.rgba()) + else: + val = value.name() + prefClass.settings.setValue("Diff/" + key, val) def getGeometry(key, prefClass=Prefs):