Clean up styles
This commit is contained in:
parent
4235034604
commit
f821d9e211
@ -27,16 +27,11 @@ import functools
|
|||||||
from PyQt5.QtWidgets import QCommonStyle, QStyle
|
from PyQt5.QtWidgets import QCommonStyle, QStyle
|
||||||
|
|
||||||
|
|
||||||
class Style(QCommonStyle):
|
class ProxyStyle(QCommonStyle):
|
||||||
|
|
||||||
"""Qt style to remove Ubuntu focus rectangle uglyness.
|
"""Helper to create a Qt proxy style as PyQt doesn't support QProxyStyle.
|
||||||
|
|
||||||
Unfortunately PyQt doesn't support QProxyStyle, so we need to do this the
|
|
||||||
hard way...
|
|
||||||
|
|
||||||
Based on:
|
Based on:
|
||||||
|
|
||||||
http://stackoverflow.com/a/17294081
|
|
||||||
https://code.google.com/p/makehuman/source/browse/trunk/makehuman/lib/qtgui.py
|
https://code.google.com/p/makehuman/source/browse/trunk/makehuman/lib/qtgui.py
|
||||||
|
|
||||||
Attributes:
|
Attributes:
|
||||||
@ -57,11 +52,20 @@ class Style(QCommonStyle):
|
|||||||
'hitTestComplexControl', 'itemPixmapRect',
|
'hitTestComplexControl', 'itemPixmapRect',
|
||||||
'itemTextRect', 'pixelMetric', 'polish', 'styleHint',
|
'itemTextRect', 'pixelMetric', 'polish', 'styleHint',
|
||||||
'subControlRect', 'subElementRect', 'unpolish',
|
'subControlRect', 'subElementRect', 'unpolish',
|
||||||
'sizeFromContents'):
|
'sizeFromContents', 'drawPrimitive'):
|
||||||
|
if not getattr(self, method):
|
||||||
target = getattr(self._style, method)
|
target = getattr(self._style, method)
|
||||||
setattr(self, method, functools.partial(target))
|
setattr(self, method, functools.partial(target))
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
|
|
||||||
|
class NoFocusRectStyle(ProxyStyle):
|
||||||
|
|
||||||
|
"""Qt style to remove Ubuntu focus rectangle uglyness.
|
||||||
|
|
||||||
|
Based on http://stackoverflow.com/a/17294081
|
||||||
|
"""
|
||||||
|
|
||||||
def drawPrimitive(self, element, option, painter, widget=None):
|
def drawPrimitive(self, element, option, painter, widget=None):
|
||||||
"""Override QCommonStyle.drawPrimitive.
|
"""Override QCommonStyle.drawPrimitive.
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ from PyQt5.QtGui import QIcon, QPixmap
|
|||||||
|
|
||||||
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
|
||||||
from qutebrowser.utils.style import Style
|
from qutebrowser.utils.style import NoFocusRectStyle
|
||||||
|
|
||||||
|
|
||||||
class EmptyTabIcon(QIcon):
|
class EmptyTabIcon(QIcon):
|
||||||
@ -80,9 +80,9 @@ class TabWidget(QTabWidget):
|
|||||||
|
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
|
self.setStyle(NoFocusRectStyle(self.style()))
|
||||||
self.setTabBar(TabBar())
|
self.setTabBar(TabBar())
|
||||||
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
|
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
|
||||||
self.setStyle(Style(self.style()))
|
|
||||||
set_register_stylesheet(self)
|
set_register_stylesheet(self)
|
||||||
self.setDocumentMode(True)
|
self.setDocumentMode(True)
|
||||||
self.setElideMode(Qt.ElideRight)
|
self.setElideMode(Qt.ElideRight)
|
||||||
|
Loading…
Reference in New Issue
Block a user