53 Private slot to get a toolbar by it's object name. |
53 Private slot to get a toolbar by it's object name. |
54 |
54 |
55 @param name object name of the toolbar (string) |
55 @param name object name of the toolbar (string) |
56 @return reference to the toolbar (QToolBar) |
56 @return reference to the toolbar (QToolBar) |
57 """ |
57 """ |
58 for toolBar in self.__allToolBars.values(): |
58 for toolBar in list(self.__allToolBars.values()): |
59 if toolBar.objectName() == name: |
59 if toolBar.objectName() == name: |
60 return toolBar |
60 return toolBar |
61 return None |
61 return None |
62 |
62 |
63 def __findAction(self, name): |
63 def __findAction(self, name): |
66 |
66 |
67 @param name name of the action to search for (string) |
67 @param name name of the action to search for (string) |
68 @return reference to the action (QAction) |
68 @return reference to the action (QAction) |
69 """ |
69 """ |
70 # check objectName() first |
70 # check objectName() first |
71 for action in self.__allActions.values(): |
71 for action in list(self.__allActions.values()): |
72 if action.objectName() == name: |
72 if action.objectName() == name: |
73 return action |
73 return action |
74 |
74 |
75 # check text() next |
75 # check text() next |
76 for action in self.__allActions.values(): |
76 for action in list(self.__allActions.values()): |
77 if action.text() == name: |
77 if action.text() == name: |
78 return action |
78 return action |
79 |
79 |
80 return None |
80 return None |
81 |
81 |
186 Public method to set the actions of several toolbars. |
186 Public method to set the actions of several toolbars. |
187 |
187 |
188 @param toolBars dictionary with toolbar id as key and |
188 @param toolBars dictionary with toolbar id as key and |
189 a list of actions as value |
189 a list of actions as value |
190 """ |
190 """ |
191 for key, actions in toolBars.items(): |
191 for key, actions in list(toolBars.items()): |
192 tb = self.__allToolBars[key] |
192 tb = self.__allToolBars[key] |
193 self.setToolBar(tb, actions) |
193 self.setToolBar(tb, actions) |
194 |
194 |
195 def setToolBar(self, toolBar, actions): |
195 def setToolBar(self, toolBar, actions): |
196 """ |
196 """ |
276 """ |
276 """ |
277 Public method to get all toolbars added with addToolBar(). |
277 Public method to get all toolbars added with addToolBar(). |
278 |
278 |
279 @return list of all default toolbars (list of QToolBar) |
279 @return list of all default toolbars (list of QToolBar) |
280 """ |
280 """ |
281 return self.__defaultToolBars.values() |
281 return list(self.__defaultToolBars.values()) |
282 |
282 |
283 def isDefaultToolBar(self, toolBar): |
283 def isDefaultToolBar(self, toolBar): |
284 """ |
284 """ |
285 Public method to check, if a toolbar was added with addToolBar(). |
285 Public method to check, if a toolbar was added with addToolBar(). |
286 |
286 |
448 stream.writeUInt16(E4ToolBarManager.ToolBarMarker) |
448 stream.writeUInt16(E4ToolBarManager.ToolBarMarker) |
449 stream.writeUInt16(len(self.__defaultToolBars)) |
449 stream.writeUInt16(len(self.__defaultToolBars)) |
450 for tbID in self.__defaultToolBars: |
450 for tbID in self.__defaultToolBars: |
451 tb = self.__allToolBars[tbID] |
451 tb = self.__allToolBars[tbID] |
452 if tb.objectName(): |
452 if tb.objectName(): |
453 stream.writeString(tb.objectName()) |
453 stream.writeString(tb.objectName().encode()) |
454 else: |
454 else: |
455 stream.writeString(tb.windowTitle()) |
455 stream.writeString(tb.windowTitle().encode()) |
456 stream.writeUInt16(len(self.__toolBars[tbID])) |
456 stream.writeUInt16(len(self.__toolBars[tbID])) |
457 for action in self.__toolBars[tbID]: |
457 for action in self.__toolBars[tbID]: |
458 if action is not None: |
458 if action is not None: |
459 if action.objectName(): |
459 if action.objectName(): |
460 stream.writeString(action.objectName()) |
460 stream.writeString(action.objectName().encode()) |
461 else: |
461 else: |
462 stream.writeString(action.text()) |
462 stream.writeString(action.text().encode()) |
463 else: |
463 else: |
464 stream.writeString("") |
464 stream.writeString("".encode()) |
465 |
465 |
466 # save the custom toolbars |
466 # save the custom toolbars |
467 stream.writeUInt16(E4ToolBarManager.CustomToolBarMarker) |
467 stream.writeUInt16(E4ToolBarManager.CustomToolBarMarker) |
468 stream.writeUInt16(len(self.__toolBars) - len(self.__defaultToolBars)) |
468 stream.writeUInt16(len(self.__toolBars) - len(self.__defaultToolBars)) |
469 for tbID in self.__toolBars: |
469 for tbID in self.__toolBars: |
470 if tbID not in self.__defaultToolBars: |
470 if tbID not in self.__defaultToolBars: |
471 tb = self.__allToolBars[tbID] |
471 tb = self.__allToolBars[tbID] |
472 stream.writeString(tb.objectName()) |
472 stream.writeString(tb.objectName().encode()) |
473 stream.writeString(tb.windowTitle()) |
473 stream.writeString(tb.windowTitle().encode()) |
474 stream.writeUInt16(len(self.__toolBars[tbID])) |
474 stream.writeUInt16(len(self.__toolBars[tbID])) |
475 for action in self.__toolBars[tbID]: |
475 for action in self.__toolBars[tbID]: |
476 if action is not None: |
476 if action is not None: |
477 if action.objectName(): |
477 if action.objectName(): |
478 stream.writeString(action.objectName()) |
478 stream.writeString(action.objectName().encode()) |
479 else: |
479 else: |
480 stream.writeString(action.text()) |
480 stream.writeString(action.text().encode()) |
481 else: |
481 else: |
482 stream.writeString("") |
482 stream.writeString("".encode()) |
483 |
483 |
484 return data |
484 return data |
485 |
485 |
486 def restoreState(self, state, version = 0): |
486 def restoreState(self, state, version = 0): |
487 """ |
487 """ |
505 if tmarker != E4ToolBarManager.ToolBarMarker: |
505 if tmarker != E4ToolBarManager.ToolBarMarker: |
506 return False |
506 return False |
507 |
507 |
508 toolBarCount = stream.readUInt16() |
508 toolBarCount = stream.readUInt16() |
509 for i in range(toolBarCount): |
509 for i in range(toolBarCount): |
510 objectName = stream.readString() |
510 objectName = stream.readString().decode() |
511 actionCount = stream.readUInt16() |
511 actionCount = stream.readUInt16() |
512 actions = [] |
512 actions = [] |
513 for j in range(actionCount): |
513 for j in range(actionCount): |
514 actionName = stream.readString() |
514 actionName = stream.readString().decode() |
515 if actionName: |
515 if actionName: |
516 action = self.__findAction(actionName) |
516 action = self.__findAction(actionName) |
517 if action is not None: |
517 if action is not None: |
518 actions.append(action) |
518 actions.append(action) |
519 else: |
519 else: |
528 |
528 |
529 oldCustomToolBars = self.__customToolBars[:] |
529 oldCustomToolBars = self.__customToolBars[:] |
530 |
530 |
531 toolBarCount = stream.readUInt16() |
531 toolBarCount = stream.readUInt16() |
532 for i in range(toolBarCount): |
532 for i in range(toolBarCount): |
533 objectName = stream.readString() |
533 objectName = stream.readString().decode() |
534 toolBarTitle = stream.readString() |
534 toolBarTitle = stream.readString().decode() |
535 actionCount = stream.readUInt16() |
535 actionCount = stream.readUInt16() |
536 actions = [] |
536 actions = [] |
537 for j in range(actionCount): |
537 for j in range(actionCount): |
538 actionName = stream.readString() |
538 actionName = stream.readString().decode() |
539 if actionName: |
539 if actionName: |
540 action = self.__findAction(actionName) |
540 action = self.__findAction(actionName) |
541 if action is not None: |
541 if action is not None: |
542 actions.append(action) |
542 actions.append(action) |
543 else: |
543 else: |
574 Public method to remove widget actions. |
574 Public method to remove widget actions. |
575 |
575 |
576 @param actions dictionary with toolbar id as key and |
576 @param actions dictionary with toolbar id as key and |
577 a list of widget actions as value |
577 a list of widget actions as value |
578 """ |
578 """ |
579 for tbID in actions.keys()[:]: |
579 for tbID in list(actions.keys())[:]: |
580 toolBar = self.__allToolBars[tbID] |
580 toolBar = self.__allToolBars[tbID] |
581 newActions = self.__toolBars[tbID][:] |
581 newActions = self.__toolBars[tbID][:] |
582 newActionsWithSeparators = self.__toolBarsWithSeparators[tbID][:] |
582 newActionsWithSeparators = self.__toolBarsWithSeparators[tbID][:] |
583 |
583 |
584 removedActions = [] |
584 removedActions = [] |