From 3c21d5986ea44d94c11130b36d69833aadb73941 Mon Sep 17 00:00:00 2001 From: ZDarian Date: Sun, 18 Jan 2015 07:34:33 -0700 Subject: [PATCH 01/11] Added toggle ability to :set Append '!' to option name of boolean value to toggle its state. --- qutebrowser/config/config.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/qutebrowser/config/config.py b/qutebrowser/config/config.py index b12c33dcf..170586090 100644 --- a/qutebrowser/config/config.py +++ b/qutebrowser/config/config.py @@ -499,6 +499,8 @@ class ConfigManager(QObject): If the option name ends with '?', the value of the option is shown instead. + If the option name ends with '!' and it is a boolean value, toggle it. + // Wrapper for self.set() to output exceptions in the status bar. @@ -523,6 +525,13 @@ class ConfigManager(QObject): val = self.get(sectname, optname[:-1], transformed=False) message.info(win_id, "{} {} = {}".format( sectname, optname[:-1], val), immediately=True) + elif optname.endswith('!'): + val = self.get(sectname, optname[:-1]) + layer = 'temp' if temp else 'conf' + if type(val) == type(True): + self.set(layer, sectname, optname[:-1], str(not val)) + else: + raise cmdexc.CommandError("set: Attempted inversion of non-boolean value. Aborting.") else: if value is None: raise cmdexc.CommandError("set: The following arguments " From 52afa1a4798c7c8918f272179d9a9984f5cb12ba Mon Sep 17 00:00:00 2001 From: ZDarian Date: Sun, 18 Jan 2015 07:39:26 -0700 Subject: [PATCH 02/11] Added permanent (count-independent) tab hide according to perm-hide variable. --- qutebrowser/config/configdata.py | 4 ++++ qutebrowser/mainwindow/tabwidget.py | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/qutebrowser/config/configdata.py b/qutebrowser/config/configdata.py index 9d22c1f72..e15e6c8d2 100644 --- a/qutebrowser/config/configdata.py +++ b/qutebrowser/config/configdata.py @@ -360,6 +360,10 @@ DATA = collections.OrderedDict([ SettingValue(typ.Bool(), 'false'), "Hide the tabbar if only one tab is open."), + ('perm-hide', + SettingValue(typ.Bool(), 'false'), + "Hide permanently."), + ('wrap', SettingValue(typ.Bool(), 'true'), "Whether to wrap when changing tabs."), diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index 6b1773fc6..94fe57c21 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -106,7 +106,8 @@ class TabBar(QTabBar): def autohide(self): """Auto-hide the tabbar if needed.""" auto_hide = config.get('tabs', 'auto-hide') - if auto_hide and self.count() == 1: + perm_hide = config.get('tabs', 'perm-hide') + if perm_hide or auto_hide and self.count() == 1: self.hide() else: self.show() From 5100f6fc8f2b1b88338e45fdd21e17569f4e383c Mon Sep 17 00:00:00 2001 From: ZDarian Date: Wed, 21 Jan 2015 07:24:05 -0700 Subject: [PATCH 03/11] better type check; -'aborting' --- qutebrowser/config/config.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qutebrowser/config/config.py b/qutebrowser/config/config.py index 170586090..85fe0ca57 100644 --- a/qutebrowser/config/config.py +++ b/qutebrowser/config/config.py @@ -528,10 +528,10 @@ class ConfigManager(QObject): elif optname.endswith('!'): val = self.get(sectname, optname[:-1]) layer = 'temp' if temp else 'conf' - if type(val) == type(True): + if isinstance(val, bool): self.set(layer, sectname, optname[:-1], str(not val)) else: - raise cmdexc.CommandError("set: Attempted inversion of non-boolean value. Aborting.") + raise cmdexc.CommandError("set: Attempted inversion of non-boolean value.") else: if value is None: raise cmdexc.CommandError("set: The following arguments " From 335f72a93f9e7a1d26dabc5690312e4f3cc7b71a Mon Sep 17 00:00:00 2001 From: ZDarian Date: Wed, 21 Jan 2015 07:27:08 -0700 Subject: [PATCH 04/11] perm-hide -> always-hide --- qutebrowser/config/configdata.py | 4 ++-- qutebrowser/mainwindow/tabwidget.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/qutebrowser/config/configdata.py b/qutebrowser/config/configdata.py index e15e6c8d2..aff20586a 100644 --- a/qutebrowser/config/configdata.py +++ b/qutebrowser/config/configdata.py @@ -360,9 +360,9 @@ DATA = collections.OrderedDict([ SettingValue(typ.Bool(), 'false'), "Hide the tabbar if only one tab is open."), - ('perm-hide', + ('always-hide', SettingValue(typ.Bool(), 'false'), - "Hide permanently."), + "Always hide the tabbar."), ('wrap', SettingValue(typ.Bool(), 'true'), diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index 94fe57c21..c110eb7bb 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -106,8 +106,8 @@ class TabBar(QTabBar): def autohide(self): """Auto-hide the tabbar if needed.""" auto_hide = config.get('tabs', 'auto-hide') - perm_hide = config.get('tabs', 'perm-hide') - if perm_hide or auto_hide and self.count() == 1: + always_hide = config.get('tabs', 'always-hide') + if always_hide or auto_hide and self.count() == 1: self.hide() else: self.show() From ef5412f5965181d93ca6cef9f5592da9df32525a Mon Sep 17 00:00:00 2001 From: ZDarian Date: Wed, 21 Jan 2015 20:50:30 -0700 Subject: [PATCH 05/11] tab *-hide -> tab hide-* --- qutebrowser/config/config.py | 2 ++ qutebrowser/config/configdata.py | 4 ++-- qutebrowser/mainwindow/tabwidget.py | 8 ++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/qutebrowser/config/config.py b/qutebrowser/config/config.py index 85fe0ca57..da15af77e 100644 --- a/qutebrowser/config/config.py +++ b/qutebrowser/config/config.py @@ -209,6 +209,8 @@ class ConfigManager(QObject): ('colors', 'tab.indicator.stop'): 'tabs.indicator.stop', ('colors', 'tab.indicator.error'): 'tabs.indicator.error', ('colors', 'tab.indicator.system'): 'tabs.indicator.system', + ('tabs', 'always-hide'): 'hide-always', + ('tabs', 'auto-hide'): 'hide-auto', } DELETED_OPTIONS = [ ('colors', 'tab.seperator'), diff --git a/qutebrowser/config/configdata.py b/qutebrowser/config/configdata.py index aff20586a..50f39c1ac 100644 --- a/qutebrowser/config/configdata.py +++ b/qutebrowser/config/configdata.py @@ -356,11 +356,11 @@ DATA = collections.OrderedDict([ SettingValue(typ.LastClose(), 'ignore'), "Behaviour when the last tab is closed."), - ('auto-hide', + ('hide-auto', SettingValue(typ.Bool(), 'false'), "Hide the tabbar if only one tab is open."), - ('always-hide', + ('hide-always', SettingValue(typ.Bool(), 'false'), "Always hide the tabbar."), diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index c110eb7bb..1cdd6a328 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -102,12 +102,12 @@ class TabBar(QTabBar): def __repr__(self): return utils.get_repr(self, count=self.count()) - @config.change_filter('tabs', 'auto-hide') + @config.change_filter('tabs', 'hide-auto') def autohide(self): """Auto-hide the tabbar if needed.""" - auto_hide = config.get('tabs', 'auto-hide') - always_hide = config.get('tabs', 'always-hide') - if always_hide or auto_hide and self.count() == 1: + hide_auto = config.get('tabs', 'hide-auto') + hide_always = config.get('tabs', 'hide-always') + if hide_always or hide_auto and self.count() == 1: self.hide() else: self.show() From d7b5f2bf52032cf6eb7584f24976b7176805e950 Mon Sep 17 00:00:00 2001 From: ZDarian Date: Wed, 21 Jan 2015 23:21:43 -0700 Subject: [PATCH 06/11] Remove always-hide from changed cfg --- qutebrowser/config/config.py | 1 - 1 file changed, 1 deletion(-) diff --git a/qutebrowser/config/config.py b/qutebrowser/config/config.py index da15af77e..76fae476b 100644 --- a/qutebrowser/config/config.py +++ b/qutebrowser/config/config.py @@ -209,7 +209,6 @@ class ConfigManager(QObject): ('colors', 'tab.indicator.stop'): 'tabs.indicator.stop', ('colors', 'tab.indicator.error'): 'tabs.indicator.error', ('colors', 'tab.indicator.system'): 'tabs.indicator.system', - ('tabs', 'always-hide'): 'hide-always', ('tabs', 'auto-hide'): 'hide-auto', } DELETED_OPTIONS = [ From 00f67135aee22eb46115fe0ae2192244af364fa4 Mon Sep 17 00:00:00 2001 From: ZDarian Date: Fri, 23 Jan 2015 06:34:01 -0700 Subject: [PATCH 07/11] Fixed tabbar visibility update --- qutebrowser/mainwindow/tabwidget.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index 1cdd6a328..48ca5a544 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -97,6 +97,7 @@ class TabBar(QTabBar): config_obj.changed.connect(self.set_colors) QTimer.singleShot(0, self.autohide) config_obj.changed.connect(self.autohide) + config_obj.changed.connect(self.alwayshide) config_obj.changed.connect(self.on_tab_colors_changed) def __repr__(self): @@ -104,14 +105,23 @@ class TabBar(QTabBar): @config.change_filter('tabs', 'hide-auto') def autohide(self): + self.tabhide() + + @config.change_filter('tabs', 'hide-always') + def alwayshide(self): + self.tabhide() + + def tabhide(self): """Auto-hide the tabbar if needed.""" hide_auto = config.get('tabs', 'hide-auto') hide_always = config.get('tabs', 'hide-always') + print('draw') if hide_always or hide_auto and self.count() == 1: self.hide() else: self.show() + def refresh(self): """Properly repaint the tab bar and relayout tabs.""" # This is a horrible hack, but we need to do this so the underlaying Qt From a08b814e5f503e19cfa47f447bf470aeda1cadd2 Mon Sep 17 00:00:00 2001 From: ZDarian Date: Fri, 23 Jan 2015 06:35:06 -0700 Subject: [PATCH 08/11] Accidentally left in print() used for testing --- qutebrowser/mainwindow/tabwidget.py | 1 - 1 file changed, 1 deletion(-) diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index 48ca5a544..c851dc914 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -115,7 +115,6 @@ class TabBar(QTabBar): """Auto-hide the tabbar if needed.""" hide_auto = config.get('tabs', 'hide-auto') hide_always = config.get('tabs', 'hide-always') - print('draw') if hide_always or hide_auto and self.count() == 1: self.hide() else: From 62adc5ffe37d7f9161bb70216678a054b2a18275 Mon Sep 17 00:00:00 2001 From: ZDarian Date: Fri, 23 Jan 2015 20:46:52 -0700 Subject: [PATCH 09/11] remove extra newline --- qutebrowser/mainwindow/tabwidget.py | 1 - 1 file changed, 1 deletion(-) diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index c851dc914..8707096f0 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -120,7 +120,6 @@ class TabBar(QTabBar): else: self.show() - def refresh(self): """Properly repaint the tab bar and relayout tabs.""" # This is a horrible hack, but we need to do this so the underlaying Qt From 0d93d1eaffaea6308858f735796839e9a78f9cf1 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sat, 24 Jan 2015 18:10:24 +0100 Subject: [PATCH 10/11] Minor style fixes. --- qutebrowser/config/config.py | 3 ++- qutebrowser/mainwindow/tabwidget.py | 14 ++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/qutebrowser/config/config.py b/qutebrowser/config/config.py index 76fae476b..8c70112c9 100644 --- a/qutebrowser/config/config.py +++ b/qutebrowser/config/config.py @@ -532,7 +532,8 @@ class ConfigManager(QObject): if isinstance(val, bool): self.set(layer, sectname, optname[:-1], str(not val)) else: - raise cmdexc.CommandError("set: Attempted inversion of non-boolean value.") + raise cmdexc.CommandError("set: Attempted inversion of " + "non-boolean value.") else: if value is None: raise cmdexc.CommandError("set: The following arguments " diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index 8707096f0..f87ab17f4 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -105,17 +105,19 @@ class TabBar(QTabBar): @config.change_filter('tabs', 'hide-auto') def autohide(self): - self.tabhide() - + """Hide tabbar if needed when tabs->hide-auto got changed.""" + self._tabhide() + @config.change_filter('tabs', 'hide-always') def alwayshide(self): - self.tabhide() + """Hide tabbar if needed when tabs->hide-always got changed.""" + self._tabhide() - def tabhide(self): - """Auto-hide the tabbar if needed.""" + def _tabhide(self): + """Hide the tabbar if needed.""" hide_auto = config.get('tabs', 'hide-auto') hide_always = config.get('tabs', 'hide-always') - if hide_always or hide_auto and self.count() == 1: + if hide_always or (hide_auto and self.count() == 1): self.hide() else: self.show() From ad53950e28b8ea7bce9eb838830ef506a32eeabc Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sat, 24 Jan 2015 18:10:45 +0100 Subject: [PATCH 11/11] Regenerate docs. --- README.asciidoc | 1 + doc/help/commands.asciidoc | 2 +- doc/help/settings.asciidoc | 18 +++++++++++++++--- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/README.asciidoc b/README.asciidoc index 5d7224455..52b36cec8 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -130,6 +130,7 @@ Contributors, sorted by the number of commits in descending order: // QUTE_AUTHORS_START * Florian Bruhin * Claude +* ZDarian * Peter Vilim * John ShaggyTwoDope Jenkins * rikn00 diff --git a/doc/help/commands.asciidoc b/doc/help/commands.asciidoc index 73cf2205a..32ae8e9a5 100644 --- a/doc/help/commands.asciidoc +++ b/doc/help/commands.asciidoc @@ -372,7 +372,7 @@ Syntax: +:set [*--temp*] ['section'] ['option'] ['value']+ Set an option. -If the option name ends with '?', the value of the option is shown instead. +If the option name ends with '?', the value of the option is shown instead. If the option name ends with '!' and it is a boolean value, toggle it. ==== positional arguments * +'section'+: The section where the option is in. diff --git a/doc/help/settings.asciidoc b/doc/help/settings.asciidoc index 4fa66ad19..05fd1c47c 100644 --- a/doc/help/settings.asciidoc +++ b/doc/help/settings.asciidoc @@ -82,7 +82,8 @@ |<>|How new tabs are positioned. |<>|How new tabs opened explicitely are positioned. |<>|Behaviour when the last tab is closed. -|<>|Hide the tabbar if only one tab is open. +|<>|Hide the tabbar if only one tab is open. +|<>|Always hide the tabbar. |<>|Whether to wrap when changing tabs. |<>|Whether tabs should be movable. |<>|On which mouse button to close tabs. @@ -718,8 +719,8 @@ Valid values: Default: +pass:[ignore]+ -[[tabs-auto-hide]] -=== auto-hide +[[tabs-hide-auto]] +=== hide-auto Hide the tabbar if only one tab is open. Valid values: @@ -729,6 +730,17 @@ Valid values: Default: +pass:[false]+ +[[tabs-hide-always]] +=== hide-always +Always hide the tabbar. + +Valid values: + + * +true+ + * +false+ + +Default: +pass:[false]+ + [[tabs-wrap]] === wrap Whether to wrap when changing tabs.