src/eric7/EricWidgets/EricToolBarManager.py

branch
eric7
changeset 10933
95a15b70f7bb
parent 10439
21c28b0f9e41
child 10992
c3b070373492
--- a/src/eric7/EricWidgets/EricToolBarManager.py	Fri Sep 27 11:00:27 2024 +0200
+++ b/src/eric7/EricWidgets/EricToolBarManager.py	Fri Sep 27 17:27:11 2024 +0200
@@ -16,11 +16,10 @@
     QIODevice,
     QObject,
     QSize,
-    pyqtSlot,
 )
 from PyQt6.QtWidgets import QStyle, QToolBar
 
-from eric7 import Preferences, Utilities
+from eric7 import EricUtilities
 
 
 class EricToolBarManager(QObject):
@@ -53,19 +52,23 @@
         ),
     }
 
-    def __init__(self, ui=None, parent=None):
+    def __init__(self, ui=None, iconSize="", parent=None):
         """
         Constructor
 
-        @param ui reference to the user interface object
-        @type UI.UserInterface
-        @param parent reference to the parent object
-        @type QObject
+        @param ui reference to the user interface object (defaults to None)
+        @type UI.UserInterface (optional)
+        @param iconSize string giving the icon size (one of the sizes defined by the
+            IconSizes dictionary) (defaults to "")
+        @type str (optional)
+        @param parent reference to the parent object (defaults to None)
+        @type QObject (optional)
         """
         super().__init__(parent)
 
         self.__mainWindow = None
         self.__ui = ui
+        self.__iconSizeStr = ""
 
         self.__toolBars = {}
         # maps toolbar IDs to actions
@@ -188,10 +191,9 @@
         if toolBar is None:
             return
 
-        iconSizeStr = Preferences.getIcons("IconSize")
-        if iconSizeStr:
+        if self.__iconSizeStr:
             with contextlib.suppress(KeyError):
-                iconSize = EricToolBarManager.IconSizes[iconSizeStr][0]
+                iconSize = EricToolBarManager.IconSizes[self.__iconSizeStr][0]
                 toolBar.setIconSize(QSize(iconSize, iconSize))
 
         newActions = []
@@ -620,11 +622,11 @@
 
         toolBarCount = stream.readUInt16()
         for _i in range(toolBarCount):
-            objectName = Utilities.readStringFromStream(stream)
+            objectName = EricUtilities.readStringFromStream(stream)
             actionCount = stream.readUInt16()
             actions = []
             for _j in range(actionCount):
-                actionName = Utilities.readStringFromStream(stream)
+                actionName = EricUtilities.readStringFromStream(stream)
                 if actionName:
                     action = self.__findAction(actionName)
                     if action is not None:
@@ -643,12 +645,12 @@
 
         toolBarCount = stream.readUInt16()
         for _i in range(toolBarCount):
-            objectName = Utilities.readStringFromStream(stream)
-            toolBarTitle = Utilities.readStringFromStream(stream)
+            objectName = EricUtilities.readStringFromStream(stream)
+            toolBarTitle = EricUtilities.readStringFromStream(stream)
             actionCount = stream.readUInt16()
             actions = []
             for _j in range(actionCount):
-                actionName = Utilities.readStringFromStream(stream)
+                actionName = EricUtilities.readStringFromStream(stream)
                 if actionName:
                     action = self.__findAction(actionName)
                     if action is not None:
@@ -808,15 +810,18 @@
             return []
         return self.__defaultToolBars[tbID][:]
 
-    @pyqtSlot()
-    def preferencesChanged(self):
-        """
-        Public slot to handle a change of preferences.
+    def setIconSize(self, iconSize):
         """
-        iconSizeStr = Preferences.getIcons("IconSize")
-        if iconSizeStr:
+        Public method to set the icon size.
+
+        @param iconSize string giving the icon size (one of the sizes defined by the
+            IconSizes dictionary)
+        @type str
+        """
+        self.__iconSizeStr = iconSize
+        if self.__iconSizeStr:
             try:
-                iconSize = EricToolBarManager.IconSizes[iconSizeStr][0]
+                iconSize = EricToolBarManager.IconSizes[self.__iconSizeStr][0]
             except KeyError:
                 # determine icon size through the style
                 iconSize = (

eric ide

mercurial