VCS Interfaces: added a configuration option to disable the VCS toolbars

Sat, 15 Aug 2020 19:14:03 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 15 Aug 2020 19:14:03 +0200
changeset 7667
cd2e9a5ee187
parent 7666
5d9e9c020454
child 7668
75b64f9e517c

VCS Interfaces: added a configuration option to disable the VCS toolbars

docs/changelog file | annotate | diff | comparison | revisions
eric6/Plugins/PluginVcsGit.py file | annotate | diff | comparison | revisions
eric6/Plugins/PluginVcsMercurial.py file | annotate | diff | comparison | revisions
eric6/Plugins/PluginVcsPySvn.py file | annotate | diff | comparison | revisions
eric6/Plugins/PluginVcsSubversion.py file | annotate | diff | comparison | revisions
eric6/Plugins/VcsPlugins/vcsGit/ProjectHelper.py file | annotate | diff | comparison | revisions
eric6/Plugins/VcsPlugins/vcsMercurial/ProjectHelper.py file | annotate | diff | comparison | revisions
eric6/Plugins/VcsPlugins/vcsPySvn/ProjectHelper.py file | annotate | diff | comparison | revisions
eric6/Plugins/VcsPlugins/vcsSubversion/ProjectHelper.py file | annotate | diff | comparison | revisions
eric6/Preferences/ConfigurationPages/VcsPage.py file | annotate | diff | comparison | revisions
eric6/Preferences/ConfigurationPages/VcsPage.ui file | annotate | diff | comparison | revisions
eric6/Preferences/__init__.py file | annotate | diff | comparison | revisions
eric6/UI/UserInterface.py file | annotate | diff | comparison | revisions
--- a/docs/changelog	Sat Aug 15 16:27:07 2020 +0200
+++ b/docs/changelog	Sat Aug 15 19:14:03 2020 +0200
@@ -4,7 +4,9 @@
 - bug fixes
 - Tasks
   -- added separate task categories for 'Test' and 'Documentation' tasks
-
+- VCS Interfaces
+  -- added a configuration option to disable the VCS toolbars
+  
 Version 20.8:
 - bug fixes
 
--- a/eric6/Plugins/PluginVcsGit.py	Sat Aug 15 16:27:07 2020 +0200
+++ b/eric6/Plugins/PluginVcsGit.py	Sat Aug 15 19:14:03 2020 +0200
@@ -234,17 +234,13 @@
         from VcsPlugins.vcsGit.git import Git
         self.__object = Git(self, self.__ui)
         
-        tbData = self.__ui.getToolbar("vcs")
-        if tbData:
-            tb = tbData[1]
-            tb.setVisible(False)
-            tb.setEnabled(False)
+        tb = self.__ui.getToolbar("vcs")[1]
+        tb.setVisible(False)
+        tb.setEnabled(False)
         
-        tbData = self.__ui.getToolbar("git")
-        if tbData:
-            tb = tbData[1]
-            tb.setVisible(True)
-            tb.setEnabled(True)
+        tb = self.__ui.getToolbar("git")[1]
+        tb.setVisible(Preferences.getVCS("ShowVcsToolbar"))
+        tb.setEnabled(True)
         
         return self.__object, True
     
