diff --git a/src/calibre/gui2/viewer/documentview.py b/src/calibre/gui2/viewer/documentview.py index 4b7c804ac9..0691a9deb8 100644 --- a/src/calibre/gui2/viewer/documentview.py +++ b/src/calibre/gui2/viewer/documentview.py @@ -640,6 +640,7 @@ class DocumentView(QWebView): # {{{ self.document.font_magnification_step) def contextMenuEvent(self, ev): + from_touch = ev.reason() == ev.Other mf = self.document.mainFrame() r = mf.hitTestContent(ev.pos()) img = r.pixmap() @@ -705,13 +706,16 @@ class DocumentView(QWebView): # {{{ for plugin in self.document.all_viewer_plugins: plugin.customize_context_menu(menu, ev, r) - if ev.reason() == ev.Other: - # Triggered by a touch event + + if from_touch: from calibre.constants import plugins pi = plugins['progress_indicator'][0] for x in (menu, self.goto_location_menu): if hasattr(pi, 'set_touch_menu_style'): pi.set_touch_menu_style(x) + helpt = QAction(QIcon(I('help.png')), _('Show supported touch screen gestures'), menu) + helpt.triggered.connect(self.gesture_handler.show_help) + menu.insertAction(menu.actions()[0], helpt) else: self.goto_location_menu.setStyle(self.style()) self.context_menu = menu diff --git a/src/calibre/gui2/viewer/gestures.py b/src/calibre/gui2/viewer/gestures.py index d5e58b0869..751f4383ed 100644 --- a/src/calibre/gui2/viewer/gestures.py +++ b/src/calibre/gui2/viewer/gestures.py @@ -10,7 +10,7 @@ import time, ctypes, sys from functools import partial from PyQt4.Qt import ( QObject, QPointF, pyqtSignal, QEvent, QApplication, QMouseEvent, Qt, - QContextMenuEvent) + QContextMenuEvent, QDialog, QDialogButtonBox, QLabel, QVBoxLayout) from calibre.constants import iswindows @@ -36,6 +36,56 @@ Tap, TapAndHold, Pinch, Swipe, SwipeAndHold = 'Tap', 'TapAndHold', 'Pinch', 'Swi Left, Right, Up, Down = 'Left', 'Right', 'Up', 'Down' In, Out = 'In', 'Out' +class Help(QDialog): # {{{ + + def __init__(self, parent=None): + QDialog.__init__(self, parent=parent) + self.l = l = QVBoxLayout(self) + self.setLayout(l) + + self.la = la = QLabel( + ''' + + + ''' + _( + ''' +

The list of available gestures

+
+
Single tap
+
A single tap on the right two thirds of the page will turn to the next page + and on the left one-third of the page will turn to the previous page. Single tapping + on a link will activate the link.
+ +
Swipe
+
Swipe to the left to go to the next page and to the right to go to the previous page. + This mimics turning pages in a paper book.
+ +
Pinch
+
Pinch in or out to decrease or increase the font size
+ +
Swipe and hold
+
If you swipe and the hold your finger down instead of lifting it, pages will be turned + rapidly allowing for quickly scanning through large numbers of pages.
+ +
Tap and hold
+
Bring up the context (right-click) menu
+
+ ''' + )) + la.setAlignment(Qt.AlignTop | Qt.AlignLeft) + la.setWordWrap(True) + l.addWidget(la, Qt.AlignTop|Qt.AlignLeft) + self.bb = bb = QDialogButtonBox(QDialogButtonBox.Close) + bb.accepted.connect(self.accept) + bb.rejected.connect(self.reject) + l.addWidget(bb) + self.resize(600, 500) +# }}} + class TouchPoint(object): def __init__(self, tp): @@ -316,3 +366,9 @@ class GestureHandler(QObject): attr = 'magnify' if direction is Out else 'shrink' getattr(self.parent(), '%s_fonts' % attr)() + def show_help(self): + Help(self.parent()).exec_() + +if __name__ == '__main__': + app = QApplication([]) + Help().exec_()