Skip to content

Commit a90e3e9

Browse files
committed
Fixed Right click support using TapAndHold gesture
1 parent 99b890b commit a90e3e9

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/app/qgisapp.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ 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
628+
#ifdef ANDROID
629629
//add reacting to long click in android
630630
grabGesture(Qt::TapAndHoldGesture);
631631
#endif
@@ -739,7 +739,7 @@ bool QgisApp::event( QEvent * event )
739739
openFile( foe->file() );
740740
done = true;
741741
}
742-
#ifndef ANDROID2
742+
#ifdef ANDROID
743743
else if (event->type() == QEvent::Gesture )
744744
{
745745
done = gestureEvent(static_cast<QGestureEvent*>(event));
@@ -7277,7 +7277,7 @@ QMenu* QgisApp::createPopupMenu()
72777277
return menu;
72787278
}
72797279

7280-
#ifndef ANDROID2
7280+
#ifdef ANDROID
72817281
bool QgisApp::gestureEvent(QGestureEvent *event)
72827282
{
72837283
if (QGesture *tapAndHold = event->gesture(Qt::TapAndHoldGesture))
@@ -7291,12 +7291,12 @@ void QgisApp::tapAndHoldTriggered(QTapAndHoldGesture *gesture)
72917291
{
72927292
if (gesture->state() == Qt::GestureFinished) {
72937293
QPoint pos = gesture->position().toPoint();
7294+
QWidget * receiver = QApplication::widgetAt( pos );
72947295
qDebug() << "tapAndHoldTriggered: LONG CLICK gesture happened at " << pos;
7295-
QWidget * receiver = QApplication::widgetAt( this->mapToGlobal(pos) );
72967296
qDebug() << "widget under point of click: " << receiver;
72977297

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 ) );
7298+
QApplication::postEvent( receiver, new QMouseEvent( QEvent::MouseButtonPress, receiver->mapFromGlobal( pos ), Qt::RightButton, Qt::RightButton, Qt::NoModifier ) );
7299+
QApplication::postEvent( receiver, new QMouseEvent( QEvent::MouseButtonRelease, receiver->mapFromGlobal( pos ), Qt::RightButton, Qt::RightButton, Qt::NoModifier ) );
73007300
}
73017301
}
73027302
#endif

src/app/qgisapp.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class QgsScaleComboBox;
8383
#include <QPointer>
8484
#include <QSslError>
8585

86-
#ifndef ANDROID2
86+
#ifdef ANDROID
8787
#include <QGestureEvent>
8888
#include <QTapAndHoldGesture>
8989
#endif
@@ -1160,7 +1160,7 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
11601160

11611161
QString mOldScale;
11621162

1163-
#ifndef ANDROID2
1163+
#ifdef ANDROID
11641164
bool gestureEvent(QGestureEvent *event);
11651165
void tapAndHoldTriggered(QTapAndHoldGesture *gesture);
11661166
#endif

0 commit comments

Comments
 (0)