@@ -254,17 +250,13 @@
         """
         self.__object = None
         
-        tbData = self.__ui.getToolbar("git")
-        if tbData:
-            tb = tbData[1]
-            tb.setVisible(False)
-            tb.setEnabled(False)
+        tb = self.__ui.getToolbar("git")[1]
+        tb.setVisible(False)
+        tb.setEnabled(False)
         
-        tbData = self.__ui.getToolbar("vcs")
-        if tbData:
-            tb = tbData[1]
-            tb.setVisible(True)
-            tb.setEnabled(True)
+        tb = self.__ui.getToolbar("vcs")[1]
+        tb.setVisible(Preferences.getVCS("ShowVcsToolbar"))
+        tb.setEnabled(True)
     
     @classmethod
     def getPreferences(cls, key):
--- a/eric6/Plugins/PluginVcsMercurial.py	Sat Aug 15 16:27:07 2020 +0200
+++ b/eric6/Plugins/PluginVcsMercurial.py	Sat Aug 15 19:14:03 2020 +0200
@@ -239,7 +239,7 @@
         tb.setEnabled(False)
         
         tb = self.__ui.getToolbar("mercurial")[1]
-        tb.setVisible(True)
+        tb.setVisible(Preferences.getVCS("ShowVcsToolbar"))
         tb.setEnabled(True)
         
         return self.__object, True
@@ -255,7 +255,7 @@
         tb.setEnabled(False)
         
         tb = self.__ui.getToolbar("vcs")[1]
-        tb.setVisible(True)
+        tb.setVisible(Preferences.getVCS("ShowVcsToolbar"))
         tb.setEnabled(True)
     
     @classmethod
--- a/eric6/Plugins/PluginVcsPySvn.py	Sat Aug 15 16:27:07 2020 +0200
+++ b/eric6/Plugins/PluginVcsPySvn.py	Sat Aug 15 19:14:03 2020 +0200
@@ -202,7 +202,7 @@
         tb.setEnabled(False)
         
         tb = self.__ui.getToolbar("pysvn")[1]
-        tb.setVisible(True)
+        tb.setVisible(Preferences.getVCS("ShowVcsToolbar"))
         tb.setEnabled(True)
         
         return self.__object, True
@@ -218,7 +218,7 @@
         tb.setEnabled(False)
         
         tb = self.__ui.getToolbar("vcs")[1]
-        tb.setVisible(True)
+        tb.setVisible(Preferences.getVCS("ShowVcsToolbar"))
         tb.setEnabled(True)
     
     def getPreferences(self, key):
--- a/eric6/Plugins/PluginVcsSubversion.py	Sat Aug 15 16:27:07 2020 +0200
+++ b/eric6/Plugins/PluginVcsSubversion.py	Sat Aug 15 19:14:03 2020 +0200
@@ -208,7 +208,7 @@
         tb.setEnabled(False)
         
         tb = self.__ui.getToolbar("subversion")[1]
-        tb.setVisible(True)
+        tb.setVisible(Preferences.getVCS("ShowVcsToolbar"))
         tb.setEnabled(True)
         
         return self.__object, True
@@ -224,7 +224,7 @@
         tb.setEnabled(False)
         
         tb = self.__ui.getToolbar("vcs")[1]
-        tb.setVisible(True)
+        tb.setVisible(Preferences.getVCS("ShowVcsToolbar"))
         tb.setEnabled(True)
     
     def getPreferences(self, key):
--- a/eric6/Plugins/VcsPlugins/vcsGit/ProjectHelper.py	Sat Aug 15 16:27:07 2020 +0200
+++ b/eric6/Plugins/VcsPlugins/vcsGit/ProjectHelper.py	Sat Aug 15 19:14:03 2020 +0200
@@ -1601,7 +1601,7 @@
         self.__toolbar.setVisible(False)
         
         ui.registerToolbar("git", self.__toolbar.windowTitle(),
-                           self.__toolbar)
+                           self.__toolbar, "vcs")
         ui.addToolBar(self.__toolbar)
     
     def removeToolbar(self, ui, toolbarManager):
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/ProjectHelper.py	Sat Aug 15 16:27:07 2020 +0200
+++ b/eric6/Plugins/VcsPlugins/vcsMercurial/ProjectHelper.py	Sat Aug 15 19:14:03 2020 +0200
@@ -1579,7 +1579,7 @@
         self.__toolbar.setVisible(False)
         
         ui.registerToolbar("mercurial", self.__toolbar.windowTitle(),
-                           self.__toolbar)
+                           self.__toolbar, "vcs")
         ui.addToolBar(self.__toolbar)
     
     def removeToolbar(self, ui, toolbarManager):
--- a/eric6/Plugins/VcsPlugins/vcsPySvn/ProjectHelper.py	Sat Aug 15 16:27:07 2020 +0200
+++ b/eric6/Plugins/VcsPlugins/vcsPySvn/ProjectHelper.py	Sat Aug 15 19:14:03 2020 +0200
@@ -585,7 +585,7 @@
         self.__toolbar.setVisible(False)
         
         ui.registerToolbar("pysvn", self.__toolbar.windowTitle(),
-                           self.__toolbar)
+                           self.__toolbar, "vcs")
         ui.addToolBar(self.__toolbar)
     
     def removeToolbar(self, ui, toolbarManager):
--- a/eric6/Plugins/VcsPlugins/vcsSubversion/ProjectHelper.py	Sat Aug 15 16:27:07 2020 +0200
+++ b/eric6/Plugins/VcsPlugins/vcsSubversion/ProjectHelper.py	Sat Aug 15 19:14:03 2020 +0200
@@ -568,7 +568,7 @@
         self.__toolbar.setVisible(False)
         
         ui.registerToolbar("subversion", self.__toolbar.windowTitle(),
-                           self.__toolbar)
+                           self.__toolbar, "vcs")
         ui.addToolBar(self.__toolbar)
     
     def removeToolbar(self, ui, toolbarManager):
--- a/eric6/Preferences/ConfigurationPages/VcsPage.py	Sat Aug 15 16:27:07 2020 +0200
+++ b/eric6/Preferences/ConfigurationPages/VcsPage.py	Sat Aug 15 19:14:03 2020 +0200
@@ -38,6 +38,8 @@
             Preferences.getVCS("MonitorLocalStatus"))
         self.autoUpdateCheckBox.setChecked(
             Preferences.getVCS("AutoUpdate"))
+        self.vcsToolbarCheckBox.setChecked(
+            Preferences.getVCS("ShowVcsToolbar"))
         
         self.initColour(
             "VcsAdded", self.pbVcsAddedButton,
@@ -80,6 +82,9 @@
         Preferences.setVCS(
             "AutoUpdate",
             self.autoUpdateCheckBox.isChecked())
+        Preferences.setVCS(
+            "ShowVcsToolbar",
+            self.vcsToolbarCheckBox.isChecked())
     
         self.saveColours(Preferences.setProjectBrowserColour)
 
--- a/eric6/Preferences/ConfigurationPages/VcsPage.ui	Sat Aug 15 16:27:07 2020 +0200
+++ b/eric6/Preferences/ConfigurationPages/VcsPage.ui	Sat Aug 15 19:14:03 2020 +0200
@@ -10,7 +10,7 @@
     <height>572</height>
    </rect>
   </property>
-  <layout class="QVBoxLayout" name="verticalLayout">
+  <layout class="QVBoxLayout" name="verticalLayout_2">
    <item>
     <widget class="QLabel" name="headerLabel">
      <property name="text">
@@ -283,6 +283,25 @@
     </widget>
    </item>
    <item>
+    <widget class="QGroupBox" name="groupBox_4">
+     <property name="title">
+      <string>Toolbars</string>
+     </property>
+     <layout class="QVBoxLayout" name="verticalLayout">
+      <item>
+       <widget class="QCheckBox" name="vcsToolbarCheckBox">
+        <property name="toolTip">
+         <string>Select to show VCS specific toolbars</string>
+        </property>
+        <property name="text">
+         <string>Show VCS Toolbar</string>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
     <spacer>
      <property name="orientation">
       <enum>Qt::Vertical</enum>
--- a/eric6/Preferences/__init__.py	Sat Aug 15 16:27:07 2020 +0200
+++ b/eric6/Preferences/__init__.py	Sat Aug 15 19:14:03 2020 +0200
@@ -1237,6 +1237,7 @@
         "AutoUpdate": False,
         "StatusMonitorInterval": 30,
         "MonitorLocalStatus": False,
+        "ShowVcsToolbar": True,
     }
     
     # defaults for tasks related stuff
--- a/eric6/UI/UserInterface.py	Sat Aug 15 16:27:07 2020 +0200
+++ b/eric6/UI/UserInterface.py	Sat Aug 15 19:14:03 2020 +0200
@@ -688,6 +688,15 @@
         splash.showMessage(self.tr("Setting View Profile..."))
         self.__setEditProfile()
         
+        # special treatment for the VCS toolbars
+        for tb in self.getToolbarsByCategory("vcs"):
+            tb.setVisible(False)
+            tb.setEnabled(False)
+        tb = self.getToolbar("vcs")[1]
+        tb.setEnabled(True)
+        if Preferences.getVCS("ShowVcsToolbar"):
+            tb.setVisible(True)
+        
         # now read the saved tasks
         splash.showMessage(self.tr("Reading Tasks..."))
         self.__readTasks()
@@ -3299,27 +3308,31 @@
 
         # just add new toolbars to the end of the list
         self.__toolbars = {}
-        self.__toolbars["file"] = [filetb.windowTitle(), filetb]
-        self.__toolbars["edit"] = [edittb.windowTitle(), edittb]
-        self.__toolbars["search"] = [searchtb.windowTitle(), searchtb]
-        self.__toolbars["view"] = [viewtb.windowTitle(), viewtb]
-        self.__toolbars["start"] = [starttb.windowTitle(), starttb]
-        self.__toolbars["debug"] = [debugtb.windowTitle(), debugtb]
-        self.__toolbars["project"] = [projecttb.windowTitle(), projecttb]
-        self.__toolbars["tools"] = [toolstb.windowTitle(), toolstb]
-        self.__toolbars["help"] = [helptb.windowTitle(), helptb]
-        self.__toolbars["settings"] = [settingstb.windowTitle(), settingstb]
-        self.__toolbars["bookmarks"] = [bookmarktb.windowTitle(), bookmarktb]
-        self.__toolbars["unittest"] = [unittesttb.windowTitle(), unittesttb]
+        self.__toolbars["file"] = [filetb.windowTitle(), filetb, ""]
+        self.__toolbars["edit"] = [edittb.windowTitle(), edittb, ""]
+        self.__toolbars["search"] = [searchtb.windowTitle(), searchtb, ""]
+        self.__toolbars["view"] = [viewtb.windowTitle(), viewtb, ""]
+        self.__toolbars["start"] = [starttb.windowTitle(), starttb, ""]
+        self.__toolbars["debug"] = [debugtb.windowTitle(), debugtb, ""]
+        self.__toolbars["project"] = [projecttb.windowTitle(), projecttb, ""]
+        self.__toolbars["tools"] = [toolstb.windowTitle(), toolstb, ""]
+        self.__toolbars["help"] = [helptb.windowTitle(), helptb, ""]
+        self.__toolbars["settings"] = [settingstb.windowTitle(), settingstb,
+                                       ""]
+        self.__toolbars["bookmarks"] = [bookmarktb.windowTitle(), bookmarktb,
+                                        ""]
+        self.__toolbars["unittest"] = [unittesttb.windowTitle(), unittesttb,
+                                       ""]
         self.__toolbars["view_profiles"] = [profilestb.windowTitle(),
-                                            profilestb]
-        self.__toolbars["plugins"] = [pluginstb.windowTitle(), pluginstb]
+                                            profilestb, ""]
+        self.__toolbars["plugins"] = [pluginstb.windowTitle(), pluginstb, ""]
         self.__toolbars["quicksearch"] = [quicksearchtb.windowTitle(),
-                                          quicksearchtb]
+                                          quicksearchtb, ""]
         self.__toolbars["multiproject"] = [multiprojecttb.windowTitle(),
-                                           multiprojecttb]
-        self.__toolbars["spelling"] = [spellingtb.windowTitle(), spellingtb]
-        self.__toolbars["vcs"] = [vcstb.windowTitle(), vcstb]
+                                           multiprojecttb, ""]
+        self.__toolbars["spelling"] = [spellingtb.windowTitle(), spellingtb,
+                                       ""]
+        self.__toolbars["vcs"] = [vcstb.windowTitle(), vcstb, "vcs"]
         
     def __initDebugToolbarsLayout(self):
         """
