@@ -625,6 +625,11 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
625625 // request notification of FileOpen events (double clicking a file icon in Mac OS X Finder)
626626 QgsApplication::setFileOpenEventReceiver ( this );
627627
628+ #ifndef ANDROID2
629+ // add reacting to long click in android
630+ grabGesture (Qt::TapAndHoldGesture);
631+ #endif
632+
628633 // update windows
629634 qApp->processEvents ();
630635
@@ -734,6 +739,12 @@ bool QgisApp::event( QEvent * event )
734739 openFile ( foe->file () );
735740 done = true ;
736741 }
742+ #ifndef ANDROID2
743+ else if (event->type () == QEvent::Gesture )
744+ {
745+ done = gestureEvent (static_cast <QGestureEvent*>(event));
746+ }
747+ #endif
737748 else
738749 {
739750 // pass other events to base class
@@ -7265,3 +7276,27 @@ QMenu* QgisApp::createPopupMenu()
72657276
72667277 return menu;
72677278}
7279+
7280+ #ifndef ANDROID2
7281+ bool QgisApp::gestureEvent (QGestureEvent *event)
7282+ {
7283+ if (QGesture *tapAndHold = event->gesture (Qt::TapAndHoldGesture))
7284+ {
7285+ tapAndHoldTriggered (static_cast <QTapAndHoldGesture *>(tapAndHold));
7286+ }
7287+ return true ;
7288+ }
7289+
7290+ void QgisApp::tapAndHoldTriggered (QTapAndHoldGesture *gesture)
7291+ {
7292+ if (gesture->state () == Qt::GestureFinished) {
7293+ QPoint pos = gesture->position ().toPoint ();
7294+ qDebug () << " tapAndHoldTriggered: LONG CLICK gesture happened at " << pos;
7295+ QWidget * receiver = QApplication::widgetAt ( this ->mapToGlobal (pos) );
7296+ qDebug () << " widget under point of click: " << receiver;
7297+
7298+ QApplication::postEvent ( receiver, new QMouseEvent ( QEvent::MouseButtonPress, pos, Qt::RightButton, Qt::RightButton, Qt::NoModifier ) );
7299+ QApplication::postEvent ( receiver, new QMouseEvent ( QEvent::MouseButtonRelease, pos, Qt::RightButton, Qt::RightButton, Qt::NoModifier ) );
7300+ }
7301+ }
7302+ #endif
0 commit comments