@@ -625,6 +625,11 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
625
625
// request notification of FileOpen events (double clicking a file icon in Mac OS X Finder)
626
626
QgsApplication::setFileOpenEventReceiver ( this );
627
627
628
+ #ifndef ANDROID2
629
+ // add reacting to long click in android
630
+ grabGesture (Qt::TapAndHoldGesture);
631
+ #endif
632
+
628
633
// update windows
629
634
qApp->processEvents ();
630
635
@@ -734,6 +739,12 @@ bool QgisApp::event( QEvent * event )
734
739
openFile ( foe->file () );
735
740
done = true ;
736
741
}
742
+ #ifndef ANDROID2
743
+ else if (event->type () == QEvent::Gesture )
744
+ {
745
+ done = gestureEvent (static_cast <QGestureEvent*>(event));
746
+ }
747
+ #endif
737
748
else
738
749
{
739
750
// pass other events to base class
@@ -7265,3 +7276,27 @@ QMenu* QgisApp::createPopupMenu()
7265
7276
7266
7277
return menu;
7267
7278
}
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