From e6c62225cbd598ea8cad640d85b085f950235933 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 10 Feb 2014 16:07:06 +0530 Subject: [PATCH] Handle taps on the viewer --- src/calibre/gui2/viewer/gestures.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/calibre/gui2/viewer/gestures.py b/src/calibre/gui2/viewer/gestures.py index a787df7c1c..053d724b21 100644 --- a/src/calibre/gui2/viewer/gestures.py +++ b/src/calibre/gui2/viewer/gestures.py @@ -165,6 +165,7 @@ class GestureHandler(QObject): QObject.__init__(self, view) self.state = State() self.state.swiped.connect(self.handle_swipe) + self.state.tapped.connect(self.handle_tap) self.evmap = {QEvent.TouchBegin: 'start', QEvent.TouchUpdate: 'update', QEvent.TouchEnd: 'end'} # Ignore fake mouse events generated by the window system from touch @@ -220,3 +221,8 @@ class GestureHandler(QObject): func = {Left:'next_page', Right: 'previous_page', Up:'goto_previous_section', Down:'goto_next_section'}[direction] getattr(view, func)() + def handle_tap(self, tp): + view = self.parent() + threshold = view.width() / 3.0 + attr = 'previous' if tp.start_position.x() <= threshold else 'next' + getattr(view, '%s_page'%attr)()