'Tabs show' recommendations applied.
This commit is contained in:
parent
b4d5f9e7a6
commit
e58735f1d7
@ -481,11 +481,11 @@ def data(readonly=False):
|
|||||||
|
|
||||||
('show',
|
('show',
|
||||||
SettingValue(typ.TabBarShow(), 'always'),
|
SettingValue(typ.TabBarShow(), 'always'),
|
||||||
"The tab bar showing strategy."),
|
"When to show the tab bar"),
|
||||||
|
|
||||||
('show-switching-delay',
|
('show-switching-delay',
|
||||||
SettingValue(typ.Int(), '800'),
|
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',
|
('wrap',
|
||||||
SettingValue(typ.Bool(), 'true'),
|
SettingValue(typ.Bool(), 'true'),
|
||||||
|
@ -1568,12 +1568,9 @@ class UserAgent(BaseType):
|
|||||||
return out
|
return out
|
||||||
|
|
||||||
class TabBarShow(BaseType):
|
class TabBarShow(BaseType):
|
||||||
|
"""When to show the tab bar."""
|
||||||
"""How to format the question when downloading."""
|
|
||||||
|
|
||||||
valid_values = ValidValues(('always', "Always show the tab bar."),
|
valid_values = ValidValues(('always', "Always show the tab bar."),
|
||||||
('never', "Always hide the tab bar."),
|
('never', "Always hide the tab bar."),
|
||||||
('multiple', "Hide the tab bar if only one tab is open."),
|
('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."))
|
||||||
|
|
||||||
|
|
||||||
|
@ -221,13 +221,16 @@ class TabBar(QTabBar):
|
|||||||
config_obj = objreg.get('config')
|
config_obj = objreg.get('config')
|
||||||
config_obj.changed.connect(self.set_font)
|
config_obj.changed.connect(self.set_font)
|
||||||
self.vertical = False
|
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.setAutoFillBackground(True)
|
||||||
self.set_colors()
|
self.set_colors()
|
||||||
config_obj.changed.connect(self.set_colors)
|
config_obj.changed.connect(self.set_colors)
|
||||||
QTimer.singleShot(0, self._tabhide)
|
QTimer.singleShot(0, self._tabhide)
|
||||||
config_obj.changed.connect(self.on_tab_colors_changed)
|
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)
|
config_obj.changed.connect(self.tabs_show)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
@ -239,30 +242,24 @@ class TabBar(QTabBar):
|
|||||||
self._tabhide()
|
self._tabhide()
|
||||||
|
|
||||||
@config.change_filter('tabs', 'show-switching-delay')
|
@config.change_filter('tabs', 'show-switching-delay')
|
||||||
def showswitchingdelay(self):
|
def show_switching_delay(self):
|
||||||
"""Reset auto hide timer when tabs->show-switching-delay got changed."""
|
"""Set timer interval when tabs->show-switching-delay got changed."""
|
||||||
self.autoHideTimer = None
|
self._auto_hide_timer.setInterval(config.get('tabs', 'show-switching-delay'))
|
||||||
|
|
||||||
def on_change(self):
|
def on_change(self):
|
||||||
"""Show tab bar when current tab got changed."""
|
"""Show tab bar when current tab got changed."""
|
||||||
show = config.get('tabs', 'show')
|
show = config.get('tabs', 'show')
|
||||||
show_switching_delay = config.get('tabs', 'show-switching-delay')
|
|
||||||
if show == 'switching':
|
if show == 'switching':
|
||||||
self.show()
|
self.show()
|
||||||
if not self.autoHideTimer:
|
self._auto_hide_timer.start()
|
||||||
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):
|
def _tabhide(self):
|
||||||
"""Hide the tab bar if needed."""
|
"""Hide the tab bar if needed."""
|
||||||
show = config.get('tabs', 'show')
|
show = config.get('tabs', 'show')
|
||||||
showNever = show == 'never'
|
show_never = show == 'never'
|
||||||
showSwitching = show == 'switching'
|
switching = show == 'switching'
|
||||||
showMultiple = show == 'multiple'
|
multiple = show == 'multiple'
|
||||||
if showNever or (showMultiple and self.count() == 1) or showSwitching:
|
if show_never or (multiple and self.count() == 1) or switching:
|
||||||
self.hide()
|
self.hide()
|
||||||
else:
|
else:
|
||||||
self.show()
|
self.show()
|
||||||
|
Loading…
Reference in New Issue
Block a user