Added theme_safe_colors method code in MainGUI.py

This commit is contained in:
Ali Khalil
2022-04-18 12:52:44 +03:00
parent e23d89779c
commit 67a7f8b8a2

View File

@@ -54,7 +54,39 @@ class MainGUI(QtWidgets.QMainWindow):
final_save = QtCore.pyqtSignal(name='saveBeforeExit')
# screenChanged = QtCore.pyqtSignal(QtGui.QScreen, QtGui.QScreen)
# Mapping of colors used for text on Light theme to
# similar colors safe for use on Dark theme
# 'input_color': (light_color, dark_color),
theme_safe_colors = {
"blue": "#1F80FF",
"brown": "#CC9966",
"darkgreen": "#008015",
"darkorange": "darkorange",
"green": "#00CC22",
"indigo": "#9457EB",
"magenta": "magenta",
"orange": "orange",
"purple": "#B284BE",
"red": "salmon",
"teal": "teal",
"tomato": "tomato",
}
def theme_safe_color(self, color):
"""
Some colors do not work well with light or dark backgrounds making them unreadable in the wrong
theme. For an approved color value this will return a similar color better suited for the current theme.
:param color: color to be replaced
:return: similar color better suited for dark or light theme
"""
if color in self.theme_safe_colors:
if self.app.options['global_theme'] == 'light':
return color
else:
return self.theme_safe_colors[color]
else:
return color
# https://www.w3.org/TR/SVG11/types.html#ColorKeywords