Revert "Clean up styles"
This reverts commit f821d9e211
.
This causes all methods to be applied from QCommonStyle, thus resulting in
right-click menus being blank...
This commit is contained in:
parent
6b12572fb0
commit
52d1645479
@ -27,11 +27,16 @@ import functools
|
|||||||
from PyQt5.QtWidgets import QCommonStyle, QStyle
|
from PyQt5.QtWidgets import QCommonStyle, QStyle
|
||||||
|
|
||||||
|
|
||||||
class ProxyStyle(QCommonStyle):
|
class Style(QCommonStyle):
|
||||||
|
|
||||||
"""Helper to create a Qt proxy style as PyQt doesn't support QProxyStyle.
|
"""Qt style to remove Ubuntu focus rectangle uglyness.
|
||||||
|
|
||||||
|
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:
|
||||||
@ -52,20 +57,11 @@ class ProxyStyle(QCommonStyle):
|
|||||||
'hitTestComplexControl', 'itemPixmapRect',
|
'hitTestComplexControl', 'itemPixmapRect',
|
||||||
'itemTextRect', 'pixelMetric', 'polish', 'styleHint',
|
'itemTextRect', 'pixelMetric', 'polish', 'styleHint',
|
||||||
'subControlRect', 'subElementRect', 'unpolish',
|
'subControlRect', 'subElementRect', 'unpolish',
|
||||||
'sizeFromContents', 'drawPrimitive'):
|
'sizeFromContents'):
|
||||||
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 NoFocusRectStyle
|
from qutebrowser.utils.style import Style
|
||||||
|
|
||||||
|
|
||||||
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