src/eric7/Preferences/ConfigurationPages/InterfaceLightPage.py

branch
eric7
changeset 10518
1682f3203ae5
parent 10428
a071d4065202
child 10683
779cda568acb
diff -r aecd5a8c958c -r 1682f3203ae5 src/eric7/Preferences/ConfigurationPages/InterfaceLightPage.py
--- a/src/eric7/Preferences/ConfigurationPages/InterfaceLightPage.py	Sun Jan 21 13:00:42 2024 +0100
+++ b/src/eric7/Preferences/ConfigurationPages/InterfaceLightPage.py	Sun Jan 21 15:38:51 2024 +0100
@@ -10,11 +10,13 @@
 import glob
 import os
 
-from PyQt6.QtCore import QTranslator
-from PyQt6.QtWidgets import QStyleFactory
+from PyQt6.QtCore import QTranslator, pyqtSlot
+from PyQt6.QtWidgets import QColorDialog, QDialog, QStyleFactory
 
 from eric7 import Globals, Preferences
+from eric7.EricGui import EricPixmapCache
 from eric7.EricWidgets.EricApplication import ericApp
+from eric7.EricWidgets.EricIconBar import EricIconBar
 from eric7.EricWidgets.EricPathPicker import EricPathPickerModes
 from eric7.Globals import getConfig
 
@@ -28,14 +30,20 @@
     use).
     """
 
-    def __init__(self):
+    def __init__(self, withSidebars=False):
         """
         Constructor
+
+        @param withSidebars flag indicating to show the sidebars configuration group
+            (defaults to False)
+        @type bool (optional)
         """
         super().__init__()
         self.setupUi(self)
         self.setObjectName("InterfacePage")
 
+        self.__withSidebars = withSidebars
+
         self.styleSheetPicker.setMode(EricPathPickerModes.OPEN_FILE_MODE)
         self.styleSheetPicker.setFilters(
             self.tr(
@@ -53,6 +61,11 @@
         self.itemSelectionStyleComboBox.addItem(self.tr("Double Click"), "doubleclick")
         self.itemSelectionStyleComboBox.addItem(self.tr("Single Click"), "singleclick")
 
+        for iconBarSize in EricIconBar.BarSizes:
+            self.iconSizeComboBox.addItem(
+                EricIconBar.BarSizes[iconBarSize][2], iconBarSize
+            )
+
         # set initial values
         self.__populateStyleCombo()
         self.__populateLanguageCombo()
@@ -67,6 +80,18 @@
             itemSelectionIndex = 0
         self.itemSelectionStyleComboBox.setCurrentIndex(itemSelectionIndex)
 
+        if self.__withSidebars:
+            self.iconSizeComboBox.setCurrentIndex(
+                self.iconSizeComboBox.findData(Preferences.getUI("IconBarSize"))
+            )
+            self.__iconBarColor = Preferences.getUI("IconBarColor")
+            self.__setIconBarSamples()
+
+            # connect the icon size combo box after initialization is complete
+            self.iconSizeComboBox.currentIndexChanged.connect(self.__setIconBarSamples)
+        else:
+            self.sidebarsGroup.setVisible(False)
+
     def save(self):
         """
         Public slot to save the Interface configuration.
@@ -88,6 +113,11 @@
         )
         Preferences.setUILanguage(uiLanguage)
 
+        if self.__withSidebars:
+            # save the sidebars settings
+            Preferences.setUI("IconBarSize", self.iconSizeComboBox.currentData())
+            Preferences.setUI("IconBarColor", self.__iconBarColor)
+
     def __populateStyleCombo(self):
         """
         Private method to populate the style combo box.
@@ -141,15 +171,57 @@
             self.languageComboBox.addItem(locales[locale], locale)
         self.languageComboBox.setCurrentIndex(currentIndex)
 
+    @pyqtSlot()
+    def __setIconBarSamples(self):
+        """
+        Private slot to set the colors of the icon bar color samples.
+        """
+        iconBarSize = self.iconSizeComboBox.currentData()
+        iconSize, borderSize = EricIconBar.BarSizes[iconBarSize][:2]
+        size = iconSize + 2 * borderSize
 
-def create(dlg):  # noqa: U100
+        self.sampleLabel.setFixedSize(size, size)
+        self.sampleLabel.setStyleSheet(
+            EricIconBar.LabelStyleSheetTemplate.format(self.__iconBarColor.name())
+        )
+        self.sampleLabel.setPixmap(
+            EricPixmapCache.getIcon("sbDebugViewer96").pixmap(iconSize, iconSize)
+        )
+
+        self.highlightedSampleLabel.setFixedSize(size, size)
+        self.highlightedSampleLabel.setStyleSheet(
+            EricIconBar.LabelStyleSheetTemplate.format(
+                self.__iconBarColor.darker().name()
+            )
+        )
+        self.highlightedSampleLabel.setPixmap(
+            EricPixmapCache.getIcon("sbDebugViewer96").pixmap(iconSize, iconSize)
+        )
+
+    @pyqtSlot()
+    def on_iconBarButton_clicked(self):
+        """
+        Private slot to select the icon bar color.
+        """
+        colDlg = QColorDialog(self)
+        # Set current colour last to avoid conflicts with alpha channel
+        colDlg.setCurrentColor(self.__iconBarColor)
+        if colDlg.exec() == QDialog.DialogCode.Accepted:
+            self.__iconBarColor = colDlg.selectedColor()
+            self.__setIconBarSamples()
+
+
+def create(dlg, withSidebars=False):  # noqa: U100
     """
     Module function to create the configuration page.
 
     @param dlg reference to the configuration dialog
     @type ConfigurationDialog
+    @param withSidebars flag indicating to show the sidebars configuration group
+        (defaults to False)
+    @type bool (optional)
     @return reference to the instantiated page
     @rtype ConfigurationPageBase
     """
-    page = InterfaceLightPage()
+    page = InterfaceLightPage(withSidebars=withSidebars)
     return page

eric ide

mercurial