SelectionEncloser/ConfigurationPage/SelectionEncloserPage.py

changeset 39
401d0bab970d
parent 38
f9f7c3af2f18
child 41
e747eb5f3f43
--- a/SelectionEncloser/ConfigurationPage/SelectionEncloserPage.py	Wed Jan 01 11:59:04 2020 +0100
+++ b/SelectionEncloser/ConfigurationPage/SelectionEncloserPage.py	Wed Apr 08 19:22:13 2020 +0200
@@ -14,6 +14,8 @@
 from PyQt5.QtCore import pyqtSlot, Qt
 from PyQt5.QtWidgets import QTreeWidgetItem, QInputDialog, QLineEdit, QDialog
 
+from E5Gui.E5Application import e5App
+
 from Preferences.ConfigurationPages.ConfigurationPageBase import \
     ConfigurationPageBase
 from .Ui_SelectionEncloserPage import Ui_SelectionEncloserPage
@@ -35,16 +37,31 @@
         self.setupUi(self)
         self.setObjectName("SelectionEncloserPage")
         
+        try:
+            usesDarkPalette = e5App().usesDarkPalette()
+        except AttributeError:
+            from PyQt5.QtGui import QPalette
+            palette = e5App().palette()
+            lightness = palette.color(QPalette.Window).lightness()
+            usesDarkPalette = lightness <= 128
+        if usesDarkPalette:
+           iconSuffix = "dark"
+        else:
+            iconSuffix = "light"
+        
         self.editButton.setIcon(UI.PixmapCache.getIcon(
-            os.path.join("SelectionEncloser", "icons", "edit.png")))
-        self.addButton.setIcon(UI.PixmapCache.getIcon("plus.png"))
-        self.deleteButton.setIcon(UI.PixmapCache.getIcon("minus.png"))
-        self.upButton.setIcon(UI.PixmapCache.getIcon("1uparrow.png"))
-        self.downButton.setIcon(UI.PixmapCache.getIcon("1downarrow.png"))
+            os.path.join("SelectionEncloser", "icons",
+                         "edit-{0}".format(iconSuffix))))
+        self.addButton.setIcon(UI.PixmapCache.getIcon("plus"))
+        self.deleteButton.setIcon(UI.PixmapCache.getIcon("minus"))
+        self.upButton.setIcon(UI.PixmapCache.getIcon("1uparrow"))
+        self.downButton.setIcon(UI.PixmapCache.getIcon("1downarrow"))
         self.addMenuButton.setIcon(UI.PixmapCache.getIcon(
-            os.path.join("SelectionEncloser", "icons", "topAdd.png")))
+            os.path.join("SelectionEncloser", "icons",
+                         "topAdd-{0}".format(iconSuffix))))
         self.addSeparatorButton.setIcon(UI.PixmapCache.getIcon(
-            os.path.join("SelectionEncloser", "icons", "separatorAdd.png")))
+            os.path.join("SelectionEncloser", "icons",
+                         "separatorAdd-{0}".format(iconSuffix))))
         
         self.editButton.setEnabled(False)
         self.addButton.setEnabled(False)

eric ide

mercurial