Skip to content
Permalink
Browse files
Merge pull request #96 from mbernasocchi/android
Android right click using TapAndHoldGesture
  • Loading branch information
timlinux committed Feb 25, 2012
2 parents c42f094 + a90e3e9 commit 4e7603fb625b57c2df440ac8ff8b38607dbbc810
Showing with 45 additions and 0 deletions.
  1. +35 −0 src/app/qgisapp.cpp
  2. +10 −0 src/app/qgisapp.h
@@ -625,6 +625,11 @@ 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 );

#ifdef ANDROID
//add reacting to long click in android
grabGesture(Qt::TapAndHoldGesture);
#endif

// update windows
qApp->processEvents();

@@ -734,6 +739,12 @@ bool QgisApp::event( QEvent * event )
openFile( foe->file() );
done = true;
}
#ifdef ANDROID
else if (event->type() == QEvent::Gesture )
{
done = gestureEvent(static_cast<QGestureEvent*>(event));
}
#endif
else
{
// pass other events to base class
@@ -7265,3 +7276,27 @@ QMenu* QgisApp::createPopupMenu()

return menu;
}

#ifdef ANDROID
bool QgisApp::gestureEvent(QGestureEvent *event)
{
if (QGesture *tapAndHold = event->gesture(Qt::TapAndHoldGesture))
{
tapAndHoldTriggered(static_cast<QTapAndHoldGesture *>(tapAndHold));
}
return true;
}

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;
qDebug() << "widget under point of click: " << receiver;

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
@@ -83,6 +83,11 @@ class QgsScaleComboBox;
#include <QPointer>
#include <QSslError>

#ifdef ANDROID
#include <QGestureEvent>
#include <QTapAndHoldGesture>
#endif

#include "qgsconfig.h"
#include "qgsfeature.h"
#include "qgspoint.h"
@@ -1154,6 +1159,11 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
bool cmpByText( QAction* a, QAction* b );

QString mOldScale;

#ifdef ANDROID
bool gestureEvent(QGestureEvent *event);
void tapAndHoldTriggered(QTapAndHoldGesture *gesture);
#endif
};

#ifdef ANDROID

0 comments on commit 4e7603f

Please sign in to comment.