From 3c016de6876de1d10f88092590e932624f2c93fb Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 28 Jan 2014 16:13:26 +0100 Subject: [PATCH] Scroll on space press --- TODO | 1 - qutebrowser/utils/config.py | 1 + qutebrowser/widgets/browser.py | 13 +++++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/TODO b/TODO index fa65916e8..532434eed 100644 --- a/TODO +++ b/TODO @@ -29,7 +29,6 @@ Minor features/bugs =================== Hiding scrollbars -Space to scroll copypaste All kind of FIXMEs :bind diff --git a/qutebrowser/utils/config.py b/qutebrowser/utils/config.py index 4a3209038..094e21a67 100644 --- a/qutebrowser/utils/config.py +++ b/qutebrowser/utils/config.py @@ -10,6 +10,7 @@ colordict = {} default_config = { 'general': { 'show_completion': 'true', + 'space_scroll': '200', }, 'keybind': { 'o': 'open', diff --git a/qutebrowser/widgets/browser.py b/qutebrowser/widgets/browser.py index d1d6e49f8..e607e2f76 100644 --- a/qutebrowser/widgets/browser.py +++ b/qutebrowser/widgets/browser.py @@ -1,10 +1,12 @@ import logging +from PyQt5.QtWidgets import QShortcut from PyQt5.QtCore import QUrl, pyqtSignal, Qt, QPoint, QEvent from PyQt5.QtPrintSupport import QPrintPreviewDialog from PyQt5.QtWebKitWidgets import QWebView, QWebPage import qutebrowser.utils as utils +import qutebrowser.utils.config as config from qutebrowser.widgets.tabbar import TabWidget class TabbedBrowser(TabWidget): @@ -24,6 +26,10 @@ class TabbedBrowser(TabWidget): super().__init__(parent) self.currentChanged.connect(self._currentChanged_handler) self.tabopen(QUrl("http://ddg.gg/")) + space = QShortcut(self) + space.setKey(Qt.Key_Space) + space.setContext(Qt.WidgetWithChildrenShortcut) + space.activated.connect(self.space_scroll) def tabopen(self, url): """Opens a new tab with a given url""" @@ -130,6 +136,13 @@ class TabbedBrowser(TabWidget): return frame.setScrollBarValue(orientation, int(m * perc / 100)) + def space_scroll(self): + try: + amount = config.config['general']['space_scroll'] + except KeyError: + amount = 200 + self.cur_scroll(0, amount) + def switch_prev(self): """Switches to the previous tab""" idx = self.currentIndex()