21 # Start-Of-Header |
21 # Start-Of-Header |
22 name = "Print Remover Plug-in" |
22 name = "Print Remover 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.0.0" |
26 version = "2.0.1" |
27 className = "PrintRemoverPlugin" |
27 className = "PrintRemoverPlugin" |
28 packageName = "PrintRemover" |
28 packageName = "PrintRemover" |
29 shortDescription = "Remove print() like debug statements." |
29 shortDescription = "Remove print() like debug statements." |
30 longDescription = \ |
30 longDescription = \ |
31 """This plug-in implements a tool to remove lines starting with""" \ |
31 """This plug-in implements a tool to remove lines starting with""" \ |
143 self.__editorOpened) |
143 self.__editorOpened) |
144 e5App().getObject("ViewManager").editorClosedEd.disconnect( |
144 e5App().getObject("ViewManager").editorClosedEd.disconnect( |
145 self.__editorClosed) |
145 self.__editorClosed) |
146 |
146 |
147 for editor, acts in self.__editors.items(): |
147 for editor, acts in self.__editors.items(): |
|
148 editor.showMenu.disconnect(self.__editorShowMenu) |
148 menu = editor.getMenu("Tools") |
149 menu = editor.getMenu("Tools") |
149 if menu is not None: |
150 if menu is not None: |
150 for act in acts: |
151 for act in acts: |
151 menu.removeAction(act) |
152 menu.removeAction(act) |
152 self.__editors = {} |
153 self.__editors = {} |
235 act = menu.addSeparator() |
236 act = menu.addSeparator() |
236 self.__editors[editor].append(act) |
237 self.__editors[editor].append(act) |
237 act = menu.addMenu(self.__menu) |
238 act = menu.addMenu(self.__menu) |
238 self.__menu.setEnabled(True) |
239 self.__menu.setEnabled(True) |
239 self.__editors[editor].append(act) |
240 self.__editors[editor].append(act) |
|
241 editor.showMenu.connect(self.__editorShowMenu) |
240 |
242 |
241 def __editorClosed(self, editor): |
243 def __editorClosed(self, editor): |
242 """ |
244 """ |
243 Private slot called, when an editor was closed. |
245 Private slot called, when an editor was closed. |
244 |
246 |
248 del self.__editors[editor] |
250 del self.__editors[editor] |
249 if not self.__editors: |
251 if not self.__editors: |
250 self.__menu.setEnabled(False) |
252 self.__menu.setEnabled(False) |
251 except KeyError: |
253 except KeyError: |
252 pass |
254 pass |
|
255 |
|
256 def __editorShowMenu(self, menuName, menu, editor): |
|
257 """ |
|
258 Private slot called, when the the editor context menu or a submenu is |
|
259 about to be shown. |
|
260 |
|
261 @param menuName name of the menu to be shown (string) |
|
262 @param menu reference to the menu (QMenu) |
|
263 @param editor reference to the editor |
|
264 """ |
|
265 if menuName == "Tools": |
|
266 if self.__menu.menuAction() not in menu.actions(): |
|
267 # Re-add our menu |
|
268 self.__editors[editor] = [] |
|
269 if not menu.isEmpty(): |
|
270 act = menu.addSeparator() |
|
271 self.__editors[editor].append(act) |
|
272 act = menu.addMenu(self.__menu) |
|
273 self.__editors[editor].append(act) |
253 |
274 |
254 def __showMenu(self): |
275 def __showMenu(self): |
255 """ |
276 """ |
256 Private slot to build the menu hierarchy. |
277 Private slot to build the menu hierarchy. |
257 """ |
278 """ |