Added code to include the Breeze icons depending on window lightness factor.

Mon, 16 Mar 2020 19:25:47 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 16 Mar 2020 19:25:47 +0100
changeset 7461
1f239d5f89b8
parent 7460
bba5648eac76
child 7462
3837031e8e54

Added code to include the Breeze icons depending on window lightness factor.

eric6/Toolbox/Startup.py file | annotate | diff | comparison | revisions
eric6/eric6.py file | annotate | diff | comparison | revisions
--- a/eric6/Toolbox/Startup.py	Mon Mar 16 19:24:18 2020 +0100
+++ b/eric6/Toolbox/Startup.py	Mon Mar 16 19:25:47 2020 +0100
@@ -12,6 +12,7 @@
 import sys
 
 from PyQt5.QtCore import QTranslator, QLocale, QLibraryInfo, QDir
+from PyQt5.QtGui import QPalette
 from PyQt5.QtWidgets import QApplication
 
 from E5Gui.E5Application import E5Application
@@ -114,13 +115,28 @@
     return (None, False)
 
 
-def initializeResourceSearchPath():
+def initializeResourceSearchPath(application):
     """
     Module function to initialize the default mime source factory.
+    
+    @param application reference to the application objetc
+    @type QGuiApplication
     """
     import Preferences
     
+    palette = application.palette()
+    lightness = palette.color(QPalette.Window).lightness()
+    if lightness > 128:
+        # light desktop
+        iconPath = "breeze"
+    else:
+        # dark desktop
+        iconPath = "breeze-dark"
     defaultIconPaths = [
+        # add paths for vector graphics
+        os.path.join(getConfig('ericIconDir'), iconPath),
+        os.path.join(getConfig('ericIconDir'), iconPath, "languages"),
+        # add old default pixel icons
         os.path.join(getConfig('ericIconDir'), "default"),
         os.path.join(getConfig('ericIconDir'), "default", "languages"),
     ]
@@ -232,7 +248,7 @@
     # the following code depends upon a valid application object
     import Preferences
     
-    initializeResourceSearchPath()
+    initializeResourceSearchPath(app)
     QApplication.setWindowIcon(UI.PixmapCache.getIcon("eric.png"))
     
     qtTransDir = Preferences.getQtTranslationsDir()
--- a/eric6/eric6.py	Mon Mar 16 19:24:18 2020 +0100
+++ b/eric6/eric6.py	Mon Mar 16 19:25:47 2020 +0100
@@ -307,7 +307,7 @@
         handleSingleApplication(ddindex)
     
     # set the search path for icons
-    Startup.initializeResourceSearchPath()
+    Startup.initializeResourceSearchPath(app)
     
     # generate and show a splash window, if not suppressed
     from UI.SplashScreen import SplashScreen, NoneSplashScreen

eric ide

mercurial