Sat, 22 May 2021 19:58:24 +0200
Sorted the eric specific extensions into packages named like the corresponding PyQt packages (i.e. EricCore,EricGui and EricWidgets).
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
7923
91e843545d9a
Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7780
diff
changeset
|
3 | # Copyright (c) 2008 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing a toolbar manager class. |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | |
8318
962bce857696
Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
10 | from PyQt6.QtCore import QObject, QByteArray, QDataStream, QIODevice |
962bce857696
Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
11 | from PyQt6.QtWidgets import QToolBar |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
12 | |
2084
d3f083dd0222
Made the fiveth set of Qt5 compatibility changes (some of the previous changes are backed out due to changes in PyQt4).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
13 | import Utilities |
d3f083dd0222
Made the fiveth set of Qt5 compatibility changes (some of the previous changes are backed out due to changes in PyQt4).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
14 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
930
diff
changeset
|
15 | |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8341
diff
changeset
|
16 | class EricToolBarManager(QObject): |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
17 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
18 | Class implementing a toolbar manager. |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
19 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
20 | VersionMarker = 0xffff |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
21 | ToolBarMarker = 0xfefe |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
22 | CustomToolBarMarker = 0xfdfd |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
23 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
930
diff
changeset
|
24 | def __init__(self, ui=None, parent=None): |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
25 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
26 | Constructor |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
27 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
28 | @param ui reference to the user interface object (UI.UserInterface) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
29 | @param parent reference to the parent object (QObject) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
30 | """ |
8218
7c09585bd960
Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
31 | super().__init__(parent) |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
32 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | self.__mainWindow = None |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
34 | self.__ui = ui |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
35 | |
2990
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2953
diff
changeset
|
36 | self.__toolBars = {} |
3621
15f23ed3f216
Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3178
diff
changeset
|
37 | # maps toolbar IDs to actions |
2990
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2953
diff
changeset
|
38 | self.__toolBarsWithSeparators = {} |
3621
15f23ed3f216
Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3178
diff
changeset
|
39 | # maps toolbar IDs to actions incl. separators |
2990
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2953
diff
changeset
|
40 | self.__defaultToolBars = {} |
3621
15f23ed3f216
Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3178
diff
changeset
|
41 | # maps default toolbar IDs to actions |
2990
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2953
diff
changeset
|
42 | self.__customToolBars = [] |
3621
15f23ed3f216
Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3178
diff
changeset
|
43 | # list of custom toolbars |
2990
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2953
diff
changeset
|
44 | self.__allToolBars = {} |
3621
15f23ed3f216
Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3178
diff
changeset
|
45 | # maps toolbar IDs to toolbars |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
46 | |
2990
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2953
diff
changeset
|
47 | self.__categoryToActions = {} |
3621
15f23ed3f216
Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3178
diff
changeset
|
48 | # maps categories to actions |
2990
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2953
diff
changeset
|
49 | self.__actionToCategory = {} |
3621
15f23ed3f216
Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3178
diff
changeset
|
50 | # maps action IDs to categories |
2990
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2953
diff
changeset
|
51 | self.__allActions = {} |
3621
15f23ed3f216
Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3178
diff
changeset
|
52 | # maps action IDs to actions |
2990
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2953
diff
changeset
|
53 | self.__actionToToolBars = {} |
3621
15f23ed3f216
Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3178
diff
changeset
|
54 | # maps action IDs to toolbars |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
55 | |
2990
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2953
diff
changeset
|
56 | self.__widgetActions = {} |
3621
15f23ed3f216
Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3178
diff
changeset
|
57 | # maps widget action IDs to toolbars |
2990
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2953
diff
changeset
|
58 | self.__allWidgetActions = {} |
3621
15f23ed3f216
Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3178
diff
changeset
|
59 | # maps widget action IDs to widget actions |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
60 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
61 | ###################################################### |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
62 | ## Private methods |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
63 | ###################################################### |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
64 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
65 | def __toolBarByName(self, name): |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
66 | """ |
2763
e4794166ad70
Fixed a serious typo.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
67 | Private slot to get a toolbar by its object name. |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
68 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
69 | @param name object name of the toolbar (string) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
70 | @return reference to the toolbar (QToolBar) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
71 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
72 | for toolBar in list(self.__allToolBars.values()): |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
73 | if toolBar.objectName() == name: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
74 | return toolBar |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
75 | return None |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
76 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
77 | def __findAction(self, name): |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
78 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
79 | Private method to find an action by name. |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
80 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
81 | @param name name of the action to search for (string) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
82 | @return reference to the action (QAction) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
83 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
84 | # check objectName() first |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
85 | for action in list(self.__allActions.values()): |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
86 | if action.objectName() == name: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
87 | return action |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
88 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
89 | # check text() next |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
90 | for action in list(self.__allActions.values()): |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
91 | if action.text() == name: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
92 | return action |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
93 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
94 | return None |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
95 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
96 | def __findDefaultToolBar(self, name): |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
97 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
98 | Private method to find a default toolbar by name. |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
99 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
100 | @param name name of the default toolbar to search for (string) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
101 | @return reference to the default toolbar (QToolBar) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
102 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
103 | # check objectName() first |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
104 | for tbID in self.__defaultToolBars: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
105 | tb = self.__allToolBars[tbID] |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
106 | if tb.objectName() == name: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
107 | return tb |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
108 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
109 | # check windowTitle() next |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
110 | for tbID in self.__defaultToolBars: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
111 | tb = self.__allToolBars[tbID] |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
112 | if tb.windowTitle() == name: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
113 | return tb |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
114 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
115 | return None |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
116 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
117 | ###################################################### |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
118 | ## Public methods |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
119 | ###################################################### |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
120 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
121 | def setMainWindow(self, mainWindow): |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
122 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
123 | Public method to set the reference to the main window. |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
124 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
125 | @param mainWindow reference to the main window (QMainWindow) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
126 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
127 | self.__mainWindow = mainWindow |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
128 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
129 | def mainWindow(self): |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
130 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
131 | Public method to get the reference to the main window. |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
132 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
133 | @return reference to the main window (QMainWindow) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
134 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
135 | return self.__mainWindow |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
136 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
137 | def addToolBar(self, toolBar, category): |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
138 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
139 | Public method to add a toolbar to be managed. |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
140 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
141 | @param toolBar reference to the toolbar to be managed (QToolBar) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
142 | @param category category for the toolbar (string) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
143 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
144 | if toolBar is None: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
145 | return |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
146 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
147 | newActions = [] |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
148 | newActionsWithSeparators = [] |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
149 | actions = toolBar.actions() |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
150 | for action in actions: |
824
360e007523bd
Fixed an issue in the toolbar manager where adding a toolbar a second time caused actions to be listed multiple times.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
151 | actID = id(action) |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
152 | self.addAction(action, category) |
824
360e007523bd
Fixed an issue in the toolbar manager where adding a toolbar a second time caused actions to be listed multiple times.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
153 | if actID in self.__widgetActions: |
360e007523bd
Fixed an issue in the toolbar manager where adding a toolbar a second time caused actions to be listed multiple times.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
154 | self.__widgetActions[actID] = toolBar |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
155 | newActionsWithSeparators.append(action) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
156 | if action.isSeparator(): |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
157 | action = None |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
158 | else: |
824
360e007523bd
Fixed an issue in the toolbar manager where adding a toolbar a second time caused actions to be listed multiple times.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
159 | if toolBar not in self.__actionToToolBars[actID]: |
360e007523bd
Fixed an issue in the toolbar manager where adding a toolbar a second time caused actions to be listed multiple times.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
160 | self.__actionToToolBars[actID].append(toolBar) |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
161 | newActions.append(action) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
162 | tbID = id(toolBar) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
163 | self.__defaultToolBars[tbID] = newActions |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
164 | self.__toolBars[tbID] = newActions |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
165 | self.__toolBarsWithSeparators[tbID] = newActionsWithSeparators |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
166 | self.__allToolBars[tbID] = toolBar |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
167 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
168 | def removeToolBar(self, toolBar): |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
169 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
170 | Public method to remove a toolbar added with addToolBar(). |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
171 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
172 | @param toolBar reference to the toolbar to be removed (QToolBar) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
173 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
174 | if toolBar is None: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
175 | return |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
176 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
177 | tbID = id(toolBar) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
178 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
179 | if tbID not in self.__defaultToolBars: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
180 | return |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
181 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
182 | defaultActions = self.__defaultToolBars[tbID][:] |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
183 | self.setToolBar(toolBar, []) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
184 | for action in defaultActions: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
185 | self.removeAction(action) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
186 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
187 | del self.__defaultToolBars[tbID] |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
188 | del self.__toolBars[tbID] |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
189 | del self.__toolBarsWithSeparators[tbID] |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
190 | del self.__allToolBars[tbID] |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
191 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
192 | for action in defaultActions: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
193 | if action is None: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
194 | toolBar.addSeparator() |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
195 | else: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
196 | toolBar.addAction(action) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
197 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
198 | def setToolBars(self, toolBars): |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
199 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
200 | Public method to set the actions of several toolbars. |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
201 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
202 | @param toolBars dictionary with toolbar id as key and |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
203 | a list of actions as value |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
204 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
205 | for key, actions in list(toolBars.items()): |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
206 | tb = self.__allToolBars[key] |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
207 | self.setToolBar(tb, actions) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
208 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
209 | def setToolBar(self, toolBar, actions): |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
210 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
211 | Public method to set the actions of a toolbar. |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
212 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
213 | @param toolBar reference to the toolbar to configure (QToolBar) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
214 | @param actions list of actions to be set (list of QAction) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
215 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
216 | if toolBar is None: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
217 | return |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
218 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
219 | tbID = id(toolBar) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
220 | if tbID not in self.__toolBars: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
221 | return |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
222 | if self.__toolBars[tbID] == actions: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
223 | return |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
224 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
225 | # step 1: check list of actions |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
226 | toRemove = {} |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
227 | newActions = [] |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
228 | for action in actions: |
7252
c5e3705073eb
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
229 | if ( |
c5e3705073eb
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
230 | action is None or |
c5e3705073eb
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
231 | (action not in newActions and |
c5e3705073eb
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
232 | id(action) in self.__allActions) |
c5e3705073eb
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
233 | ): |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
234 | newActions.append(action) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
235 | oldTB = self.toolBarWidgetAction(action) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
236 | if oldTB is not None and oldTB != toolBar: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
237 | if id(oldTB) not in toRemove: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
238 | toRemove[id(oldTB)] = [] |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
239 | toRemove[id(oldTB)].append(action) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
240 | self.removeWidgetActions(toRemove) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
241 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
242 | # step 2: remove all toolbar actions |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
243 | for action in self.__toolBarsWithSeparators[tbID]: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
244 | if self.toolBarWidgetAction(action) == tbID: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
245 | self.__widgetActions[id(action)] = None |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
246 | toolBar.removeAction(action) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
247 | if action.isSeparator(): |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
248 | del action |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
249 | else: |
5616
adcffadf4962
Reworked some __IGNORE_WARNING__ comments to be more specific.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
250 | self.__actionToToolBars[id(action)].remove(toolBar) |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
251 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
252 | # step 3: set the actions as requested |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
253 | newActionsWithSeparators = [] |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
254 | for action in newActions: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
255 | newAction = None |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
256 | if action is None: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
257 | newAction = toolBar.addSeparator() |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
258 | elif id(action) in self.__allActions: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
259 | toolBar.addAction(action) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
260 | newAction = action |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
261 | self.__actionToToolBars[id(action)].append(toolBar) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
262 | if id(action) in self.__widgetActions: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
263 | self.__widgetActions[id(action)] = toolBar |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
264 | else: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
265 | continue |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
266 | newActionsWithSeparators.append(newAction) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
267 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
268 | if toolBar.isVisible(): |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
269 | toolBar.hide() |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
270 | toolBar.show() |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
271 | self.__toolBars[tbID] = newActions |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
272 | self.__toolBarsWithSeparators[tbID] = newActionsWithSeparators |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
273 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
274 | def resetToolBar(self, toolBar): |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
275 | """ |
2763
e4794166ad70
Fixed a serious typo.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
276 | Public method to reset a toolbar to its default state. |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
277 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
278 | @param toolBar reference to the toolbar to configure (QToolBar) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
279 | """ |
1112
8a7d1b9d18db
Improved code quality by getting rid of star imports. That way pyflakes can do its job. A few bugs fixed found by flakes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
280 | if not self.isDefaultToolBar(): |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
281 | return |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
282 | self.setToolBar(toolBar, self.__defaultToolBars[id(toolBar)]) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
283 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
284 | def resetAllToolBars(self): |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
285 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
286 | Public method to reset all toolbars to their default state. |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
287 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
288 | self.setToolBars(self.__defaultToolBars) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
289 | for toolBar in self.__customToolBars[:]: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
290 | self.deleteToolBar(toolBar) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
291 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
292 | def defaultToolBars(self): |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
293 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
294 | Public method to get all toolbars added with addToolBar(). |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
295 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
296 | @return list of all default toolbars (list of QToolBar) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
297 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
298 | return list(self.__defaultToolBars.values()) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
299 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
300 | def isDefaultToolBar(self, toolBar): |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
301 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
302 | Public method to check, if a toolbar was added with addToolBar(). |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
303 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
304 | @param toolBar reference to the toolbar to be checked (QToolBar) |
2953
703452a2876f
Started correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2763
diff
changeset
|
305 | @return flag indicating an added toolbar (boolean) |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
306 | """ |
7252
c5e3705073eb
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
307 | return ( |
c5e3705073eb
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
308 | toolBar is not None and |
3035
36e9f388958b
Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2990
diff
changeset
|
309 | id(toolBar) in self.__defaultToolBars |
7252
c5e3705073eb
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
310 | ) |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
311 | |
930
95309225005e
Fixed an issue related to restore custom toolbars.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
824
diff
changeset
|
312 | def createToolBar(self, title, name=""): |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
313 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
314 | Public method to create a custom toolbar. |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
315 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
316 | @param title title to be used for the toolbar (string) |
930
95309225005e
Fixed an issue related to restore custom toolbars.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
824
diff
changeset
|
317 | @param name optional name for the new toolbar (string) |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
318 | @return reference to the created toolbar (QToolBar) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
319 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
320 | if self.__mainWindow is None: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
321 | return None |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
322 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
323 | toolBar = QToolBar(title, self.__mainWindow) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
324 | toolBar.setToolTip(title) |
930
95309225005e
Fixed an issue related to restore custom toolbars.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
824
diff
changeset
|
325 | if not name: |
95309225005e
Fixed an issue related to restore custom toolbars.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
824
diff
changeset
|
326 | index = 1 |
95309225005e
Fixed an issue related to restore custom toolbars.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
824
diff
changeset
|
327 | customPrefix = "__CustomPrefix__" |
410
e5d1addeb90c
Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
55
diff
changeset
|
328 | name = "{0}{1:d}".format(customPrefix, index) |
930
95309225005e
Fixed an issue related to restore custom toolbars.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
824
diff
changeset
|
329 | while self.__toolBarByName(name) is not None: |
95309225005e
Fixed an issue related to restore custom toolbars.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
824
diff
changeset
|
330 | index += 1 |
95309225005e
Fixed an issue related to restore custom toolbars.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
824
diff
changeset
|
331 | name = "{0}{1:d}".format(customPrefix, index) |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
332 | toolBar.setObjectName(name) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
333 | self.__mainWindow.addToolBar(toolBar) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
334 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
335 | tbID = id(toolBar) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
336 | self.__customToolBars.append(toolBar) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
337 | self.__allToolBars[tbID] = toolBar |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
338 | self.__toolBars[tbID] = [] |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
339 | self.__toolBarsWithSeparators[tbID] = [] |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
340 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
341 | if self.__ui is not None: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
342 | toolBar.setIconSize(self.__ui.getToolBarIconSize()) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
343 | self.__ui.registerToolbar(name, title, toolBar) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
344 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
345 | return toolBar |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
346 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
347 | def deleteToolBar(self, toolBar): |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
348 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
349 | Public method to remove a custom toolbar created with createToolBar(). |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
350 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
351 | @param toolBar reference to the toolbar to be managed (QToolBar) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
352 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
353 | if toolBar is None: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
354 | return |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
355 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
356 | tbID = id(toolBar) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
357 | if tbID not in self.__toolBars: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
358 | return |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
359 | if tbID in self.__defaultToolBars: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
360 | return |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
361 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
362 | if self.__ui is not None: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
363 | self.__ui.unregisterToolbar(toolBar.objectName()) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
364 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
365 | self.setToolBar(toolBar, []) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
366 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
367 | del self.__allToolBars[tbID] |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
368 | del self.__toolBars[tbID] |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
369 | del self.__toolBarsWithSeparators[tbID] |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
370 | self.__customToolBars.remove(toolBar) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
371 | self.__mainWindow.removeToolBar(toolBar) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
372 | del toolBar |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
373 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
374 | def renameToolBar(self, toolBar, title): |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
375 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
376 | Public method to give a toolbar a new title. |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
377 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
378 | @param toolBar reference to the toolbar to be managed (QToolBar) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
379 | @param title title to be used for the toolbar (string) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
380 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
381 | if toolBar is None: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
382 | return |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
383 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
384 | toolBar.setWindowTitle(title) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
385 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
386 | if self.__ui is not None: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
387 | self.__ui.reregisterToolbar(toolBar.objectName(), title) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
388 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
389 | def toolBars(self): |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
390 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
391 | Public method to get all toolbars. |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
392 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
393 | @return list of all toolbars (list of QToolBar) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
394 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
395 | return list(self.__allToolBars.values()) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
396 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
397 | def addAction(self, action, category): |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
398 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
399 | Public method to add an action to be managed. |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
400 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
401 | @param action reference to the action to be managed (QAction) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
402 | @param category category for the toolbar (string) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
403 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
404 | if action is None: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
405 | return |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
406 | if action.isSeparator(): |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
407 | return |
824
360e007523bd
Fixed an issue in the toolbar manager where adding a toolbar a second time caused actions to be listed multiple times.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
408 | if id(action) in self.__allActions: |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
409 | return |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
410 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
411 | if action.metaObject().className() == "QWidgetAction": |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
412 | self.__widgetActions[id(action)] = None |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
413 | self.__allWidgetActions[id(action)] = action |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
414 | self.__allActions[id(action)] = action |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
415 | if category not in self.__categoryToActions: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
416 | self.__categoryToActions[category] = [] |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
417 | self.__categoryToActions[category].append(action) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
418 | self.__actionToCategory[id(action)] = category |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
419 | self.__actionToToolBars[id(action)] = [] |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
420 | |
5108
f5cb9cb98e6a
Added an action to clear the private data of the IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
421 | def addActions(self, actions, category): |
f5cb9cb98e6a
Added an action to clear the private data of the IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
422 | """ |
f5cb9cb98e6a
Added an action to clear the private data of the IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
423 | Public method to add actions to be managed. |
f5cb9cb98e6a
Added an action to clear the private data of the IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
424 | |
f5cb9cb98e6a
Added an action to clear the private data of the IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
425 | @param actions list of actions to be managed |
f5cb9cb98e6a
Added an action to clear the private data of the IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
426 | @type list of QAction |
f5cb9cb98e6a
Added an action to clear the private data of the IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
427 | @param category category for the toolbar |
f5cb9cb98e6a
Added an action to clear the private data of the IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
428 | @type str |
f5cb9cb98e6a
Added an action to clear the private data of the IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
429 | """ |
f5cb9cb98e6a
Added an action to clear the private data of the IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
430 | for action in actions: |
f5cb9cb98e6a
Added an action to clear the private data of the IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
431 | self.addAction(action, category) |
f5cb9cb98e6a
Added an action to clear the private data of the IDE.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
432 | |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
433 | def removeAction(self, action): |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
434 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
435 | Public method to remove an action from the manager. |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
436 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
437 | @param action reference to the action to be removed (QAction) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
438 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
439 | aID = id(action) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
440 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
441 | if aID not in self.__allActions: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
442 | return |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
443 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
444 | toolBars = self.__actionToToolBars[aID] |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
445 | for toolBar in toolBars: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
446 | tbID = id(toolBar) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
447 | self.__toolBars[tbID].remove(action) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
448 | self.__toolBarsWithSeparators[tbID].remove(action) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
449 | toolBar.removeAction(action) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
450 | if toolBar.isVisible(): |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
451 | toolBar.hide() |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
452 | toolBar.show() |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
453 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
454 | for tbID in self.__defaultToolBars: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
455 | if action in self.__defaultToolBars[tbID]: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
456 | self.__defaultToolBars[tbID].remove(action) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
457 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
458 | del self.__allActions[aID] |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
459 | if aID in self.__widgetActions: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
460 | del self.__widgetActions[aID] |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
461 | del self.__allWidgetActions[aID] |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
462 | del self.__actionToCategory[aID] |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
463 | del self.__actionToToolBars[aID] |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
464 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
465 | for category in self.__categoryToActions: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
466 | if action in self.__categoryToActions[category]: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
467 | self.__categoryToActions[category].remove(action) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
468 | |
4113
feac3108a780
Some small modifications to the plug-in manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4021
diff
changeset
|
469 | def removeCategoryActions(self, category): |
feac3108a780
Some small modifications to the plug-in manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4021
diff
changeset
|
470 | """ |
feac3108a780
Some small modifications to the plug-in manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4021
diff
changeset
|
471 | Public method to remove the actions belonging to a category. |
feac3108a780
Some small modifications to the plug-in manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4021
diff
changeset
|
472 | |
feac3108a780
Some small modifications to the plug-in manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4021
diff
changeset
|
473 | @param category category for the actions (string) |
feac3108a780
Some small modifications to the plug-in manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4021
diff
changeset
|
474 | """ |
feac3108a780
Some small modifications to the plug-in manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4021
diff
changeset
|
475 | for action in self.categoryActions(category): |
feac3108a780
Some small modifications to the plug-in manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4021
diff
changeset
|
476 | self.removeAction(action) |
feac3108a780
Some small modifications to the plug-in manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4021
diff
changeset
|
477 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
930
diff
changeset
|
478 | def saveState(self, version=0): |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
479 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
480 | Public method to save the state of the toolbar manager. |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
481 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
482 | @param version version number stored with the data (integer) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
483 | @return saved state as a byte array (QByteArray) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
484 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
485 | data = QByteArray() |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
486 | stream = QDataStream(data, QIODevice.OpenModeFlag.WriteOnly) |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
487 | stream.setVersion(QDataStream.Version.Qt_4_6) |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8341
diff
changeset
|
488 | stream.writeUInt16(EricToolBarManager.VersionMarker) |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
489 | stream.writeUInt16(version) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
490 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
491 | # save default toolbars |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8341
diff
changeset
|
492 | stream.writeUInt16(EricToolBarManager.ToolBarMarker) |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
493 | stream.writeUInt16(len(self.__defaultToolBars)) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
494 | for tbID in self.__defaultToolBars: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
495 | tb = self.__allToolBars[tbID] |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
496 | if tb.objectName(): |
4331
711e7c35a49b
Changed code to make eric compatible to PyQt 5.5 (QByteArry issue).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4113
diff
changeset
|
497 | stream.writeString(tb.objectName().encode("utf-8")) |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
498 | else: |
4331
711e7c35a49b
Changed code to make eric compatible to PyQt 5.5 (QByteArry issue).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4113
diff
changeset
|
499 | stream.writeString(tb.windowTitle().encode("utf-8")) |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
500 | stream.writeUInt16(len(self.__toolBars[tbID])) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
501 | for action in self.__toolBars[tbID]: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
502 | if action is not None: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
503 | if action.objectName(): |
4331
711e7c35a49b
Changed code to make eric compatible to PyQt 5.5 (QByteArry issue).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4113
diff
changeset
|
504 | stream.writeString(action.objectName().encode("utf-8")) |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
505 | else: |
4331
711e7c35a49b
Changed code to make eric compatible to PyQt 5.5 (QByteArry issue).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4113
diff
changeset
|
506 | stream.writeString(action.text().encode("utf-8")) |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
507 | else: |
4331
711e7c35a49b
Changed code to make eric compatible to PyQt 5.5 (QByteArry issue).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4113
diff
changeset
|
508 | stream.writeString("".encode("utf-8")) |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
509 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
510 | # save the custom toolbars |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8341
diff
changeset
|
511 | stream.writeUInt16(EricToolBarManager.CustomToolBarMarker) |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
512 | stream.writeUInt16(len(self.__toolBars) - len(self.__defaultToolBars)) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
513 | for tbID in self.__toolBars: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
514 | if tbID not in self.__defaultToolBars: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
515 | tb = self.__allToolBars[tbID] |
4331
711e7c35a49b
Changed code to make eric compatible to PyQt 5.5 (QByteArry issue).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4113
diff
changeset
|
516 | stream.writeString(tb.objectName().encode("utf-8")) |
711e7c35a49b
Changed code to make eric compatible to PyQt 5.5 (QByteArry issue).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4113
diff
changeset
|
517 | stream.writeString(tb.windowTitle().encode("utf-8")) |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
518 | stream.writeUInt16(len(self.__toolBars[tbID])) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
519 | for action in self.__toolBars[tbID]: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
520 | if action is not None: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
521 | if action.objectName(): |
4332
64034d85c709
Corrected some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4331
diff
changeset
|
522 | stream.writeString(action.objectName() |
64034d85c709
Corrected some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4331
diff
changeset
|
523 | .encode("utf-8")) |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
524 | else: |
4331
711e7c35a49b
Changed code to make eric compatible to PyQt 5.5 (QByteArry issue).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4113
diff
changeset
|
525 | stream.writeString(action.text().encode("utf-8")) |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
526 | else: |
4331
711e7c35a49b
Changed code to make eric compatible to PyQt 5.5 (QByteArry issue).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4113
diff
changeset
|
527 | stream.writeString("".encode("utf-8")) |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
528 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
529 | return data |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
530 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
930
diff
changeset
|
531 | def restoreState(self, state, version=0): |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
532 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
533 | Public method to restore the state of the toolbar manager. |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
534 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
535 | @param state byte array containing the saved state (QByteArray) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
536 | @param version version number stored with the data (integer) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
537 | @return flag indicating success (boolean) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
538 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
539 | if state.isEmpty(): |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
540 | return False |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
541 | |
8341
e470de1e6628
Reinstantiated code after QByteArray was fixed in PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8322
diff
changeset
|
542 | data = QByteArray(state) |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
543 | stream = QDataStream(data, QIODevice.OpenModeFlag.ReadOnly) |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
544 | stream.setVersion(QDataStream.Version.Qt_4_6) |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
545 | marker = stream.readUInt16() |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
546 | vers = stream.readUInt16() |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8341
diff
changeset
|
547 | if marker != EricToolBarManager.VersionMarker or vers != version: |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
548 | return False |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
549 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
550 | tmarker = stream.readUInt16() |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8341
diff
changeset
|
551 | if tmarker != EricToolBarManager.ToolBarMarker: |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
552 | return False |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
553 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
554 | toolBarCount = stream.readUInt16() |
6187
2cc7e3629784
Started to fix some unused loop variable warnings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
555 | for _i in range(toolBarCount): |
2084
d3f083dd0222
Made the fiveth set of Qt5 compatibility changes (some of the previous changes are backed out due to changes in PyQt4).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
556 | objectName = Utilities.readStringFromStream(stream) |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
557 | actionCount = stream.readUInt16() |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
558 | actions = [] |
6187
2cc7e3629784
Started to fix some unused loop variable warnings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
559 | for _j in range(actionCount): |
2084
d3f083dd0222
Made the fiveth set of Qt5 compatibility changes (some of the previous changes are backed out due to changes in PyQt4).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
560 | actionName = Utilities.readStringFromStream(stream) |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
561 | if actionName: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
562 | action = self.__findAction(actionName) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
563 | if action is not None: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
564 | actions.append(action) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
565 | else: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
566 | actions.append(None) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
567 | toolBar = self.__findDefaultToolBar(objectName) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
568 | if toolBar is not None: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
569 | self.setToolBar(toolBar, actions) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
570 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
571 | cmarker = stream.readUInt16() |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8341
diff
changeset
|
572 | if cmarker != EricToolBarManager.CustomToolBarMarker: |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
573 | return False |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
574 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
575 | oldCustomToolBars = self.__customToolBars[:] |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
576 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
577 | toolBarCount = stream.readUInt16() |
6187
2cc7e3629784
Started to fix some unused loop variable warnings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
578 | for _i in range(toolBarCount): |
2084
d3f083dd0222
Made the fiveth set of Qt5 compatibility changes (some of the previous changes are backed out due to changes in PyQt4).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
579 | objectName = Utilities.readStringFromStream(stream) |
d3f083dd0222
Made the fiveth set of Qt5 compatibility changes (some of the previous changes are backed out due to changes in PyQt4).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
580 | toolBarTitle = Utilities.readStringFromStream(stream) |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
581 | actionCount = stream.readUInt16() |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
582 | actions = [] |
6187
2cc7e3629784
Started to fix some unused loop variable warnings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
583 | for _j in range(actionCount): |
2084
d3f083dd0222
Made the fiveth set of Qt5 compatibility changes (some of the previous changes are backed out due to changes in PyQt4).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
584 | actionName = Utilities.readStringFromStream(stream) |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
585 | if actionName: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
586 | action = self.__findAction(actionName) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
587 | if action is not None: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
588 | actions.append(action) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
589 | else: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
590 | actions.append(None) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
591 | toolBar = self.__toolBarByName(objectName) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
592 | if toolBar is not None: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
593 | toolBar.setWindowTitle(toolBarTitle) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
594 | oldCustomToolBars.remove(toolBar) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
595 | else: |
930
95309225005e
Fixed an issue related to restore custom toolbars.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
824
diff
changeset
|
596 | toolBar = self.createToolBar(toolBarTitle, objectName) |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
597 | if toolBar is not None: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
598 | toolBar.setObjectName(objectName) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
599 | self.setToolBar(toolBar, actions) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
600 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
601 | for tb in oldCustomToolBars: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
602 | self.deleteToolBar(tb) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
603 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
604 | return True |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
605 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
606 | def toolBarWidgetAction(self, action): |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
607 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
608 | Public method to get the toolbar for a widget action. |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
609 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
610 | @param action widget action to check for (QAction) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
611 | @return reference to the toolbar containing action (QToolBar) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
612 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
613 | aID = id(action) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
614 | if aID in self.__widgetActions: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
615 | return self.__widgetActions[aID] |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
616 | return None |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
617 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
618 | def removeWidgetActions(self, actions): |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
619 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
620 | Public method to remove widget actions. |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
621 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
622 | @param actions dictionary with toolbar id as key and |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
623 | a list of widget actions as value |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
624 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
625 | for tbID in list(actions.keys())[:]: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
626 | toolBar = self.__allToolBars[tbID] |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
627 | newActions = self.__toolBars[tbID][:] |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
628 | newActionsWithSeparators = self.__toolBarsWithSeparators[tbID][:] |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
629 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
630 | removedActions = [] |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
631 | for action in actions[tbID]: |
7252
c5e3705073eb
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
632 | if ( |
c5e3705073eb
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
633 | action in newActions and |
c5e3705073eb
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
634 | self.toolBarWidgetAction(action) == toolBar |
c5e3705073eb
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
635 | ): |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
636 | newActions.remove(action) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
637 | newActionsWithSeparators.remove(action) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
638 | removedActions.append(action) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
639 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
640 | self.__toolBars[tbID] = newActions |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
641 | self.__toolBarsWithSeparators[tbID] = newActionsWithSeparators |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
642 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
643 | for action in removedActions: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
644 | self.__widgetActions[id(action)] = None |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
645 | self.__actionToToolBars[id(action)].remove(toolBar) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
646 | toolBar.removeAction(action) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
647 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
648 | def isWidgetAction(self, action): |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
649 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
650 | Public method to check, if action is a widget action. |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
651 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
652 | @param action reference to the action to be checked (QAction) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
653 | @return flag indicating a widget action (boolean) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
654 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
655 | return id(action) in self.__allWidgetActions |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
656 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
657 | def categories(self): |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
658 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
659 | Public method to get the list of categories. |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
660 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
661 | @return list of categories (list of string) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
662 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
663 | return list(self.__categoryToActions.keys()) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
664 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
665 | def categoryActions(self, category): |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
666 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
667 | Public method to get the actions belonging to a category. |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
668 | |
4113
feac3108a780
Some small modifications to the plug-in manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4021
diff
changeset
|
669 | @param category category for the actions (string) |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
670 | @return list of actions (list of QAction) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
671 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
672 | if category not in self.__categoryToActions: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
673 | return [] |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
674 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
675 | return self.__categoryToActions[category][:] |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
676 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
677 | def actionById(self, aID): |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
678 | """ |
2763
e4794166ad70
Fixed a serious typo.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
679 | Public method to get an action given its id. |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
680 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
681 | @param aID id of the action object (integer) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
682 | @return reference to the action (QAction) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
683 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
684 | if aID not in self.__allActions: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
685 | return None |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
686 | return self.__allActions[aID] |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
687 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
688 | def toolBarById(self, tbID): |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
689 | """ |
2763
e4794166ad70
Fixed a serious typo.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
690 | Public method to get a toolbar given its id. |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
691 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
692 | @param tbID id of the toolbar object (integer) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
693 | @return reference to the toolbar (QToolBar) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
694 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
695 | if tbID not in self.__allToolBars: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
696 | return None |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
697 | return self.__allToolBars[tbID] |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
698 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
699 | def toolBarActions(self, tbID): |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
700 | """ |
2763
e4794166ad70
Fixed a serious typo.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
701 | Public method to get a toolbar's actions given its id. |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
702 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
703 | @param tbID id of the toolbar object (integer) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
704 | @return list of actions (list of QAction) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
705 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
706 | if tbID not in self.__toolBars: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
707 | return [] |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
708 | return self.__toolBars[tbID][:] |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
709 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
710 | def toolBarsActions(self): |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
711 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
712 | Public method to get all toolbars and their actions. |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
713 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
714 | @return reference to dictionary of toolbar IDs as key and list |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
715 | of actions as values |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
716 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
717 | return self.__toolBars |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
718 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
719 | def defaultToolBarActions(self, tbID): |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
720 | """ |
2763
e4794166ad70
Fixed a serious typo.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
721 | Public method to get a default toolbar's actions given its id. |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
722 | |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
723 | @param tbID id of the default toolbar object (integer) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
724 | @return list of actions (list of QAction) |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
725 | """ |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
726 | if tbID not in self.__defaultToolBars: |
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
727 | return [] |
410
e5d1addeb90c
Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
55
diff
changeset
|
728 | return self.__defaultToolBars[tbID][:] |