287 @param toolBar reference to the toolbar to be checked (QToolBar) |
287 @param toolBar reference to the toolbar to be checked (QToolBar) |
288 """ |
288 """ |
289 return toolBar is not None and \ |
289 return toolBar is not None and \ |
290 id(toolBar) in self.__defaultToolBars |
290 id(toolBar) in self.__defaultToolBars |
291 |
291 |
292 def createToolBar(self, title): |
292 def createToolBar(self, title, name=""): |
293 """ |
293 """ |
294 Public method to create a custom toolbar. |
294 Public method to create a custom toolbar. |
295 |
295 |
296 @param title title to be used for the toolbar (string) |
296 @param title title to be used for the toolbar (string) |
|
297 @param name optional name for the new toolbar (string) |
297 @return reference to the created toolbar (QToolBar) |
298 @return reference to the created toolbar (QToolBar) |
298 """ |
299 """ |
299 if self.__mainWindow is None: |
300 if self.__mainWindow is None: |
300 return None |
301 return None |
301 |
302 |
302 toolBar = QToolBar(title, self.__mainWindow) |
303 toolBar = QToolBar(title, self.__mainWindow) |
303 toolBar.setToolTip(title) |
304 toolBar.setToolTip(title) |
304 index = 1 |
305 if not name: |
305 customPrefix = "__CustomPrefix__" |
306 index = 1 |
306 name = "{0}{1:d}".format(customPrefix, index) |
307 customPrefix = "__CustomPrefix__" |
307 while self.__toolBarByName(name) is not None: |
|
308 index += 1 |
|
309 name = "{0}{1:d}".format(customPrefix, index) |
308 name = "{0}{1:d}".format(customPrefix, index) |
|
309 while self.__toolBarByName(name) is not None: |
|
310 index += 1 |
|
311 name = "{0}{1:d}".format(customPrefix, index) |
310 toolBar.setObjectName(name) |
312 toolBar.setObjectName(name) |
311 self.__mainWindow.addToolBar(toolBar) |
313 self.__mainWindow.addToolBar(toolBar) |
312 |
314 |
313 tbID = id(toolBar) |
315 tbID = id(toolBar) |
314 self.__customToolBars.append(toolBar) |
316 self.__customToolBars.append(toolBar) |
545 toolBar = self.__toolBarByName(objectName) |
547 toolBar = self.__toolBarByName(objectName) |
546 if toolBar is not None: |
548 if toolBar is not None: |
547 toolBar.setWindowTitle(toolBarTitle) |
549 toolBar.setWindowTitle(toolBarTitle) |
548 oldCustomToolBars.remove(toolBar) |
550 oldCustomToolBars.remove(toolBar) |
549 else: |
551 else: |
550 toolBar = self.createToolBar(toolBarTitle) |
552 toolBar = self.createToolBar(toolBarTitle, objectName) |
551 if toolBar is not None: |
553 if toolBar is not None: |
552 toolBar.setObjectName(objectName) |
554 toolBar.setObjectName(objectName) |
553 self.setToolBar(toolBar, actions) |
555 self.setToolBar(toolBar, actions) |
554 |
556 |
555 for tb in oldCustomToolBars: |
557 for tb in oldCustomToolBars: |