mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Handle taps on the viewer
This commit is contained in:
parent
72ae72418c
commit
e6c62225cb
@ -165,6 +165,7 @@ class GestureHandler(QObject):
|
|||||||
QObject.__init__(self, view)
|
QObject.__init__(self, view)
|
||||||
self.state = State()
|
self.state = State()
|
||||||
self.state.swiped.connect(self.handle_swipe)
|
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'}
|
self.evmap = {QEvent.TouchBegin: 'start', QEvent.TouchUpdate: 'update', QEvent.TouchEnd: 'end'}
|
||||||
|
|
||||||
# Ignore fake mouse events generated by the window system from touch
|
# 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]
|
func = {Left:'next_page', Right: 'previous_page', Up:'goto_previous_section', Down:'goto_next_section'}[direction]
|
||||||
getattr(view, func)()
|
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)()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user