Skip to content

Commit 99b890b

Browse files
committed
initial right click support
1 parent 371d7fe commit 99b890b

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

src/app/qgisapp.cpp

+35
Original file line numberDiff line numberDiff line change
@@ -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

src/app/qgisapp.h

+10
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ class QgsScaleComboBox;
8383
#include <QPointer>
8484
#include <QSslError>
8585

86+
#ifndef ANDROID2
87+
#include <QGestureEvent>
88+
#include <QTapAndHoldGesture>
89+
#endif
90+
8691
#include "qgsconfig.h"
8792
#include "qgsfeature.h"
8893
#include "qgspoint.h"
@@ -1154,6 +1159,11 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
11541159
bool cmpByText( QAction* a, QAction* b );
11551160

11561161
QString mOldScale;
1162+
1163+
#ifndef ANDROID2
1164+
bool gestureEvent(QGestureEvent *event);
1165+
void tapAndHoldTriggered(QTapAndHoldGesture *gesture);
1166+
#endif
11571167
};
11581168

11591169
#ifdef ANDROID

0 commit comments

Comments
 (0)