Merge branch 'artur-shaik-auto_show_tabbar'
This commit is contained in:
commit
0734d9f0de
@ -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
|
||||
------
|
||||
|
@ -102,8 +102,8 @@
|
||||
|<<tabs-new-tab-position,new-tab-position>>|How new tabs are positioned.
|
||||
|<<tabs-new-tab-position-explicit,new-tab-position-explicit>>|How new tabs opened explicitly are positioned.
|
||||
|<<tabs-last-close,last-close>>|Behavior when the last tab is closed.
|
||||
|<<tabs-hide-auto,hide-auto>>|Hide the tab bar if only one tab is open.
|
||||
|<<tabs-hide-always,hide-always>>|Always hide the tab bar.
|
||||
|<<tabs-show,show>>|When to show 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'.
|
||||
|<<tabs-wrap,wrap>>|Whether to wrap when changing tabs.
|
||||
|<<tabs-movable,movable>>|Whether tabs should be movable.
|
||||
|<<tabs-close-mouse-button,close-mouse-button>>|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
|
||||
|
@ -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'):
|
||||
|
@ -479,13 +479,14 @@ 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'),
|
||||
"When to show the tab bar"),
|
||||
|
||||
('hide-always',
|
||||
SettingValue(typ.Bool(), 'false'),
|
||||
"Always hide the tab bar."),
|
||||
('show-switching-delay',
|
||||
SettingValue(typ.Int(), '800'),
|
||||
"Time to show the tab bar before hiding it when tabs->show is "
|
||||
"set to 'switching'."),
|
||||
|
||||
('wrap',
|
||||
SettingValue(typ.Bool(), 'true'),
|
||||
|
@ -1566,3 +1566,15 @@ class UserAgent(BaseType):
|
||||
"curl 7.40.0")
|
||||
]
|
||||
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."))
|
||||
|
@ -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,47 @@ class TabBar(QTabBar):
|
||||
config_obj = objreg.get('config')
|
||||
config_obj.changed.connect(self.set_font)
|
||||
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.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.autohide)
|
||||
config_obj.changed.connect(self.alwayshide)
|
||||
config_obj.changed.connect(self.on_tab_colors_changed)
|
||||
config_obj.changed.connect(self.on_show_switching_delay_changed)
|
||||
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 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'))
|
||||
|
||||
def on_change(self):
|
||||
"""Show tab bar when current tab got changed."""
|
||||
show = config.get('tabs', 'show')
|
||||
if show == 'switching':
|
||||
self.show()
|
||||
self._auto_hide_timer.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')
|
||||
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()
|
||||
|
Loading…
Reference in New Issue
Block a user