Added code to repopulate the Tools menu. release-2.0.1

Mon, 05 Jan 2015 19:26:52 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 05 Jan 2015 19:26:52 +0100
changeset 32
429a8bee8f1f
parent 31
ca51aba3b8c3
child 33
bc127c597643

Added code to repopulate the Tools menu.

ChangeLog file | annotate | diff | comparison | revisions
PluginPrintRemover.py file | annotate | diff | comparison | revisions
PluginPrintRemover.zip file | annotate | diff | comparison | revisions
PrintRemover/Documentation/source/Plugin_Tools_Print_Remover.PluginPrintRemover.html file | annotate | diff | comparison | revisions
--- a/ChangeLog	Thu Jan 01 13:28:48 2015 +0100
+++ b/ChangeLog	Mon Jan 05 19:26:52 2015 +0100
@@ -1,5 +1,8 @@
 ChangeLog
 ---------
+Version 2.0.1:
+- bug fixes
+
 Version 2.0.0:
 - ported for eric6 using PyQt5
 
--- 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.
Binary file PluginPrintRemover.zip has changed
--- a/PrintRemover/Documentation/source/Plugin_Tools_Print_Remover.PluginPrintRemover.html	Thu Jan 01 13:28:48 2015 +0100
+++ b/PrintRemover/Documentation/source/Plugin_Tools_Print_Remover.PluginPrintRemover.html	Mon Jan 05 19:26:52 2015 +0100
@@ -75,6 +75,9 @@
 <td><a href="#PrintRemoverPlugin.__editorOpened">__editorOpened</a></td>
 <td>Private slot called, when a new editor was opened.</td>
 </tr><tr>
+<td><a href="#PrintRemoverPlugin.__editorShowMenu">__editorShowMenu</a></td>
+<td>Private slot called, when the the editor context menu or a submenu is about to be shown.</td>
+</tr><tr>
 <td><a href="#PrintRemoverPlugin.__initMenu">__initMenu</a></td>
 <td>Private method to initialize the menu.</td>
 </tr><tr>
@@ -137,6 +140,23 @@
 <dd>
 reference to the new editor (QScintilla.Editor)
 </dd>
+</dl><a NAME="PrintRemoverPlugin.__editorShowMenu" ID="PrintRemoverPlugin.__editorShowMenu"></a>
+<h4>PrintRemoverPlugin.__editorShowMenu</h4>
+<b>__editorShowMenu</b>(<i>menuName, menu, editor</i>)
+<p>
+        Private slot called, when the the editor context menu or a submenu is
+        about to be shown.
+</p><dl>
+<dt><i>menuName</i></dt>
+<dd>
+name of the menu to be shown (string)
+</dd><dt><i>menu</i></dt>
+<dd>
+reference to the menu (QMenu)
+</dd><dt><i>editor</i></dt>
+<dd>
+reference to the editor
+</dd>
 </dl><a NAME="PrintRemoverPlugin.__initMenu" ID="PrintRemoverPlugin.__initMenu"></a>
 <h4>PrintRemoverPlugin.__initMenu</h4>
 <b>__initMenu</b>(<i></i>)

eric ide

mercurial