From 3c21d5986ea44d94c11130b36d69833aadb73941 Mon Sep 17 00:00:00 2001 From: ZDarian Date: Sun, 18 Jan 2015 07:34:33 -0700 Subject: [PATCH 1/9] 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 2/9] 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 3/9] 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 4/9] 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 5/9] 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 6/9] 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 7/9] 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 8/9] 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 9/9] 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