51 64, |
50 64, |
52 QCoreApplication.translate("EricToolBarManager", "extra large (64 px)"), |
51 QCoreApplication.translate("EricToolBarManager", "extra large (64 px)"), |
53 ), |
52 ), |
54 } |
53 } |
55 |
54 |
56 def __init__(self, ui=None, parent=None): |
55 def __init__(self, ui=None, iconSize="", parent=None): |
57 """ |
56 """ |
58 Constructor |
57 Constructor |
59 |
58 |
60 @param ui reference to the user interface object |
59 @param ui reference to the user interface object (defaults to None) |
61 @type UI.UserInterface |
60 @type UI.UserInterface (optional) |
62 @param parent reference to the parent object |
61 @param iconSize string giving the icon size (one of the sizes defined by the |
63 @type QObject |
62 IconSizes dictionary) (defaults to "") |
|
63 @type str (optional) |
|
64 @param parent reference to the parent object (defaults to None) |
|
65 @type QObject (optional) |
64 """ |
66 """ |
65 super().__init__(parent) |
67 super().__init__(parent) |
66 |
68 |
67 self.__mainWindow = None |
69 self.__mainWindow = None |
68 self.__ui = ui |
70 self.__ui = ui |
|
71 self.__iconSizeStr = "" |
69 |
72 |
70 self.__toolBars = {} |
73 self.__toolBars = {} |
71 # maps toolbar IDs to actions |
74 # maps toolbar IDs to actions |
72 self.__toolBarsWithSeparators = {} |
75 self.__toolBarsWithSeparators = {} |
73 # maps toolbar IDs to actions incl. separators |
76 # maps toolbar IDs to actions incl. separators |
186 @type str |
189 @type str |
187 """ |
190 """ |
188 if toolBar is None: |
191 if toolBar is None: |
189 return |
192 return |
190 |
193 |
191 iconSizeStr = Preferences.getIcons("IconSize") |
194 if self.__iconSizeStr: |
192 if iconSizeStr: |
|
193 with contextlib.suppress(KeyError): |
195 with contextlib.suppress(KeyError): |
194 iconSize = EricToolBarManager.IconSizes[iconSizeStr][0] |
196 iconSize = EricToolBarManager.IconSizes[self.__iconSizeStr][0] |
195 toolBar.setIconSize(QSize(iconSize, iconSize)) |
197 toolBar.setIconSize(QSize(iconSize, iconSize)) |
196 |
198 |
197 newActions = [] |
199 newActions = [] |
198 newActionsWithSeparators = [] |
200 newActionsWithSeparators = [] |
199 actions = toolBar.actions() |
201 actions = toolBar.actions() |
618 if tmarker != EricToolBarManager.ToolBarMarker: |
620 if tmarker != EricToolBarManager.ToolBarMarker: |
619 return False |
621 return False |
620 |
622 |
621 toolBarCount = stream.readUInt16() |
623 toolBarCount = stream.readUInt16() |
622 for _i in range(toolBarCount): |
624 for _i in range(toolBarCount): |
623 objectName = Utilities.readStringFromStream(stream) |
625 objectName = EricUtilities.readStringFromStream(stream) |
624 actionCount = stream.readUInt16() |
626 actionCount = stream.readUInt16() |
625 actions = [] |
627 actions = [] |
626 for _j in range(actionCount): |
628 for _j in range(actionCount): |
627 actionName = Utilities.readStringFromStream(stream) |
629 actionName = EricUtilities.readStringFromStream(stream) |
628 if actionName: |
630 if actionName: |
629 action = self.__findAction(actionName) |
631 action = self.__findAction(actionName) |
630 if action is not None: |
632 if action is not None: |
631 actions.append(action) |
633 actions.append(action) |
632 else: |
634 else: |
641 |
643 |
642 oldCustomToolBars = self.__customToolBars[:] |
644 oldCustomToolBars = self.__customToolBars[:] |
643 |
645 |
644 toolBarCount = stream.readUInt16() |
646 toolBarCount = stream.readUInt16() |
645 for _i in range(toolBarCount): |
647 for _i in range(toolBarCount): |
646 objectName = Utilities.readStringFromStream(stream) |
648 objectName = EricUtilities.readStringFromStream(stream) |
647 toolBarTitle = Utilities.readStringFromStream(stream) |
649 toolBarTitle = EricUtilities.readStringFromStream(stream) |
648 actionCount = stream.readUInt16() |
650 actionCount = stream.readUInt16() |
649 actions = [] |
651 actions = [] |
650 for _j in range(actionCount): |
652 for _j in range(actionCount): |
651 actionName = Utilities.readStringFromStream(stream) |
653 actionName = EricUtilities.readStringFromStream(stream) |
652 if actionName: |
654 if actionName: |
653 action = self.__findAction(actionName) |
655 action = self.__findAction(actionName) |
654 if action is not None: |
656 if action is not None: |
655 actions.append(action) |
657 actions.append(action) |
656 else: |
658 else: |
806 """ |
808 """ |
807 if tbID not in self.__defaultToolBars: |
809 if tbID not in self.__defaultToolBars: |
808 return [] |
810 return [] |
809 return self.__defaultToolBars[tbID][:] |
811 return self.__defaultToolBars[tbID][:] |
810 |
812 |
811 @pyqtSlot() |
813 def setIconSize(self, iconSize): |
812 def preferencesChanged(self): |
814 """ |
813 """ |
815 Public method to set the icon size. |
814 Public slot to handle a change of preferences. |
816 |
815 """ |
817 @param iconSize string giving the icon size (one of the sizes defined by the |
816 iconSizeStr = Preferences.getIcons("IconSize") |
818 IconSizes dictionary) |
817 if iconSizeStr: |
819 @type str |
|
820 """ |
|
821 self.__iconSizeStr = iconSize |
|
822 if self.__iconSizeStr: |
818 try: |
823 try: |
819 iconSize = EricToolBarManager.IconSizes[iconSizeStr][0] |
824 iconSize = EricToolBarManager.IconSizes[self.__iconSizeStr][0] |
820 except KeyError: |
825 except KeyError: |
821 # determine icon size through the style |
826 # determine icon size through the style |
822 iconSize = ( |
827 iconSize = ( |
823 list(self.__allToolBars.items()[0]) |
828 list(self.__allToolBars.items()[0]) |
824 .style() |
829 .style() |