diff --git a/qutebrowser/browser/webengine/webenginetab.py b/qutebrowser/browser/webengine/webenginetab.py index 2d898112c..8d52961f6 100644 --- a/qutebrowser/browser/webengine/webenginetab.py +++ b/qutebrowser/browser/webengine/webenginetab.py @@ -54,9 +54,21 @@ class WebEngineCaret(tab.AbstractCaret): class WebEngineScroller(tab.AbstractScroller): - ## TODO + def pos_perc(self): + page = self._widget.page() + try: + size = page.contentsSize() + pos = page.scrollPosition() + except AttributeError: + # Added in Qt 5.7 + return (None, None) + else: + # FIXME is this correct? + perc_x = 100 / size.width() * pos.x() + perc_y = 100 / size.height() * pos.y() + return (perc_x, perc_y) - pass + ## TODO class WebEngineHistory(tab.AbstractHistory): diff --git a/qutebrowser/mainwindow/statusbar/percentage.py b/qutebrowser/mainwindow/statusbar/percentage.py index 3a15b8308..6cc64cd71 100644 --- a/qutebrowser/mainwindow/statusbar/percentage.py +++ b/qutebrowser/mainwindow/statusbar/percentage.py @@ -46,6 +46,8 @@ class Percentage(textbase.TextBase): self.setText('[top]') elif y == 100: self.setText('[bot]') + elif y is None: + self.setText('[???]') else: self.setText('[{:2}%]'.format(y)) diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index 99e2051e5..34727ca64 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -128,7 +128,9 @@ class TabWidget(QTabWidget): fields['host'] = '' y = widget.scroll.pos_perc()[1] - if y <= 0: + if y is None: + scroll_pos = '???' + elif y <= 0: scroll_pos = 'top' elif y >= 100: scroll_pos = 'bot'