21 # Start-Of-Header |
21 # Start-Of-Header |
22 name = "Color String Plug-in" |
22 name = "Color String Plug-in" |
23 author = "Detlev Offenbach <detlev@die-offenbachs.de>" |
23 author = "Detlev Offenbach <detlev@die-offenbachs.de>" |
24 autoactivate = True |
24 autoactivate = True |
25 deactivateable = True |
25 deactivateable = True |
26 version = "2.1.1" |
26 version = "2.2.0" |
27 className = "ColorStringPlugin" |
27 className = "ColorStringPlugin" |
28 packageName = "ColorString" |
28 packageName = "ColorString" |
29 shortDescription = "Insert color as string" |
29 shortDescription = "Insert color as string" |
30 longDescription = \ |
30 longDescription = \ |
31 """This plug-in implements a tool to select a color via a""" \ |
31 """This plug-in implements a tool to select a color via a""" \ |
68 """ |
69 """ |
69 global error |
70 global error |
70 error = "" # clear previous error |
71 error = "" # clear previous error |
71 |
72 |
72 self.__ui.showMenu.connect(self.__populateMenu) |
73 self.__ui.showMenu.connect(self.__populateMenu) |
|
74 |
|
75 menu = self.__ui.getMenu("plugin_tools") |
|
76 if menu is not None: |
|
77 if not menu.isEmpty(): |
|
78 act = menu.addSeparator() |
|
79 self.__mainActions.append(act) |
|
80 act = menu.addMenu(self.__menu) |
|
81 self.__mainActions.append(act) |
73 |
82 |
74 e5App().getObject("ViewManager").editorOpenedEd.connect( |
83 e5App().getObject("ViewManager").editorOpenedEd.connect( |
75 self.__editorOpened) |
84 self.__editorOpened) |
76 e5App().getObject("ViewManager").editorClosedEd.connect( |
85 e5App().getObject("ViewManager").editorClosedEd.connect( |
77 self.__editorClosed) |
86 self.__editorClosed) |
85 """ |
94 """ |
86 Public method to deactivate this plugin. |
95 Public method to deactivate this plugin. |
87 """ |
96 """ |
88 self.__ui.showMenu.disconnect(self.__populateMenu) |
97 self.__ui.showMenu.disconnect(self.__populateMenu) |
89 |
98 |
|
99 menu = self.__ui.getMenu("plugin_tools") |
|
100 if menu is not None: |
|
101 for act in self.__mainActions: |
|
102 menu.removeAction(act) |
|
103 self.__mainActions = [] |
|
104 |
90 e5App().getObject("ViewManager").editorOpenedEd.disconnect( |
105 e5App().getObject("ViewManager").editorOpenedEd.disconnect( |
91 self.__editorOpened) |
106 self.__editorOpened) |
92 e5App().getObject("ViewManager").editorClosedEd.disconnect( |
107 e5App().getObject("ViewManager").editorClosedEd.disconnect( |
93 self.__editorClosed) |
108 self.__editorClosed) |
94 |
109 |
135 Private slot to populate the tools menu with our entry. |
150 Private slot to populate the tools menu with our entry. |
136 |
151 |
137 @param name name of the menu (string) |
152 @param name name of the menu (string) |
138 @param menu reference to the menu to be populated (QMenu) |
153 @param menu reference to the menu to be populated (QMenu) |
139 """ |
154 """ |
140 if name != "Tools": |
155 if name not in ["Tools", "PluginTools"]: |
141 return |
156 return |
142 |
157 |
143 if not menu.isEmpty(): |
158 editor = e5App().getObject("ViewManager").activeWindow() |
144 menu.addSeparator() |
159 |
145 menu.addMenu(self.__menu) |
160 if name == "Tools": |
|
161 if not menu.isEmpty(): |
|
162 menu.addSeparator() |
|
163 act = menu.addMenu(self.__menu) |
|
164 act.setEnabled(editor is not None) |
|
165 elif name == "PluginTools" and self.__mainActions: |
|
166 self.__mainActions[-1].setEnabled(editor is not None) |
146 |
167 |
147 def __editorOpened(self, editor): |
168 def __editorOpened(self, editor): |
148 """ |
169 """ |
149 Private slot called, when a new editor was opened. |
170 Private slot called, when a new editor was opened. |
150 |
171 |