PluginColorString.py

changeset 17
b8fac5c059fb
parent 16
126fc3a16ebf
child 18
a1e72b3e06cc
--- a/PluginColorString.py	Thu Jan 01 13:27:54 2015 +0100
+++ b/PluginColorString.py	Fri Jan 02 17:07:54 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 = "ColorStringPlugin"
 packageName = "ColorString"
 shortDescription = "Insert color as string"
@@ -157,6 +157,7 @@
             act = menu.addMenu(self.__menu)
             self.__menu.setEnabled(True)
             self.__editors[editor].append(act)
+            editor.showMenu.connect(self.__editorShowMenu)
     
     def __editorClosed(self, editor):
         """
@@ -171,6 +172,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 __isHexString(self, text):
         """
         Private method to check, if a given text is a hex string.

eric ide

mercurial