Use fake-key scrolling for :scroll-perc 0/100.

This commit is contained in:
Florian Bruhin 2015-05-16 15:51:41 +02:00
parent 4dbc4ba93f
commit 9b372de4a9

View File

@ -165,12 +165,17 @@ class CommandDispatcher:
perc = 100
elif perc is None:
perc = count
perc = qtutils.check_overflow(perc, 'int', fatal=False)
frame = self._current_widget().page().currentFrame()
m = frame.scrollBarMaximum(orientation)
if m == 0:
return
frame.setScrollBarValue(orientation, int(m * perc / 100))
if perc == 0:
self.scroll('top')
elif perc == 100:
self.scroll('bottom')
else:
perc = qtutils.check_overflow(perc, 'int', fatal=False)
frame = self._current_widget().page().currentFrame()
m = frame.scrollBarMaximum(orientation)
if m == 0:
return
frame.setScrollBarValue(orientation, int(m * perc / 100))
def _tab_move_absolute(self, idx):
"""Get an index for moving a tab absolutely.
@ -616,6 +621,10 @@ class CommandDispatcher:
press_evt = QKeyEvent(QEvent.KeyPress, key, Qt.NoModifier, 0, 0, 0)
release_evt = QKeyEvent(QEvent.KeyRelease, key, Qt.NoModifier, 0, 0, 0)
# Count doesn't make sense with top/bottom
if direction in ('top', 'bottom'):
count = 1
for _ in range(count):
widget.keyPressEvent(press_evt)
widget.keyReleaseEvent(release_evt)