Try changing tabbar color
This commit is contained in:
parent
b4aba0d0ee
commit
9b21f37659
@ -24,7 +24,7 @@ import functools
|
|||||||
from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt, QSize
|
from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt, QSize
|
||||||
from PyQt5.QtWidgets import (QTabWidget, QTabBar, QSizePolicy, QCommonStyle,
|
from PyQt5.QtWidgets import (QTabWidget, QTabBar, QSizePolicy, QCommonStyle,
|
||||||
QStyle)
|
QStyle)
|
||||||
from PyQt5.QtGui import QIcon, QPixmap, QPalette
|
from PyQt5.QtGui import QIcon, QPixmap, QPalette, QColor
|
||||||
|
|
||||||
import qutebrowser.config.config as config
|
import qutebrowser.config.config as config
|
||||||
from qutebrowser.config.style import set_register_stylesheet
|
from qutebrowser.config.style import set_register_stylesheet
|
||||||
@ -186,6 +186,13 @@ class TabBar(QTabBar):
|
|||||||
qt_ensure_valid(size)
|
qt_ensure_valid(size)
|
||||||
return size
|
return size
|
||||||
|
|
||||||
|
def initStyleOption(self, option, tabIndex):
|
||||||
|
"""Override initStyleOption so we can mark odd tabs."""
|
||||||
|
super().initStyleOption(option, tabIndex)
|
||||||
|
if tabIndex % 2:
|
||||||
|
option |= 0x10000000
|
||||||
|
return option
|
||||||
|
|
||||||
|
|
||||||
class TabWidgetStyle(QCommonStyle):
|
class TabWidgetStyle(QCommonStyle):
|
||||||
|
|
||||||
@ -217,7 +224,7 @@ class TabWidgetStyle(QCommonStyle):
|
|||||||
style: The base/"parent" style.
|
style: The base/"parent" style.
|
||||||
"""
|
"""
|
||||||
self._style = style
|
self._style = style
|
||||||
for method in ('drawComplexControl', 'drawControl', 'drawItemPixmap',
|
for method in ('drawComplexControl', 'drawItemPixmap',
|
||||||
'generatedIconPixmap', 'hitTestComplexControl',
|
'generatedIconPixmap', 'hitTestComplexControl',
|
||||||
'itemPixmapRect', 'itemTextRect', 'pixelMetric',
|
'itemPixmapRect', 'itemTextRect', 'pixelMetric',
|
||||||
'polish', 'styleHint', 'subControlRect',
|
'polish', 'styleHint', 'subControlRect',
|
||||||
@ -275,3 +282,12 @@ class TabWidgetStyle(QCommonStyle):
|
|||||||
alignment |= Qt.AlignLeft
|
alignment |= Qt.AlignLeft
|
||||||
super().drawItemText(painter, rectangle, alignment, palette, enabled,
|
super().drawItemText(painter, rectangle, alignment, palette, enabled,
|
||||||
text, textRole)
|
text, textRole)
|
||||||
|
|
||||||
|
def drawControl(self, element, opt, p, widget=None):
|
||||||
|
"""Override drawControl to draw odd tabs in a different color."""
|
||||||
|
if element != QStyle.CE_TabBarTab:
|
||||||
|
super().drawControl(element, opt, p, widget)
|
||||||
|
return
|
||||||
|
raise Exception
|
||||||
|
opt.palette.setColor(QPalette.Base, QColor('red'))
|
||||||
|
self._style.drawControl(element, opt, p, widget)
|
||||||
|
Loading…
Reference in New Issue
Block a user