Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+102
@@ -0,0 +1,102 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Declaration/Definition
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
|
||||
#include "gestures.h"
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtCore/QEvent>
|
||||
|
||||
#include <QtWidgets/QWidget>
|
||||
|
||||
namespace SituationMap { namespace RB {
|
||||
|
||||
// TabGestureRecognizer
|
||||
|
||||
ApplyGestureRecognizer::ApplyGestureRecognizer() : QGestureRecognizer()
|
||||
{
|
||||
}
|
||||
|
||||
ApplyGestureRecognizer::~ApplyGestureRecognizer()
|
||||
{}
|
||||
|
||||
|
||||
QGesture * ApplyGestureRecognizer::create( QObject * target )
|
||||
{
|
||||
qDebug() << "ApplyGesture create";
|
||||
|
||||
if (target && target->isWidgetType())
|
||||
{
|
||||
((QWidget*)target)->setAttribute(Qt::WA_AcceptTouchEvents);
|
||||
}
|
||||
return new ApplyGesture();
|
||||
} // TabGestureRecognizer::create
|
||||
|
||||
|
||||
QGestureRecognizer::Result ApplyGestureRecognizer::recognize( QGesture * state, QObject* , QEvent * event)
|
||||
{
|
||||
ApplyGesture * q = static_cast<ApplyGesture*>(state);
|
||||
const QTouchEvent * ev = static_cast<const QTouchEvent*>(event);
|
||||
|
||||
QGestureRecognizer::Result result = QGestureRecognizer::CancelGesture;
|
||||
|
||||
switch (event->type())
|
||||
{
|
||||
case QEvent::TouchBegin:
|
||||
{
|
||||
qDebug() << "ApplyGesture begin";
|
||||
q->_position = ev->touchPoints().at(0).pos();
|
||||
q->setHotSpot(ev->touchPoints().at(0).screenPos());
|
||||
q->_tripleTouch = (ev->touchPoints().size() == 3);
|
||||
result = QGestureRecognizer::TriggerGesture;
|
||||
} break;
|
||||
|
||||
case QEvent::TouchUpdate:
|
||||
case QEvent::TouchEnd:
|
||||
{
|
||||
if (q->state() != Qt::NoGesture && ev->touchPoints().size() >= 1 && ev->touchPoints().size() <= 3)
|
||||
{
|
||||
if (ev->touchPoints().size() == 3) q->_tripleTouch = true;
|
||||
qDebug() << "ApplyGesture update _tripleTouch=" << q->_tripleTouch;
|
||||
QTouchEvent::TouchPoint p = ev->touchPoints().at(0);
|
||||
QPoint delta = p.pos().toPoint() - p.startPos().toPoint();
|
||||
enum { TapRadius = 40 };
|
||||
if (delta.manhattanLength() <= TapRadius)
|
||||
{
|
||||
if (event->type() == QEvent::TouchEnd)
|
||||
{
|
||||
result = (q->_tripleTouch) ? QGestureRecognizer::FinishGesture : QGestureRecognizer::CancelGesture;
|
||||
}
|
||||
else result = QGestureRecognizer::TriggerGesture;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
|
||||
case QEvent::MouseButtonPress:
|
||||
case QEvent::MouseMove:
|
||||
case QEvent::MouseButtonRelease:
|
||||
result = QGestureRecognizer::Ignore;
|
||||
break;
|
||||
default:
|
||||
result = QGestureRecognizer::Ignore;
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
} // TabGestureRecognizer::recognize( QGesture * state, QObject * watched, QEvent * event)
|
||||
|
||||
|
||||
void ApplyGestureRecognizer::reset( QGesture * state )
|
||||
{
|
||||
ApplyGesture * q = static_cast<ApplyGesture*>(state);
|
||||
q->_tripleTouch = false;
|
||||
} // TabGestureRecognizer::reset( QGesture * gesture )
|
||||
|
||||
|
||||
|
||||
}} // namspaces
|
||||
Reference in new issue
Block a user