@@ -3843,34 +3856,44 @@
         except KeyError:
             return None
         
-    def registerToolbar(self, name, text, toolbar):
+    def registerToolbar(self, name, text, toolbar, category=""):
         """
         Public method to register a toolbar.
         
         This method must be called in order to make a toolbar manageable by the
         UserInterface object.
         
-        @param name name of the toolbar (string). This is used as the key into
+        @param name name of the toolbar. This is used as the key into
             the dictionary of toolbar references.
-        @param text user visible text for the toolbar entry (string)
-        @param toolbar reference to the toolbar to be registered (QToolBar)
+        @type str
+        @param text user visible text for the toolbar entry
+        @type str
+        @param toolbar reference to the toolbar to be registered
+        @type QToolBar
+        @param category toolbar category
+        @type str
         @exception KeyError raised, if a toolbar with the given name was
             already registered
         """
         if name in self.__toolbars:
             raise KeyError("Toolbar '{0}' already registered.".format(name))
         
-        self.__toolbars[name] = [text, toolbar]
-        
-    def reregisterToolbar(self, name, text):
+        self.__toolbars[name] = [text, toolbar, category]
+        
+    def reregisterToolbar(self, name, text, category=""):
         """
         Public method to change the visible text for the named toolbar.
         
-        @param name name of the toolbar to be changed (string)
-        @param text new user visible text for the toolbar entry (string)
+        @param name name of the toolbar to be changed
+        @type str
+        @param text new user visible text for the toolbar entry
+        @type str
+        @param category new toolbar category for the toolbar entry
+        @type str
         """
         if name in self.__toolbars:
             self.__toolbars[name][0] = text
