Changed code to close torn off submenus of the Mercurial project menu.

Sun, 29 May 2011 18:04:36 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 29 May 2011 18:04:36 +0200
changeset 1076
6fb76985422b
parent 1075
75bfe8bd4243
child 1078
aeee8401e2ce

Changed code to close torn off submenus of the Mercurial project menu.

Plugins/VcsPlugins/vcsMercurial/ProjectHelper.py file | annotate | diff | comparison | revisions
Plugins/VcsPlugins/vcsMercurial/hg.py file | annotate | diff | comparison | revisions
Project/Project.py file | annotate | diff | comparison | revisions
--- a/Plugins/VcsPlugins/vcsMercurial/ProjectHelper.py	Sun May 29 15:25:28 2011 +0200
+++ b/Plugins/VcsPlugins/vcsMercurial/ProjectHelper.py	Sun May 29 18:04:36 2011 +0200
@@ -842,7 +842,8 @@
         """
         menu.clear()
         
-        # TODO: close torn off menus in the shutdown method (extend base class with this method)
+        self.subMenus = []
+        
         adminMenu = QMenu(self.trUtf8("Repository Administration"), menu)
         adminMenu.setTearOffEnabled(True)
         adminMenu.addAction(self.hgHeadsAct)
@@ -864,12 +865,14 @@
         adminMenu.addAction(self.hgRollbackAct)
         adminMenu.addSeparator()
         adminMenu.addAction(self.hgVerifyAct)
+        self.subMenus.append(adminMenu)
         
         specialsMenu = QMenu(self.trUtf8("Specials"), menu)
         specialsMenu.setTearOffEnabled(True)
         specialsMenu.addAction(self.hgPushForcedAct)
         specialsMenu.addSeparator()
         specialsMenu.addAction(self.hgServeAct)
+        self.subMenus.append(specialsMenu)
         
         bundleMenu = QMenu(self.trUtf8("Changegroup Management"), menu)
         bundleMenu.setTearOffEnabled(True)
@@ -877,6 +880,7 @@
         bundleMenu.addAction(self.hgIdentifyBundleAct)
         bundleMenu.addAction(self.hgPreviewBundleAct)
         bundleMenu.addAction(self.hgUnbundleAct)
+        self.subMenus.append(bundleMenu)
         
         bisectMenu = QMenu(self.trUtf8("Bisect"), menu)
         bisectMenu.setTearOffEnabled(True)
@@ -884,6 +888,7 @@
         bisectMenu.addAction(self.hgBisectBadAct)
         bisectMenu.addAction(self.hgBisectSkipAct)
         bisectMenu.addAction(self.hgBisectResetAct)
+        self.subMenus.append(bisectMenu)
         
         extensionsMenu = QMenu(self.trUtf8("Extensions"), menu)
         extensionsMenu.aboutToShow.connect(self.__showExtensionMenu)
@@ -957,6 +962,21 @@
         menu.addAction(self.hgEditUserConfigAct)
         menu.addAction(self.hgConfigAct)
     
+    def shutdown(self):
+        """
+        Public method to perform shutdown actions.
+        """
+        # close torn off sub menus
+        for menu in self.subMenus:
+            if menu.isTearOffMenuVisible():
+                menu.hideTearOffMenu()
+        
+        # close torn off extension menus
+        for extensionName in self.extensionMenus:
+            menu = self.extensionMenus[extensionName].menu()
+            if menu.isTearOffMenuVisible():
+                menu.hideTearOffMenu()
+    
     def __showExtensionMenu(self):
         """
         Private slot showing the extensions menu.
--- a/Plugins/VcsPlugins/vcsMercurial/hg.py	Sun May 29 15:25:28 2011 +0200
+++ b/Plugins/VcsPlugins/vcsMercurial/hg.py	Sun May 29 18:04:36 2011 +0200
@@ -176,6 +176,9 @@
         if self.bundleFile and os.path.exists(self.bundleFile):
             os.remove(self.bundleFile)
         
+        # shut down the project helpers
+        self.__projectHelper.shutdown()
+        
         # shut down the extensions
         for extension in self.__extensions.values():
             extension.shutdown()
@@ -2306,10 +2309,10 @@
         @param project reference to the project object
         @return the project helper object
         """
-        helper = self.__plugin.getProjectHelper()
-        helper.setObjects(self, project)
+        self.__projectHelper = self.__plugin.getProjectHelper()
+        self.__projectHelper.setObjects(self, project)
         self.__monitorRepoIniFile(project.ppath)
-        return helper
+        return self.__projectHelper
 
     ############################################################################
     ##  Status Monitor Thread methods
--- a/Project/Project.py	Sun May 29 15:25:28 2011 +0200
+++ b/Project/Project.py	Sun May 29 18:04:36 2011 +0200
@@ -2535,7 +2535,6 @@
         
         # now shutdown the vcs interface
         if self.vcs:
-            # TODO: if not reopen: close torn off vcs menus
             self.vcs.vcsShutdown()
             self.vcs = None
             e5App().getObject("PluginManager").deactivateVcsPlugins()

eric ide

mercurial