--- a/PluginPySide2PyQt.py Thu Jan 01 13:29:02 2015 +0100 +++ b/PluginPySide2PyQt.py Mon Jan 05 19:32:53 2015 +0100 @@ -21,7 +21,7 @@ author = "Detlev Offenbach <detlev@die-offenbachs.de>" autoactivate = True deactivateable = True -version = "2.0.0" +version = "2.0.1" className = "PySide2PyQtPlugin" packageName = "PySide2PyQt" shortDescription = "Convert PySide file to PyQt and vice versa" @@ -90,6 +90,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: @@ -164,6 +165,7 @@ act = menu.addMenu(self.__menu) self.__editors[editor].append(act) self.__menu.setEnabled(True) + editor.showMenu.connect(self.__editorShowMenu) def __editorClosed(self, editor): """ @@ -178,6 +180,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 __pyside2Pyqt(self): """ Private slot to convert the code of the current editor from PySide