E5Gui/E5ToolBarManager.py

branch
5_1_x
changeset 931
d8a11b6a7d49
parent 824
360e007523bd
child 945
8cd4d08fa9f6
child 1113
95d837803666
--- a/E5Gui/E5ToolBarManager.py	Thu Mar 03 19:30:14 2011 +0100
+++ b/E5Gui/E5ToolBarManager.py	Fri Mar 04 18:28:04 2011 +0100
@@ -289,11 +289,12 @@
         return toolBar is not None and \
                id(toolBar) in self.__defaultToolBars
     
-    def createToolBar(self, title):
+    def createToolBar(self, title, name=""):
         """
         Public method to create a custom toolbar.
         
         @param title title to be used for the toolbar (string)
+        @param name optional name for the new toolbar (string)
         @return reference to the created toolbar (QToolBar)
         """
         if self.__mainWindow is None:
@@ -301,12 +302,13 @@
         
         toolBar = QToolBar(title, self.__mainWindow)
         toolBar.setToolTip(title)
-        index = 1
-        customPrefix = "__CustomPrefix__"
-        name = "{0}{1:d}".format(customPrefix, index)
-        while self.__toolBarByName(name) is not None:
-            index += 1
+        if not name:
+            index = 1
+            customPrefix = "__CustomPrefix__"
             name = "{0}{1:d}".format(customPrefix, index)
+            while self.__toolBarByName(name) is not None:
+                index += 1
+                name = "{0}{1:d}".format(customPrefix, index)
         toolBar.setObjectName(name)
         self.__mainWindow.addToolBar(toolBar)
         
@@ -547,7 +549,7 @@
                 toolBar.setWindowTitle(toolBarTitle)
                 oldCustomToolBars.remove(toolBar)
             else:
-                toolBar = self.createToolBar(toolBarTitle)
+                toolBar = self.createToolBar(toolBarTitle, objectName)
             if toolBar is not None:
                 toolBar.setObjectName(objectName)
                 self.setToolBar(toolBar, actions)

eric ide

mercurial