+            self.__toolbars[name][2] = category
         
     def unregisterToolbar(self, name):
         """
@@ -3892,7 +3915,28 @@
             return self.__toolbars[name]
         except KeyError:
             return None
-        
+    
+    def getToolbarsByCategory(self, category):
+        """
+        Public method to get a list of toolbars belonging to a given toolbar
+        category.
+        
+        @param category toolbar category
+        @type str
+        @return list of toolbars
+        @rtype list of QToolBar
+        """
+        toolbars = []
+        for tbName in self.__toolbars:
+            try:
+                if self.__toolbars[tbName][2] == category:
+                    toolbars.append(self.__toolbars[tbName][1])
+            except IndexError:
+                # backward compatibility; category is not yet supported
+                pass
+        
+        return toolbars
+    
     def getLocale(self):
         """
         Public method to get the locale of the IDE.
@@ -4111,8 +4155,9 @@
         """
         menu.clear()
         
-        for name, (text, tb) in sorted(self.__toolbars.items(),
-                                       key=lambda t: t[1][0]):
+        for name, (text, tb, category) in sorted(
+            self.__toolbars.items(), key=lambda t: t[1][0]
+        ):
             act = menu.addAction(text)
             act.setCheckable(True)
             act.setChecked(not tb.isHidden())
@@ -4152,12 +4197,12 @@
         name = act.data()
         if name:
             if name == "__SHOW__":
-                for _text, tb in self.__toolbars.values():
+                for _text, tb, category in self.__toolbars.values():
                     tb.show()
                 if self.__menus["toolbars"].isTearOffMenuVisible():
                     self.__menus["toolbars"].hideTearOffMenu()
             elif name == "__HIDE__":
-                for _text, tb in self.__toolbars.values():
+                for _text, tb, category in self.__toolbars.values():
                     tb.hide()
                 if self.__menus["toolbars"].isTearOffMenuVisible():
                     self.__menus["toolbars"].hideTearOffMenu()
@@ -4165,6 +4210,7 @@
                 tb = self.__toolbars[name][1]
                 if act.isChecked():
                     tb.show()
+                    tb.setEnabled(True)
                 else:
                     tb.hide()
 
@@ -4178,15 +4224,16 @@
         name = act.data()
         if name:
             if name == "__SHOW__":
-                for _text, tb in self.__toolbars.values():
+                for _text, tb, category in self.__toolbars.values():
                     tb.show()
             elif name == "__HIDE__":
-                for _text, tb in self.__toolbars.values():
+                for _text, tb, category in self.__toolbars.values():
                     tb.hide()
             else:
                 tb = self.__toolbars[name][1]
                 if act.isChecked():
                     tb.show()
+                    tb.setEnabled(True)
                 else:
                     tb.hide()
             if self.__menus["toolbars"].isTearOffMenuVisible():

eric ide

mercurial