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()