From 52d1645479ef151138a6c21c9d27f528b5186765 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 19 Jun 2014 21:05:41 +0200 Subject: [PATCH] Revert "Clean up styles" This reverts commit f821d9e211b9bd6dfb1b5b62bfe7a1da1c720a4a. This causes all methods to be applied from QCommonStyle, thus resulting in right-click menus being blank... --- qutebrowser/utils/style.py | 24 ++++++++++-------------- qutebrowser/widgets/tabwidget.py | 4 ++-- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/qutebrowser/utils/style.py b/qutebrowser/utils/style.py index 10bdd2f45..92d5006a9 100644 --- a/qutebrowser/utils/style.py +++ b/qutebrowser/utils/style.py @@ -27,11 +27,16 @@ import functools 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: + + http://stackoverflow.com/a/17294081 https://code.google.com/p/makehuman/source/browse/trunk/makehuman/lib/qtgui.py Attributes: @@ -52,20 +57,11 @@ class ProxyStyle(QCommonStyle): 'hitTestComplexControl', 'itemPixmapRect', 'itemTextRect', 'pixelMetric', 'polish', 'styleHint', 'subControlRect', 'subElementRect', 'unpolish', - 'sizeFromContents', 'drawPrimitive'): - if not getattr(self, method): - target = getattr(self._style, method) - setattr(self, method, functools.partial(target)) + 'sizeFromContents'): + target = getattr(self._style, method) + setattr(self, method, functools.partial(target)) 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): """Override QCommonStyle.drawPrimitive. diff --git a/qutebrowser/widgets/tabwidget.py b/qutebrowser/widgets/tabwidget.py index b51d32141..3c9c116ea 100644 --- a/qutebrowser/widgets/tabwidget.py +++ b/qutebrowser/widgets/tabwidget.py @@ -25,7 +25,7 @@ from PyQt5.QtGui import QIcon, QPixmap import qutebrowser.config.config as config from qutebrowser.config.style import set_register_stylesheet -from qutebrowser.utils.style import NoFocusRectStyle +from qutebrowser.utils.style import Style class EmptyTabIcon(QIcon): @@ -80,9 +80,9 @@ class TabWidget(QTabWidget): def __init__(self, parent): super().__init__(parent) - self.setStyle(NoFocusRectStyle(self.style())) self.setTabBar(TabBar()) self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) + self.setStyle(Style(self.style())) set_register_stylesheet(self) self.setDocumentMode(True) self.setElideMode(Qt.ElideRight)