[PATCH] option to hide urlCombo (#2600)

7 views
Skip to first unread message

Marc Schlaich

unread,
May 23, 2013, 11:40:53 AM5/23/13
to thg...@googlegroups.com
I have two patches. The first one hides automatically if it has <= 1 alias:

# HG changeset patch
# User schlamar <marc.s...@googlemail.com>
# Date 1368771192 -7200
#      Fri May 17 08:13:12 2013 +0200
# Node ID 7bb762abc27b58fa4a0b2d5d9a6818d7f3e4aff4
# Parent  96275cf8d36474942e299868eefa16deb3bda243
workbench: hide urlCombo if there isn't more than 1 alias (fixes #2600)

diff -r 96275cf8d364 -r 7bb762abc27b tortoisehg/hgqt/workbench.py
--- a/tortoisehg/hgqt/workbench.py                   Thu May 23 00:54:27 2013 +0900
+++ b/tortoisehg/hgqt/workbench.py	Fri May 17 08:13:12 2013 +0200
@@ -369,7 +369,9 @@
                   enabled='repoopen', toolbar='sync')
         self.urlCombo = QComboBox(self)
         self.urlCombo.setSizeAdjustPolicy(QComboBox.AdjustToContents)
-        self.synctbar.addWidget(self.urlCombo)
+        self.urlComboAction = self.synctbar.addWidget(self.urlCombo)
+        # hide it because workbench could be started without open repo
+        self.urlComboAction.setVisible(False)
         self.synctbar.actionTriggered.connect(self._runSyncAction)
 
         self.updateMenu()
@@ -379,6 +381,11 @@
         aliases = [hglib.tounicode(alias)
                    for alias, path in repo.ui.configitems('paths')]
 
+        if len(aliases) <= 1:
+            self.urlComboAction.setVisible(False)
+        else:
+            self.urlComboAction.setVisible(True)
+
         # 1. Sort the list if aliases
         aliases.sort()
         # 2. Place the default alias at the top of the list

The second one adds a settings to configure either the auto behavior from above or "always on":

# HG changeset patch
# User schlamar <marc.s...@googlemail.com>
# Date 1369314907 -7200
#      Thu May 23 15:15:07 2013 +0200
# Node ID 6a1dbcb68024b241ae67c5b1a44a4ffde75e4f6d
# Parent  7bb762abc27b58fa4a0b2d5d9a6818d7f3e4aff4
workbench: added option to make urlCombo always visible (see #2600)

diff -r 7bb762abc27b -r 6a1dbcb68024 tortoisehg/hgqt/settings.py
--- a/tortoisehg/hgqt/settings.py         Fri May 17 08:13:12 2013 +0200
+++ b/tortoisehg/hgqt/settings.py	Thu May 23 15:15:07 2013 +0200
@@ -716,6 +716,14 @@
           '<li><b>never</b>: Never show any prompt to activate any bookmarks.'
           '</ul><p>'
           'Default: prompt')),
+    _fi(_('Target combo'), 'tortoisehg.workbench.target-combo', (genDefaultCombo,
+        ['auto', 'always']),
+        _('Select if TortoiseHg will show a target combo in the sync toolbar.'
+        '<ul><li><b>auto</b>: The default. Show the combo if more than one '
+        'target configured.'
+        '<li><b>always</b>: Always show the combo.'
+        '</ul><p>'
+        'Default: auto'), restartneeded=True,),
     )),
 ({'name': 'commit', 'label': _('Commit', 'config item'), 'icon': 'menucommit'},
  (
diff -r 7bb762abc27b -r 6a1dbcb68024 tortoisehg/hgqt/workbench.py
--- a/tortoisehg/hgqt/workbench.py	Fri May 17 08:13:12 2013 +0200
+++ b/tortoisehg/hgqt/workbench.py	Thu May 23 15:15:07 2013 +0200
@@ -381,7 +381,9 @@
         aliases = [hglib.tounicode(alias)
                    for alias, path in repo.ui.configitems('paths')]
 
-        if len(aliases) <= 1:
+        combo_setting = self.ui.config('tortoisehg', 'workbench.target-combo',
+                                       'auto')
+        if len(aliases) <= 1 and combo_setting == 'auto':
             self.urlComboAction.setVisible(False)
         else:
             self.urlComboAction.setVisible(True)
2600a.patch
2600b.patch

Yuya Nishihara

unread,
May 24, 2013, 12:03:07 PM5/24/13
to thg...@googlegroups.com
On Thu, 23 May 2013 08:40:53 -0700 (PDT), Marc Schlaich wrote:
> I have two patches. The first one hides automatically if it has <= 1 alias:
>
> # HG changeset patch
> # User schlamar <marc.s...@googlemail.com>
> # Date 1368771192 -7200
> # Fri May 17 08:13:12 2013 +0200
> # Node ID 7bb762abc27b58fa4a0b2d5d9a6818d7f3e4aff4
> # Parent 96275cf8d36474942e299868eefa16deb3bda243
> workbench: hide urlCombo if there isn't more than 1 alias (fixes #2600)

Queued them for default branch. Thanks.

[...]

> --- a/tortoisehg/hgqt/workbench.py Fri May 17 08:13:12 2013 +0200
> +++ b/tortoisehg/hgqt/workbench.py Thu May 23 15:15:07 2013 +0200
> @@ -381,7 +381,9 @@
> aliases = [hglib.tounicode(alias)
> for alias, path in repo.ui.configitems('paths')]
>
> - if len(aliases) <= 1:
> + combo_setting = self.ui.config('tortoisehg', 'workbench.target-combo',
> + 'auto')
> + if len(aliases) <= 1 and combo_setting == 'auto':
> self.urlComboAction.setVisible(False)
> else:
> self.urlComboAction.setVisible(True)

Probably repo.ui.config() is better. Somebody might set 'target-combo' value to
per-repository config.

Regards,
Reply all
Reply to author
Forward
0 new messages