From b4d5f9e7a6129bccf07feb50c193a448e4dda234 Mon Sep 17 00:00:00 2001 From: Artur Shaik Date: Fri, 19 Jun 2015 12:06:48 +0600 Subject: [PATCH 1/5] Tabs->show option. Issue #771 Implemted common option for tab bar show strategy. Options: always, never, multiple, switching. --- qutebrowser/config/configdata.py | 12 ++++----- qutebrowser/config/configtypes.py | 11 ++++++++ qutebrowser/mainwindow/tabwidget.py | 41 ++++++++++++++++++++--------- 3 files changed, 46 insertions(+), 18 deletions(-) diff --git a/qutebrowser/config/configdata.py b/qutebrowser/config/configdata.py index 5968731f3..87ff31995 100644 --- a/qutebrowser/config/configdata.py +++ b/qutebrowser/config/configdata.py @@ -479,13 +479,13 @@ def data(readonly=False): SettingValue(typ.LastClose(), 'ignore'), "Behavior when the last tab is closed."), - ('hide-auto', - SettingValue(typ.Bool(), 'false'), - "Hide the tab bar if only one tab is open."), + ('show', + SettingValue(typ.TabBarShow(), 'always'), + "The tab bar showing strategy."), - ('hide-always', - SettingValue(typ.Bool(), 'false'), - "Always hide the tab bar."), + ('show-switching-delay', + SettingValue(typ.Int(), '800'), + "Time to show tab bar before hide it when tabs->show is switching."), ('wrap', SettingValue(typ.Bool(), 'true'), diff --git a/qutebrowser/config/configtypes.py b/qutebrowser/config/configtypes.py index da2efda06..c054d1779 100644 --- a/qutebrowser/config/configtypes.py +++ b/qutebrowser/config/configtypes.py @@ -1566,3 +1566,14 @@ class UserAgent(BaseType): "curl 7.40.0") ] return out + +class TabBarShow(BaseType): + + """How to format the question when downloading.""" + + valid_values = ValidValues(('always', "Always show the tab bar."), + ('never', "Always hide the tab bar."), + ('multiple', "Hide the tab bar if only one tab is open."), + ('switching', "Show the tab bar only when current tab changed.")) + + diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index 5ba9bb66d..14e428fe9 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -194,6 +194,7 @@ class TabWidget(QTabWidget): @pyqtSlot(int) def emit_tab_index_changed(self, index): """Emit the tab_index_changed signal if the current tab changed.""" + self.tabBar().on_change() self.tab_index_changed.emit(index, self.count()) @@ -220,32 +221,48 @@ class TabBar(QTabBar): config_obj = objreg.get('config') config_obj.changed.connect(self.set_font) self.vertical = False + self.autoHideTimer = None self.setAutoFillBackground(True) self.set_colors() config_obj.changed.connect(self.set_colors) QTimer.singleShot(0, self._tabhide) - config_obj.changed.connect(self.autohide) - config_obj.changed.connect(self.alwayshide) config_obj.changed.connect(self.on_tab_colors_changed) + config_obj.changed.connect(self.showswitchingdelay) + config_obj.changed.connect(self.tabs_show) def __repr__(self): return utils.get_repr(self, count=self.count()) - @config.change_filter('tabs', 'hide-auto') - def autohide(self): - """Hide tab bar if needed when tabs->hide-auto got changed.""" + @config.change_filter('tabs', 'show') + def tabs_show(self): + """Hide or show tab bar if needed when tabs->show got changed.""" self._tabhide() - @config.change_filter('tabs', 'hide-always') - def alwayshide(self): - """Hide tab bar if needed when tabs->hide-always got changed.""" - self._tabhide() + @config.change_filter('tabs', 'show-switching-delay') + def showswitchingdelay(self): + """Reset auto hide timer when tabs->show-switching-delay got changed.""" + self.autoHideTimer = None + + def on_change(self): + """Show tab bar when current tab got changed.""" + show = config.get('tabs', 'show') + show_switching_delay = config.get('tabs', 'show-switching-delay') + if show == 'switching': + self.show() + if not self.autoHideTimer: + self.autoHideTimer = QTimer() + self.autoHideTimer.setInterval(show_switching_delay) + self.autoHideTimer.setSingleShot(True) + self.autoHideTimer.timeout.connect(self._tabhide) + self.autoHideTimer.start() def _tabhide(self): """Hide the tab bar 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): + show = config.get('tabs', 'show') + showNever = show == 'never' + showSwitching = show == 'switching' + showMultiple = show == 'multiple' + if showNever or (showMultiple and self.count() == 1) or showSwitching: self.hide() else: self.show() From e58735f1d70a57bbc265ec8ec1dfb3dd5fd38504 Mon Sep 17 00:00:00 2001 From: Artur Shaik Date: Fri, 19 Jun 2015 21:29:23 +0600 Subject: [PATCH 2/5] 'Tabs show' recommendations applied. --- qutebrowser/config/configdata.py | 4 ++-- qutebrowser/config/configtypes.py | 7 ++----- qutebrowser/mainwindow/tabwidget.py | 29 +++++++++++++---------------- 3 files changed, 17 insertions(+), 23 deletions(-) diff --git a/qutebrowser/config/configdata.py b/qutebrowser/config/configdata.py index 87ff31995..f38192c85 100644 --- a/qutebrowser/config/configdata.py +++ b/qutebrowser/config/configdata.py @@ -481,11 +481,11 @@ def data(readonly=False): ('show', SettingValue(typ.TabBarShow(), 'always'), - "The tab bar showing strategy."), + "When to show the tab bar"), ('show-switching-delay', SettingValue(typ.Int(), '800'), - "Time to show tab bar before hide it when tabs->show is switching."), + "Time to show the tab bar before hiding it when tabs->show is set to 'switching'."), ('wrap', SettingValue(typ.Bool(), 'true'), diff --git a/qutebrowser/config/configtypes.py b/qutebrowser/config/configtypes.py index c054d1779..8541b81c4 100644 --- a/qutebrowser/config/configtypes.py +++ b/qutebrowser/config/configtypes.py @@ -1568,12 +1568,9 @@ class UserAgent(BaseType): return out class TabBarShow(BaseType): - - """How to format the question when downloading.""" + """When to show the tab bar.""" valid_values = ValidValues(('always', "Always show the tab bar."), ('never', "Always hide the tab bar."), ('multiple', "Hide the tab bar if only one tab is open."), - ('switching', "Show the tab bar only when current tab changed.")) - - + ('switching', "Show the tab bar when switching tabs.")) diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index 14e428fe9..18efe5df5 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -221,13 +221,16 @@ class TabBar(QTabBar): config_obj = objreg.get('config') config_obj.changed.connect(self.set_font) self.vertical = False - self.autoHideTimer = None + self._auto_hide_timer = QTimer() + self._auto_hide_timer.setSingleShot(True) + self._auto_hide_timer.setInterval(config.get('tabs', 'show-switching-delay')) + self._auto_hide_timer.timeout.connect(self._tabhide) self.setAutoFillBackground(True) self.set_colors() config_obj.changed.connect(self.set_colors) QTimer.singleShot(0, self._tabhide) config_obj.changed.connect(self.on_tab_colors_changed) - config_obj.changed.connect(self.showswitchingdelay) + config_obj.changed.connect(self.show_switching_delay) config_obj.changed.connect(self.tabs_show) def __repr__(self): @@ -239,30 +242,24 @@ class TabBar(QTabBar): self._tabhide() @config.change_filter('tabs', 'show-switching-delay') - def showswitchingdelay(self): - """Reset auto hide timer when tabs->show-switching-delay got changed.""" - self.autoHideTimer = None + def show_switching_delay(self): + """Set timer interval when tabs->show-switching-delay got changed.""" + self._auto_hide_timer.setInterval(config.get('tabs', 'show-switching-delay')) def on_change(self): """Show tab bar when current tab got changed.""" show = config.get('tabs', 'show') - show_switching_delay = config.get('tabs', 'show-switching-delay') if show == 'switching': self.show() - if not self.autoHideTimer: - self.autoHideTimer = QTimer() - self.autoHideTimer.setInterval(show_switching_delay) - self.autoHideTimer.setSingleShot(True) - self.autoHideTimer.timeout.connect(self._tabhide) - self.autoHideTimer.start() + self._auto_hide_timer.start() def _tabhide(self): """Hide the tab bar if needed.""" show = config.get('tabs', 'show') - showNever = show == 'never' - showSwitching = show == 'switching' - showMultiple = show == 'multiple' - if showNever or (showMultiple and self.count() == 1) or showSwitching: + show_never = show == 'never' + switching = show == 'switching' + multiple = show == 'multiple' + if show_never or (multiple and self.count() == 1) or switching: self.hide() else: self.show() From 6b98158d6457c3059920461e5cb98d505c5cc420 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sat, 1 Aug 2015 21:29:43 +0200 Subject: [PATCH 3/5] Fix lint. --- qutebrowser/config/configdata.py | 3 ++- qutebrowser/config/configtypes.py | 8 ++++++-- qutebrowser/mainwindow/tabwidget.py | 10 ++++++---- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/qutebrowser/config/configdata.py b/qutebrowser/config/configdata.py index f38192c85..75fd1b6ad 100644 --- a/qutebrowser/config/configdata.py +++ b/qutebrowser/config/configdata.py @@ -485,7 +485,8 @@ def data(readonly=False): ('show-switching-delay', SettingValue(typ.Int(), '800'), - "Time to show the tab bar before hiding it when tabs->show is set to 'switching'."), + "Time to show the tab bar before hiding it when tabs->show is " + "set to 'switching'."), ('wrap', SettingValue(typ.Bool(), 'true'), diff --git a/qutebrowser/config/configtypes.py b/qutebrowser/config/configtypes.py index 8541b81c4..e6e2ab0af 100644 --- a/qutebrowser/config/configtypes.py +++ b/qutebrowser/config/configtypes.py @@ -1567,10 +1567,14 @@ class UserAgent(BaseType): ] return out + class TabBarShow(BaseType): + """When to show the tab bar.""" valid_values = ValidValues(('always', "Always show the tab bar."), ('never', "Always hide the tab bar."), - ('multiple', "Hide the tab bar if only one tab is open."), - ('switching', "Show the tab bar when switching tabs.")) + ('multiple', "Hide the tab bar if only one tab " + "is open."), + ('switching', "Show the tab bar when switching " + "tabs.")) diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index 18efe5df5..ea1426add 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -223,14 +223,15 @@ class TabBar(QTabBar): self.vertical = False self._auto_hide_timer = QTimer() self._auto_hide_timer.setSingleShot(True) - self._auto_hide_timer.setInterval(config.get('tabs', 'show-switching-delay')) + self._auto_hide_timer.setInterval( + config.get('tabs', 'show-switching-delay')) self._auto_hide_timer.timeout.connect(self._tabhide) self.setAutoFillBackground(True) self.set_colors() config_obj.changed.connect(self.set_colors) QTimer.singleShot(0, self._tabhide) config_obj.changed.connect(self.on_tab_colors_changed) - config_obj.changed.connect(self.show_switching_delay) + config_obj.changed.connect(self.on_show_switching_delay_changed) config_obj.changed.connect(self.tabs_show) def __repr__(self): @@ -242,9 +243,10 @@ class TabBar(QTabBar): self._tabhide() @config.change_filter('tabs', 'show-switching-delay') - def show_switching_delay(self): + def on_show_switching_delay_changed(self): """Set timer interval when tabs->show-switching-delay got changed.""" - self._auto_hide_timer.setInterval(config.get('tabs', 'show-switching-delay')) + self._auto_hide_timer.setInterval( + config.get('tabs', 'show-switching-delay')) def on_change(self): """Show tab bar when current tab got changed.""" From d8017a04a872a53890609ae10f11de206b7bf444 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sat, 1 Aug 2015 22:36:59 +0200 Subject: [PATCH 4/5] Mark old tabbar hide settings as removed. --- qutebrowser/config/config.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/qutebrowser/config/config.py b/qutebrowser/config/config.py index 061e8fda1..378b3b5bd 100644 --- a/qutebrowser/config/config.py +++ b/qutebrowser/config/config.py @@ -328,6 +328,8 @@ class ConfigManager(QObject): ('colors', 'tabs.separator'), ('colors', 'completion.item.bg'), ('tabs', 'indicator-space'), + ('tabs', 'hide-auto'), + ('tabs', 'hide-always'), ] CHANGED_OPTIONS = { ('content', 'cookies-accept'): From f89adc28732573a93e671ced1b93583356e31c54 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sat, 1 Aug 2015 22:43:20 +0200 Subject: [PATCH 5/5] Update docs. --- CHANGELOG.asciidoc | 5 +++++ doc/help/settings.asciidoc | 31 ++++++++++++++----------------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 8c63de871..282f776fc 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -29,6 +29,9 @@ Added size/padding of the tabbar. - New setting `network -> referer-header` to configure when the referer should be sent (by default it's only sent while on the same domain). +- New setting `tabs -> show` which supersedes the old `tabs -> hide-*` options + and has an additional `switching` option which shows tab while switching + them. There's also a new `show-switching` option to configure the timeout. Changed ~~~~~~~ @@ -52,6 +55,8 @@ Removed - The `tabs -> indicator-space` setting got removed as the new padding settings should be used instead. +- The `tabs -> hide-always` and `tabs -> hide-auto` settings got merged into + the new `tabs -> show` setting. v0.3.0 ------ diff --git a/doc/help/settings.asciidoc b/doc/help/settings.asciidoc index 62593eacd..cd11988b8 100644 --- a/doc/help/settings.asciidoc +++ b/doc/help/settings.asciidoc @@ -102,8 +102,8 @@ |<>|How new tabs are positioned. |<>|How new tabs opened explicitly are positioned. |<>|Behavior when the last tab is closed. -|<>|Hide the tab bar if only one tab is open. -|<>|Always hide the tab bar. +|<>|When to show the tab bar +|<>|Time to show the tab bar before hiding it when tabs->show is set to 'switching'. |<>|Whether to wrap when changing tabs. |<>|Whether tabs should be movable. |<>|On which mouse button to close tabs. @@ -961,27 +961,24 @@ Valid values: Default: +pass:[ignore]+ -[[tabs-hide-auto]] -=== hide-auto -Hide the tab bar if only one tab is open. +[[tabs-show]] +=== show +When to show the tab bar Valid values: - * +true+ - * +false+ + * +always+: Always show the tab bar. + * +never+: Always hide the tab bar. + * +multiple+: Hide the tab bar if only one tab is open. + * +switching+: Show the tab bar when switching tabs. -Default: +pass:[false]+ +Default: +pass:[always]+ -[[tabs-hide-always]] -=== hide-always -Always hide the tab bar. +[[tabs-show-switching-delay]] +=== show-switching-delay +Time to show the tab bar before hiding it when tabs->show is set to 'switching'. -Valid values: - - * +true+ - * +false+ - -Default: +pass:[false]+ +Default: +pass:[800]+ [[tabs-wrap]] === wrap