diff options
author | Morten Engvoldsen <morten.engvoldsen@nokia.com> | 2010-07-08 11:19:36 (GMT) |
---|---|---|
committer | Morten Engvoldsen <morten.engvoldsen@nokia.com> | 2010-07-08 11:19:36 (GMT) |
commit | 05f22cf7aa28c1a7866e4e3207974aae4f1d644d (patch) | |
tree | 8a252042e2437d95785f801ede2f06b58b65ebc0 | |
parent | dc1443ac784201bd9c016519d01481aeeb3d8f53 (diff) | |
parent | 8b212b5f36ef7479bb902c6f8c8c1f4335f7f39f (diff) | |
download | Qt-05f22cf7aa28c1a7866e4e3207974aae4f1d644d.zip Qt-05f22cf7aa28c1a7866e4e3207974aae4f1d644d.tar.gz Qt-05f22cf7aa28c1a7866e4e3207974aae4f1d644d.tar.bz2 |
Merge branch '4.7' of git@scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7
-rw-r--r-- | src/gui/kernel/qgesture.cpp | 29 | ||||
-rw-r--r-- | src/gui/kernel/qgesture.h | 3 | ||||
-rw-r--r-- | src/gui/kernel/qgesture_p.h | 1 | ||||
-rw-r--r-- | src/gui/kernel/qgesturemanager.cpp | 4 | ||||
-rw-r--r-- | src/gui/kernel/qstandardgestures.cpp | 7 |
5 files changed, 38 insertions, 6 deletions
diff --git a/src/gui/kernel/qgesture.cpp b/src/gui/kernel/qgesture.cpp index f5688f4..6359ecf 100644 --- a/src/gui/kernel/qgesture.cpp +++ b/src/gui/kernel/qgesture.cpp @@ -41,6 +41,7 @@ #include "qgesture.h" #include "private/qgesture_p.h" +#include "private/qstandardgestures_p.h" #ifndef QT_NO_GESTURES @@ -726,6 +727,34 @@ void QTapAndHoldGesture::setPosition(const QPointF &value) d_func()->position = value; } +/*! + Set the timeout, in milliseconds, before the gesture triggers. + + The recognizer will detect a touch down and and if \a msecs + later the touch is still down, it will trigger the QTapAndHoldGesture. + The default value is 700 milliseconds. +*/ +// static +void QTapAndHoldGesture::setTimeout(int msecs) +{ + QTapAndHoldGesturePrivate::Timeout = msecs; +} + +/*! + Gets the timeout, in milliseconds, before the gesture triggers. + + The recognizer will detect a touch down and and if timeout() + later the touch is still down, it will trigger the QTapAndHoldGesture. + The default value is 700 milliseconds. +*/ +// static +int QTapAndHoldGesture::timeout() +{ + return QTapAndHoldGesturePrivate::Timeout; +} + +int QTapAndHoldGesturePrivate::Timeout = 700; // in ms + QT_END_NAMESPACE #endif // QT_NO_GESTURES diff --git a/src/gui/kernel/qgesture.h b/src/gui/kernel/qgesture.h index 8c10895..8f410b1 100644 --- a/src/gui/kernel/qgesture.h +++ b/src/gui/kernel/qgesture.h @@ -252,6 +252,9 @@ public: QPointF position() const; void setPosition(const QPointF &pos); + static void setTimeout(int msecs); + static int timeout(); + friend class QTapAndHoldGestureRecognizer; }; diff --git a/src/gui/kernel/qgesture_p.h b/src/gui/kernel/qgesture_p.h index f5474c1..29b923e 100644 --- a/src/gui/kernel/qgesture_p.h +++ b/src/gui/kernel/qgesture_p.h @@ -177,6 +177,7 @@ public: QPointF position; int timerId; + static int Timeout; }; QT_END_NAMESPACE diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index e43a560..fe9dd8a 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -71,7 +71,7 @@ QT_BEGIN_NAMESPACE QGestureManager::QGestureManager(QObject *parent) - : QObject(parent), state(NotGesture), m_lastCustomGestureId(0) + : QObject(parent), state(NotGesture), m_lastCustomGestureId(Qt::CustomGesture) { qRegisterMetaType<Qt::GestureState>(); @@ -119,7 +119,7 @@ Qt::GestureType QGestureManager::registerGestureRecognizer(QGestureRecognizer *r if (type == Qt::CustomGesture) { // generate a new custom gesture id ++m_lastCustomGestureId; - type = Qt::GestureType(Qt::CustomGesture + m_lastCustomGestureId); + type = Qt::GestureType(m_lastCustomGestureId); } m_recognizers.insertMulti(type, recognizer); delete dummy; diff --git a/src/gui/kernel/qstandardgestures.cpp b/src/gui/kernel/qstandardgestures.cpp index 62d8a53..e05f8cc 100644 --- a/src/gui/kernel/qstandardgestures.cpp +++ b/src/gui/kernel/qstandardgestures.cpp @@ -517,7 +517,6 @@ QTapAndHoldGestureRecognizer::recognize(QGesture *state, QObject *object, const QMouseEvent *me = static_cast<const QMouseEvent *>(event); const QGraphicsSceneMouseEvent *gsme = static_cast<const QGraphicsSceneMouseEvent *>(event); - enum { TimerInterval = 2000 }; enum { TapRadius = 40 }; switch (event->type()) { @@ -526,21 +525,21 @@ QTapAndHoldGestureRecognizer::recognize(QGesture *state, QObject *object, q->setHotSpot(d->position); if (d->timerId) q->killTimer(d->timerId); - d->timerId = q->startTimer(TimerInterval); + d->timerId = q->startTimer(QTapAndHoldGesturePrivate::Timeout); return QGestureRecognizer::MayBeGesture; // we don't show a sign of life until the timeout case QEvent::MouseButtonPress: d->position = me->globalPos(); q->setHotSpot(d->position); if (d->timerId) q->killTimer(d->timerId); - d->timerId = q->startTimer(TimerInterval); + d->timerId = q->startTimer(QTapAndHoldGesturePrivate::Timeout); return QGestureRecognizer::MayBeGesture; // we don't show a sign of life until the timeout case QEvent::TouchBegin: d->position = ev->touchPoints().at(0).startScreenPos(); q->setHotSpot(d->position); if (d->timerId) q->killTimer(d->timerId); - d->timerId = q->startTimer(TimerInterval); + d->timerId = q->startTimer(QTapAndHoldGesturePrivate::Timeout); return QGestureRecognizer::MayBeGesture; // we don't show a sign of life until the timeout case QEvent::GraphicsSceneMouseRelease: case QEvent::MouseButtonRelease: |