--- a/PluginPrintRemover.py Thu Jan 01 13:28:48 2015 +0100 +++ b/PluginPrintRemover.py Mon Jan 05 19:26:52 2015 +0100 @@ -23,7 +23,7 @@ author = "Detlev Offenbach <detlev@die-offenbachs.de>" autoactivate = True deactivateable = True -version = "2.0.0" +version = "2.0.1" className = "PrintRemoverPlugin" packageName = "PrintRemover" shortDescription = "Remove print() like debug statements." @@ -145,6 +145,7 @@ self.__editorClosed) for editor, acts in self.__editors.items(): + editor.showMenu.disconnect(self.__editorShowMenu) menu = editor.getMenu("Tools") if menu is not None: for act in acts: @@ -237,6 +238,7 @@ act = menu.addMenu(self.__menu) self.__menu.setEnabled(True) self.__editors[editor].append(act) + editor.showMenu.connect(self.__editorShowMenu) def __editorClosed(self, editor): """ @@ -251,6 +253,25 @@ except KeyError: pass + def __editorShowMenu(self, menuName, menu, editor): + """ + Private slot called, when the the editor context menu or a submenu is + about to be shown. + + @param menuName name of the menu to be shown (string) + @param menu reference to the menu (QMenu) + @param editor reference to the editor + """ + if menuName == "Tools": + if self.__menu.menuAction() not in menu.actions(): + # Re-add our menu + self.__editors[editor] = [] + if not menu.isEmpty(): + act = menu.addSeparator() + self.__editors[editor].append(act) + act = menu.addMenu(self.__menu) + self.__editors[editor].append(act) + def __showMenu(self): """ Private slot to build the menu hierarchy.