Adapted the colors of the symbols viewer for dark color themes. eric7

Fri, 24 Dec 2021 16:36:44 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 24 Dec 2021 16:36:44 +0100
branch
eric7
changeset 8853
efcceef1e26b
parent 8852
923d8d251db9
child 8854
68c67538da4e

Adapted the colors of the symbols viewer for dark color themes.

eric7/UI/SymbolsWidget.py file | annotate | diff | comparison | revisions
--- a/eric7/UI/SymbolsWidget.py	Fri Dec 24 15:17:59 2021 +0100
+++ b/eric7/UI/SymbolsWidget.py	Fri Dec 24 16:36:44 2021 +0100
@@ -18,6 +18,8 @@
 from PyQt6.QtGui import QColor
 from PyQt6.QtWidgets import QWidget, QHeaderView, QAbstractItemView
 
+from EricWidgets.EricApplication import ericApp
+
 from .Ui_SymbolsWidget import Ui_SymbolsWidget
 
 import UI.PixmapCache
@@ -46,6 +48,8 @@
             self.tr("Name"),
         ]
         
+        self.__isDark = ericApp().usesDarkPalette()
+        
         self.__tables = [
             # first   last     display name
             (0x0, 0x1f, self.tr("Control Characters")),
@@ -377,24 +381,39 @@
             role == Qt.ItemDataRole.BackgroundRole and
             index.column() == 0
         ):
-            # TODO: adapt color to current palette
-            return QColor(Qt.GlobalColor.lightGray)
+            if self.__isDark:
+                return QColor("#4d4d4d")
+            else:
+                return QColor(Qt.GlobalColor.lightGray)
         
         if role == Qt.ItemDataRole.ForegroundRole:
             char = chr(symbolId)
-            # TODO: adapt color to current palette
-            if self.__isDigit(char):
-                return QColor(Qt.GlobalColor.darkBlue)
-            elif self.__isLetter(char):
-                return QColor(Qt.GlobalColor.darkGreen)
-            elif self.__isMark(char):
-                return QColor(Qt.GlobalColor.darkRed)
-            elif self.__isSymbol(char):
-                return QColor(Qt.GlobalColor.black)
-            elif self.__isPunct(char):
-                return QColor(Qt.GlobalColor.darkMagenta)
+            if self.__isDark:
+                if self.__isDigit(char):
+                    return QColor("#8787ff")
+                elif self.__isLetter(char):
+                    return QColor("#87ff87")
+                elif self.__isMark(char):
+                    return QColor("#ff8787")
+                elif self.__isSymbol(char):
+                    return QColor("#ffc060")
+                elif self.__isPunct(char):
+                    return QColor("#d080ff")
+                else:
+                    return QColor(Qt.GlobalColor.lightGray)
             else:
-                return QColor(Qt.GlobalColor.darkGray)
+                if self.__isDigit(char):
+                    return QColor(Qt.GlobalColor.darkBlue)
+                elif self.__isLetter(char):
+                    return QColor(Qt.GlobalColor.darkGreen)
+                elif self.__isMark(char):
+                    return QColor(Qt.GlobalColor.darkRed)
+                elif self.__isSymbol(char):
+                    return QColor(Qt.GlobalColor.darkYellow)
+                elif self.__isPunct(char):
+                    return QColor(Qt.GlobalColor.darkMagenta)
+                else:
+                    return QColor(Qt.GlobalColor.darkGray)
         
         if (
             role == Qt.ItemDataRole.TextAlignmentRole and

eric ide

mercurial