Skip to content

Commit

Permalink
Fixed Right click support using TapAndHold gesture
Browse files Browse the repository at this point in the history
  • Loading branch information
mbernasocchi committed Feb 22, 2012
1 parent 99b890b commit a90e3e9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions src/app/qgisapp.cpp
Expand Up @@ -625,7 +625,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
// request notification of FileOpen events (double clicking a file icon in Mac OS X Finder)
QgsApplication::setFileOpenEventReceiver( this );

#ifndef ANDROID2
#ifdef ANDROID
//add reacting to long click in android
grabGesture(Qt::TapAndHoldGesture);
#endif
Expand Down Expand Up @@ -739,7 +739,7 @@ bool QgisApp::event( QEvent * event )
openFile( foe->file() );
done = true;
}
#ifndef ANDROID2
#ifdef ANDROID
else if (event->type() == QEvent::Gesture )
{
done = gestureEvent(static_cast<QGestureEvent*>(event));
Expand Down Expand Up @@ -7277,7 +7277,7 @@ QMenu* QgisApp::createPopupMenu()
return menu;
}

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

QApplication::postEvent( receiver, new QMouseEvent( QEvent::MouseButtonPress, pos, Qt::RightButton, Qt::RightButton, Qt::NoModifier ) );
QApplication::postEvent( receiver, new QMouseEvent( QEvent::MouseButtonRelease, pos, Qt::RightButton, Qt::RightButton, Qt::NoModifier ) );
QApplication::postEvent( receiver, new QMouseEvent( QEvent::MouseButtonPress, receiver->mapFromGlobal( pos ), Qt::RightButton, Qt::RightButton, Qt::NoModifier ) );
QApplication::postEvent( receiver, new QMouseEvent( QEvent::MouseButtonRelease, receiver->mapFromGlobal( pos ), Qt::RightButton, Qt::RightButton, Qt::NoModifier ) );
}
}
#endif
4 changes: 2 additions & 2 deletions src/app/qgisapp.h
Expand Up @@ -83,7 +83,7 @@ class QgsScaleComboBox;
#include <QPointer>
#include <QSslError>

#ifndef ANDROID2
#ifdef ANDROID
#include <QGestureEvent>
#include <QTapAndHoldGesture>
#endif
Expand Down Expand Up @@ -1160,7 +1160,7 @@ class QgisApp : public QMainWindow, private Ui::MainWindow

QString mOldScale;

#ifndef ANDROID2
#ifdef ANDROID
bool gestureEvent(QGestureEvent *event);
void tapAndHoldTriggered(QTapAndHoldGesture *gesture);
#endif
Expand Down

0 comments on commit a90e3e9

Please sign in to comment.