Implement scroll.pos_perc for QtWebEngine
This commit is contained in:
parent
a1f4dcd542
commit
9c5143786c
@ -54,9 +54,21 @@ class WebEngineCaret(tab.AbstractCaret):
|
|||||||
|
|
||||||
class WebEngineScroller(tab.AbstractScroller):
|
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):
|
class WebEngineHistory(tab.AbstractHistory):
|
||||||
|
@ -46,6 +46,8 @@ class Percentage(textbase.TextBase):
|
|||||||
self.setText('[top]')
|
self.setText('[top]')
|
||||||
elif y == 100:
|
elif y == 100:
|
||||||
self.setText('[bot]')
|
self.setText('[bot]')
|
||||||
|
elif y is None:
|
||||||
|
self.setText('[???]')
|
||||||
else:
|
else:
|
||||||
self.setText('[{:2}%]'.format(y))
|
self.setText('[{:2}%]'.format(y))
|
||||||
|
|
||||||
|
@ -128,7 +128,9 @@ class TabWidget(QTabWidget):
|
|||||||
fields['host'] = ''
|
fields['host'] = ''
|
||||||
|
|
||||||
y = widget.scroll.pos_perc()[1]
|
y = widget.scroll.pos_perc()[1]
|
||||||
if y <= 0:
|
if y is None:
|
||||||
|
scroll_pos = '???'
|
||||||
|
elif y <= 0:
|
||||||
scroll_pos = 'top'
|
scroll_pos = 'top'
|
||||||
elif y >= 100:
|
elif y >= 100:
|
||||||
scroll_pos = 'bot'
|
scroll_pos = 'bot'
|
||||||
|
Loading…
Reference in New Issue
Block a user