diff options
author | Marius <froase@gmail.com> | 2017-06-20 23:55:11 +0200 |
---|---|---|
committer | Marius <froase@gmail.com> | 2017-06-20 23:55:11 +0200 |
commit | dfedddf0bdb0d803cd8b2d32d74977228c9d58da (patch) | |
tree | 803510fafa4d0107ced6050915bfe8d0285b8001 | |
parent | 6e166d139a81b53cbb50a8370d59f7269c3a10cb (diff) | |
download | qutebrowser-dfedddf0bdb0d803cd8b2d32d74977228c9d58da.tar.gz qutebrowser-dfedddf0bdb0d803cd8b2d32d74977228c9d58da.zip |
Wrap scroll button workaround in try/except
for older pyqt5 versions (5.2.1)
-rw-r--r-- | qutebrowser/mainwindow/tabwidget.py | 21 |
1 files 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): |