From dfedddf0bdb0d803cd8b2d32d74977228c9d58da Mon Sep 17 00:00:00 2001 From: Marius Date: Tue, 20 Jun 2017 23:55:11 +0200 Subject: [PATCH] Wrap scroll button workaround in try/except for older pyqt5 versions (5.2.1) --- qutebrowser/mainwindow/tabwidget.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index 9168a28b6..2096bf8e0 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -747,6 +747,8 @@ class TabBarStyle(QCommonStyle): Return: A QRect. """ + + if sr == QStyle.SE_TabBarTabText: layouts = self._tab_layout(opt) if layouts is None: @@ -759,13 +761,20 @@ class TabBarStyle(QCommonStyle): # style differences... rct = super().subElementRect(sr, opt, widget) return rct - elif sr == QStyle.SE_TabBarScrollLeftButton: - # We need this so the left scroll button is aligned properly. - # Otherwise, empty space will be shown after the last tab even - # though the button width is set to 0 - rct = super().subElementRect(sr, opt, widget) - return rct else: + try: + # We need this so the left scroll button is aligned properly. + # Otherwise, empty space will be shown after the last tab even + # though the button width is set to 0 + + # In older PyQt-versions (5.2.1) QStyle does not have this + # attribute. + if sr == QStyle.SE_TabBarScrollLeftButton: + return super().subElementRect(sr, opt, widget) + + except AttributeError: + pass + return self._style.subElementRect(sr, opt, widget) def _tab_layout(self, opt):