Add config for tab colors for odd/even sel. tabs.

This commit is contained in:
Florian Bruhin 2015-09-19 21:45:57 +02:00
parent 957116658d
commit f96de5a598
4 changed files with 37 additions and 13 deletions

View File

@ -23,6 +23,12 @@ Added
- New setting `ui -> hide-wayland-decoration` to hide the window decoration - New setting `ui -> hide-wayland-decoration` to hide the window decoration
when using wayland. when using wayland.
Changed
~~~~~~~
- The `colors -> tabs.bg/fg.selected` option got split into
`tabs.bg/fg.selected.odd/even`.
Fixed Fixed
~~~~~ ~~~~~

View File

@ -324,10 +324,12 @@ class ConfigManager(QObject):
RENAMED_OPTIONS = { RENAMED_OPTIONS = {
('colors', 'tab.fg.odd'): 'tabs.fg.odd', ('colors', 'tab.fg.odd'): 'tabs.fg.odd',
('colors', 'tab.fg.even'): 'tabs.fg.even', ('colors', 'tab.fg.even'): 'tabs.fg.even',
('colors', 'tab.fg.selected'): 'tabs.fg.selected', ('colors', 'tab.fg.selected'): 'tabs.fg.selected.odd',
('colors', 'tabs.fg.selected'): 'tabs.fg.selected.odd',
('colors', 'tab.bg.odd'): 'tabs.bg.odd', ('colors', 'tab.bg.odd'): 'tabs.bg.odd',
('colors', 'tab.bg.even'): 'tabs.bg.even', ('colors', 'tab.bg.even'): 'tabs.bg.even',
('colors', 'tab.bg.selected'): 'tabs.bg.selected', ('colors', 'tab.bg.selected'): 'tabs.bg.selected.odd',
('colors', 'tabs.bg.selected'): 'tabs.bg.selected.odd',
('colors', 'tab.bg.bar'): 'tabs.bg.bar', ('colors', 'tab.bg.bar'): 'tabs.bg.bar',
('colors', 'tab.indicator.start'): 'tabs.indicator.start', ('colors', 'tab.indicator.start'): 'tabs.indicator.start',
('colors', 'tab.indicator.stop'): 'tabs.indicator.stop', ('colors', 'tab.indicator.stop'): 'tabs.indicator.stop',

View File

@ -973,13 +973,21 @@ def data(readonly=False):
SettingValue(typ.QtColor(), 'darkgrey'), SettingValue(typ.QtColor(), 'darkgrey'),
"Background color of unselected even tabs."), "Background color of unselected even tabs."),
('tabs.fg.selected', ('tabs.fg.selected.odd',
SettingValue(typ.QtColor(), 'white'), SettingValue(typ.QtColor(), 'white'),
"Foreground color of selected tabs."), "Foreground color of selected odd tabs."),
('tabs.bg.selected', ('tabs.bg.selected.odd',
SettingValue(typ.QtColor(), 'black'), SettingValue(typ.QtColor(), 'black'),
"Background color of selected tabs."), "Background color of selected odd tabs."),
('tabs.fg.selected.even',
SettingValue(typ.QtColor(), '${tabs.fg.selected.odd}'),
"Foreground color of selected even tabs."),
('tabs.bg.selected.even',
SettingValue(typ.QtColor(), '${tabs.bg.selected.odd}'),
"Background color of selected even tabs."),
('tabs.bg.bar', ('tabs.bg.bar',
SettingValue(typ.QtColor(), '#555555'), SettingValue(typ.QtColor(), '#555555'),

View File

@ -409,17 +409,25 @@ class TabBar(QTabBar):
for idx in range(self.count()): for idx in range(self.count()):
tab = QStyleOptionTab() tab = QStyleOptionTab()
self.initStyleOption(tab, idx) self.initStyleOption(tab, idx)
bg_parts = ['tabs', 'bg']
fg_parts = ['tabs', 'fg']
if idx == selected: if idx == selected:
bg_color = config.get('colors', 'tabs.bg.selected') bg_parts.append('selected')
fg_color = config.get('colors', 'tabs.fg.selected') fg_parts.append('selected')
elif idx % 2:
bg_color = config.get('colors', 'tabs.bg.odd') if idx % 2:
fg_color = config.get('colors', 'tabs.fg.odd') bg_parts.append('odd')
fg_parts.append('odd')
else: else:
bg_color = config.get('colors', 'tabs.bg.even') bg_parts.append('even')
fg_color = config.get('colors', 'tabs.fg.even') fg_parts.append('even')
bg_color = config.get('colors', '.'.join(bg_parts))
fg_color = config.get('colors', '.'.join(fg_parts))
tab.palette.setColor(QPalette.Window, bg_color) tab.palette.setColor(QPalette.Window, bg_color)
tab.palette.setColor(QPalette.WindowText, fg_color) tab.palette.setColor(QPalette.WindowText, fg_color)
try: try:
indicator_color = self.tab_data(idx, 'indicator-color') indicator_color = self.tab_data(idx, 'indicator-color')
except KeyError: except KeyError: