Added code to repopulate the Tools menu.

Fri, 02 Jan 2015 17:12:30 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 02 Jan 2015 17:12:30 +0100
changeset 24
31a6f2b29967
parent 23
014dd5f63240
child 25
681c98f73cbc

Added code to repopulate the Tools menu.

ChangeLog file | annotate | diff | comparison | revisions
PluginToolGenerateHash.py file | annotate | diff | comparison | revisions
PluginToolGenerateHash.zip file | annotate | diff | comparison | revisions
ToolGenerateHash/Documentation/source/Plugin_Tools_GenerateHash.PluginToolGenerateHash.html file | annotate | diff | comparison | revisions
--- a/ChangeLog	Thu Jan 01 13:28:09 2015 +0100
+++ b/ChangeLog	Fri Jan 02 17:12:30 2015 +0100
@@ -1,5 +1,8 @@
 ChangeLog
 ---------
+Version 2.0.1:
+- bug fixes
+
 Version 2.0.0:
 - ported for eric6 using PyQt5
 
--- a/PluginToolGenerateHash.py	Thu Jan 01 13:28:09 2015 +0100
+++ b/PluginToolGenerateHash.py	Fri Jan 02 17:12:30 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 = "ToolGenerateHashPlugin"
 packageName = "ToolGenerateHash"
 shortDescription = "Generate a hash for a selectable file or directory"
@@ -191,6 +191,7 @@
             self.__editors[editor].append(act)
             act = menu.addMenu(self.__dirMenu)
             self.__editors[editor].append(act)
+            editor.showMenu.connect(self.__editorShowMenu)
             
             self.__fileMenu.setEnabled(True)
             self.__dirMenu.setEnabled(True)
@@ -209,6 +210,30 @@
         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.__fileMenu.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.__fileMenu)
+                self.__editors[editor].append(act)
+                act = menu.addMenu(self.__dirMenu)
+                self.__editors[editor].append(act)
+                
+                self.__fileMenu.setEnabled(True)
+                self.__dirMenu.setEnabled(True)
+    
     def __insertHash(self, hashStr):
         """
         Private method to insert the generated hash string.
Binary file PluginToolGenerateHash.zip has changed
--- a/ToolGenerateHash/Documentation/source/Plugin_Tools_GenerateHash.PluginToolGenerateHash.html	Thu Jan 01 13:28:09 2015 +0100
+++ b/ToolGenerateHash/Documentation/source/Plugin_Tools_GenerateHash.PluginToolGenerateHash.html	Fri Jan 02 17:12:30 2015 +0100
@@ -66,6 +66,9 @@
 <td><a href="#ToolGenerateHashPlugin.__editorOpened">__editorOpened</a></td>
 <td>Private slot called, when a new editor was opened.</td>
 </tr><tr>
+<td><a href="#ToolGenerateHashPlugin.__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="#ToolGenerateHashPlugin.__hashDirectory">__hashDirectory</a></td>
 <td>Private slot to generate the hash for a directory.</td>
 </tr><tr>
@@ -125,6 +128,23 @@
 <dd>
 reference to the new editor (QScintilla.Editor)
 </dd>
+</dl><a NAME="ToolGenerateHashPlugin.__editorShowMenu" ID="ToolGenerateHashPlugin.__editorShowMenu"></a>
+<h4>ToolGenerateHashPlugin.__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="ToolGenerateHashPlugin.__hashDirectory" ID="ToolGenerateHashPlugin.__hashDirectory"></a>
 <h4>ToolGenerateHashPlugin.__hashDirectory</h4>
 <b>__hashDirectory</b>(<i></i>)

eric ide

mercurial