Merge branch 'toggletab' of https://github.com/smalltock/qutebrowser into smalltock-toggletab

This commit is contained in:
Florian Bruhin 2015-01-24 18:04:24 +01:00
commit 6ab65eb9d3
3 changed files with 27 additions and 4 deletions

View File

@ -209,6 +209,7 @@ 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', 'auto-hide'): 'hide-auto',
}
DELETED_OPTIONS = [
('colors', 'tab.seperator'),
@ -499,6 +500,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 +526,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 isinstance(val, bool):
self.set(layer, sectname, optname[:-1], str(not val))
else:
raise cmdexc.CommandError("set: Attempted inversion of non-boolean value.")
else:
if value is None:
raise cmdexc.CommandError("set: The following arguments "

View File

@ -356,10 +356,14 @@ 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."),
('hide-always',
SettingValue(typ.Bool(), 'false'),
"Always hide the tabbar."),
('wrap',
SettingValue(typ.Bool(), 'true'),
"Whether to wrap when changing tabs."),

View File

@ -97,16 +97,25 @@ 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):
return utils.get_repr(self, count=self.count())
@config.change_filter('tabs', 'auto-hide')
@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."""
auto_hide = config.get('tabs', 'auto-hide')
if 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()