Merge branch 'smalltock-toggletab'

This commit is contained in:
Florian Bruhin 2015-01-24 18:10:52 +01:00
commit 7a11be1fb1
6 changed files with 48 additions and 9 deletions

View File

@ -130,6 +130,7 @@ Contributors, sorted by the number of commits in descending order:
// QUTE_AUTHORS_START
* Florian Bruhin
* Claude
* ZDarian
* Peter Vilim
* John ShaggyTwoDope Jenkins
* rikn00

View File

@ -372,7 +372,7 @@ Syntax: +:set [*--temp*] ['section'] ['option'] ['value']+
Set an option.
If the option name ends with '?', the value of the option is shown instead.
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.
==== positional arguments
* +'section'+: The section where the option is in.

View File

@ -82,7 +82,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 explicitely are positioned.
|<<tabs-last-close,last-close>>|Behaviour when the last tab is closed.
|<<tabs-auto-hide,auto-hide>>|Hide the tabbar if only one tab is open.
|<<tabs-hide-auto,hide-auto>>|Hide the tabbar if only one tab is open.
|<<tabs-hide-always,hide-always>>|Always hide the tabbar.
|<<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.
@ -718,8 +719,8 @@ Valid values:
Default: +pass:[ignore]+
[[tabs-auto-hide]]
=== auto-hide
[[tabs-hide-auto]]
=== hide-auto
Hide the tabbar if only one tab is open.
Valid values:
@ -729,6 +730,17 @@ Valid values:
Default: +pass:[false]+
[[tabs-hide-always]]
=== hide-always
Always hide the tabbar.
Valid values:
* +true+
* +false+
Default: +pass:[false]+
[[tabs-wrap]]
=== wrap
Whether to wrap when changing tabs.

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,14 @@ 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,27 @@ 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):
"""Auto-hide the tabbar if needed."""
auto_hide = config.get('tabs', 'auto-hide')
if auto_hide and self.count() == 1:
"""Hide tabbar if needed when tabs->hide-auto got changed."""
self._tabhide()
@config.change_filter('tabs', 'hide-always')
def alwayshide(self):
"""Hide tabbar if needed when tabs->hide-always got changed."""
self._tabhide()
def _tabhide(self):
"""Hide the tabbar 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):
self.hide()
else:
self.show()