Adaptation for the new plug-in tools menu handling. release-2.1.0

Fri, 28 Aug 2015 10:47:02 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 28 Aug 2015 10:47:02 +0200
changeset 38
7641127c1421
parent 37
0c6357a73f49
child 39
2deba55d4322

Adaptation for the new plug-in tools menu handling.

ChangeLog file | annotate | diff | comparison | revisions
PluginPrintRemover.py file | annotate | diff | comparison | revisions
PluginPrintRemover.zip file | annotate | diff | comparison | revisions
--- a/ChangeLog	Fri Feb 27 18:34:24 2015 +0100
+++ b/ChangeLog	Fri Aug 28 10:47:02 2015 +0200
@@ -1,5 +1,8 @@
 ChangeLog
 ---------
+Version 2.1.0:
+- adaptation for the new plug-in tools menu handling
+
 Version 2.0.3:
 - added Russian translations provided by Alexander Barkoff
 
--- a/PluginPrintRemover.py	Fri Feb 27 18:34:24 2015 +0100
+++ b/PluginPrintRemover.py	Fri Aug 28 10:47:02 2015 +0200
@@ -23,7 +23,7 @@
 author = "Detlev Offenbach <detlev@die-offenbachs.de>"
 autoactivate = True
 deactivateable = True
-version = "2.0.3"
+version = "2.1.0"
 className = "PrintRemoverPlugin"
 packageName = "PrintRemover"
 shortDescription = "Remove print() like debug statements."
@@ -108,6 +108,7 @@
         self.__initMenu()
         
         self.__editors = {}
+        self.__mainActions = []
     
     def activate(self):
         """
@@ -123,6 +124,14 @@
         
         self.__ui.showMenu.connect(self.__populateMenu)
         
+        menu = self.__ui.getMenu("plugin_tools")
+        if menu is not None:
+            if not menu.isEmpty():
+                act = menu.addSeparator()
+                self.__mainActions.append(act)
+            act = menu.addMenu(self.__menu)
+            self.__mainActions.append(act)
+        
         e5App().getObject("ViewManager").editorOpenedEd.connect(
             self.__editorOpened)
         e5App().getObject("ViewManager").editorClosedEd.connect(
@@ -139,6 +148,12 @@
         """
         self.__ui.showMenu.disconnect(self.__populateMenu)
         
+        menu = self.__ui.getMenu("plugin_tools")
+        if menu is not None:
+            for act in self.__mainActions:
+                menu.removeAction(act)
+        self.__mainActions = []
+
         e5App().getObject("ViewManager").editorOpenedEd.disconnect(
             self.__editorOpened)
         e5App().getObject("ViewManager").editorClosedEd.disconnect(
@@ -212,16 +227,19 @@
         @param name name of the menu (string)
         @param menu reference to the menu to be populated (QMenu)
         """
-        if name != "Tools":
+        if name not in ["Tools", "PluginTools"]:
             return
         
         editor = e5App().getObject("ViewManager").activeWindow()
         
-        if not menu.isEmpty():
-            menu.addSeparator()
-        
-        act = menu.addMenu(self.__menu)
-        act.setEnabled(editor is not None)
+        if name == "Tools":
+            if not menu.isEmpty():
+                menu.addSeparator()
+            
+            act = menu.addMenu(self.__menu)
+            act.setEnabled(editor is not None)
+        elif name == "PluginTools" and self.__mainActions:
+            self.__mainActions[-1].setEnabled(editor is not None)
     
     def __editorOpened(self, editor):
         """
Binary file PluginPrintRemover.zip has changed

eric ide

mercurial