Implement page-wise scrolling.

This commit is contained in:
Florian Bruhin 2014-02-13 10:28:09 +01:00
parent 4c5364ded0
commit 029813c8eb
5 changed files with 30 additions and 27 deletions

12
TODO
View File

@ -60,18 +60,6 @@ https://code.google.com/p/devicenzo/source/browse/trunk/devicenzo.py
Keybinding stuff (from dwb)
===========================
[n]C-f
Scroll [n] pages down (command: scroll_page_down, aliases: pagedown).
[n]C-b
Scroll [n] pages up (command: scroll_page_up, aliases: pageup).
[n]C-d
Scroll [n] half pages down (command: scroll_halfpage_down, aliases: halfdown).
[n]C-u
Scroll [n] half pages up (command: scroll_halfpage_up, aliases: halfup).
xo
Open url in a new tab in background, the argument $URI will be repaced with the current uri (command: backopen, aliases: bopen ).

View File

@ -271,6 +271,7 @@ class QuteBrowser(QApplication):
'forward': self.mainwindow.tabs.cur_forward,
'print': self.mainwindow.tabs.cur_print,
'scroll': self.mainwindow.tabs.cur_scroll,
'scroll_page': self.mainwindow.tabs.cur_scroll_page,
'scroll_perc_x': self.mainwindow.tabs.cur_scroll_percent_x,
'scroll_perc_y': self.mainwindow.tabs.cur_scroll_percent_y,
'undo': self.mainwindow.tabs.undo_close,

View File

@ -162,6 +162,22 @@ class Scroll(Command):
hide = True
class ScrollPage(Command):
"""Scroll N pages up/down.
arg 1: pages in x-direction
arg 2: pages in y-direction
count: multiplicator
"""
nargs = 2
count = True
hide = True
name = 'scroll_page'
class Undo(Command):
"""Undo closing a tab."""

View File

@ -37,7 +37,6 @@ fontdict = {}
default_config = """
[general]
show_completion = true
space_scroll = 200
ignorecase = true
wrapsearch = true
startpage = http://www.duckduckgo.com/
@ -93,6 +92,10 @@ PP = tabpaste sel
@Ctrl-Shift-T@ = undo
@Ctrl-W@ = tabclose
@Ctrl-T@ = tabopen about:blank
@Ctrl-F@ = scroll_page 0 1
@Ctrl-B@ = scroll_page 0 -1
@Ctrl-D@ = scroll_page 0 0.5
@Ctrl-U@ = scroll_page 0 -0.5
[colors]
completion.fg = #333333

View File

@ -32,7 +32,6 @@ from PyQt5.QtPrintSupport import QPrintPreviewDialog
from PyQt5.QtWebKitWidgets import QWebView, QWebPage
import qutebrowser.utils.about as about
import qutebrowser.utils.config as config
import qutebrowser.utils.url as urlutils
from qutebrowser.widgets.tabbar import TabWidget
from qutebrowser.utils.signals import dbg_signal, SignalCache
@ -73,7 +72,7 @@ class TabbedBrowser(TabWidget):
space = QShortcut(self)
space.setKey(Qt.Key_Space)
space.setContext(Qt.WidgetWithChildrenShortcut)
space.activated.connect(self.space_scroll)
space.activated.connect(lambda: self.cur_scroll_page(0, 1))
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
def tabopen(self, url):
@ -258,6 +257,14 @@ class TabbedBrowser(TabWidget):
return
frame.setScrollBarValue(orientation, int(m * perc / 100))
def cur_scroll_page(self, mx, my, count=1):
"""Scroll the frame mx pages to the right and my pages down."""
# FIXME this might not work with HTML frames
page = self.currentWidget().page()
size = page.viewportSize()
page.mainFrame().scroll(int(count) * float(mx) * size.width(),
int(count) * float(my) * size.height())
def switch_prev(self, count=1):
"""Switch to the ([count]th) previous tab.
@ -284,18 +291,6 @@ class TabbedBrowser(TabWidget):
# FIXME
pass
def space_scroll(self):
"""Scroll when space is pressed.
This gets called from the space QShortcut in __init__.
"""
try:
amount = config.config['general']['space_scroll']
except KeyError:
amount = 200
self.cur_scroll(0, amount)
def cur_yank(self, sel=False):
"""Yank the current url to the clipboard or primary selection.