summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
authorDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-04-20 09:44:23 (GMT)
committerDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-05-11 14:51:50 (GMT)
commit62229907918ddf1b830a51c8a2613cf2492ae1c7 (patch)
tree165fce05c5ebac7bf7425bfebf6fd3e361f44c63 /src/gui/kernel
parent0cc862890384929c4c3b07c6dc5787362f3aeb9c (diff)
downloadQt-62229907918ddf1b830a51c8a2613cf2492ae1c7.zip
Qt-62229907918ddf1b830a51c8a2613cf2492ae1c7.tar.gz
Qt-62229907918ddf1b830a51c8a2613cf2492ae1c7.tar.bz2
Added a QApplication::eventDeliveryDelayForGestures property that
specifies a timout for mouse event delivery to allow the gesture framework to successfully recognizer a gesture.
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/qapplication.cpp27
-rw-r--r--src/gui/kernel/qapplication.h4
-rw-r--r--src/gui/kernel/qgesturemanager.cpp20
-rw-r--r--src/gui/kernel/qgesturemanager_p.h5
4 files changed, 50 insertions, 6 deletions
diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp
index ca5d77b..f652942 100644
--- a/src/gui/kernel/qapplication.cpp
+++ b/src/gui/kernel/qapplication.cpp
@@ -5116,6 +5116,33 @@ void QApplication::removeGestureRecognizer(QGestureRecognizer *recognizer)
d->gestureManager->removeRecognizer(recognizer);
}
+/*!
+ \property QApplication::eventDeliveryDelayForGestures
+
+ Specifies the \a delay before input events are delivered to the
+ gesture enabled widgets.
+
+ The delay allows to postpone widget's input event handling until
+ gestures framework can successfully recognize a gesture.
+
+ \sa QWidget::grabGesture
+*/
+void QApplication::setEventDeliveryDelayForGestures(int delay)
+{
+ Q_D(QApplication);
+ if (!d->gestureManager)
+ d->gestureManager = new QGestureManager(this);
+ d->gestureManager->setEventDeliveryDelay(delay);
+}
+
+int QApplication::eventDeliveryDelayForGestures()
+{
+ Q_D(QApplication);
+ if (!d->gestureManager)
+ d->gestureManager = new QGestureManager(this);
+ return d->gestureManager->eventDeliveryDelay();
+}
+
/*! \fn QDecoration &QApplication::qwsDecoration()
Return the QWSDecoration used for decorating windows.
diff --git a/src/gui/kernel/qapplication.h b/src/gui/kernel/qapplication.h
index 70458ef..e09ea08 100644
--- a/src/gui/kernel/qapplication.h
+++ b/src/gui/kernel/qapplication.h
@@ -107,6 +107,7 @@ class Q_GUI_EXPORT QApplication : public QCoreApplication
Q_PROPERTY(int autoMaximizeThreshold READ autoMaximizeThreshold WRITE setAutoMaximizeThreshold)
Q_PROPERTY(bool autoSipEnabled READ autoSipEnabled WRITE setAutoSipEnabled)
#endif
+ Q_PROPERTY(int eventDeliveryDelayForGestures READ eventDeliveryDelayForGestures WRITE setEventDeliveryDelayForGestures)
public:
enum Type { Tty, GuiClient, GuiServer };
@@ -270,6 +271,9 @@ public:
void addGestureRecognizer(QGestureRecognizer *recognizer);
void removeGestureRecognizer(QGestureRecognizer *recognizer);
+ void setEventDeliveryDelayForGestures(int delay);
+ int eventDeliveryDelayForGestures();
+
Q_SIGNALS:
void lastWindowClosed();
void focusChanged(QWidget *old, QWidget *now);
diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp
index bb0ee6d..1a37a05 100644
--- a/src/gui/kernel/qgesturemanager.cpp
+++ b/src/gui/kernel/qgesturemanager.cpp
@@ -63,11 +63,10 @@ QT_BEGIN_NAMESPACE
bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event);
static const unsigned int MaximumGestureRecognitionTimeout = 2000;
-static const unsigned int DelayedPressTimeout = 300;
QGestureManager::QGestureManager(QObject *parent)
- : QObject(parent), targetWidget(0), delayedPressTimer(0),
- lastMousePressEvent(QEvent::None, QPoint(), Qt::NoButton, 0, 0),
+ : QObject(parent), targetWidget(0), eventDeliveryDelayTimeout(300),
+ delayedPressTimer(0), lastMousePressEvent(QEvent::None, QPoint(), Qt::NoButton, 0, 0),
state(NotGesture)
{
qRegisterMetaType<Qt::DirectionType>();
@@ -328,7 +327,8 @@ bool QGestureManager::filterEvent(QEvent *event)
}
killTimer(delayedPressTimer);
delayedPressTimer = 0;
- } else if (state == MaybeGesture && event->type() == QEvent::MouseButtonPress) {
+ } else if (state == MaybeGesture && event->type() == QEvent::MouseButtonPress
+ && eventDeliveryDelayTimeout) {
// postpone the press event delivery until we know for
// sure whether it is a gesture.
DEBUG() << "QGestureManager: postponing mouse press event";
@@ -337,7 +337,7 @@ bool QGestureManager::filterEvent(QEvent *event)
me->globalPos(), me->button(),
me->buttons(), me->modifiers());
Q_ASSERT(delayedPressTimer == 0);
- delayedPressTimer = startTimer(DelayedPressTimeout);
+ delayedPressTimer = startTimer(eventDeliveryDelayTimeout);
if (!delayedPressTimer)
qWarning("QGestureManager: couldn't start delayed press timer!");
}
@@ -491,6 +491,16 @@ bool QGestureManager::sendGestureEvent(QWidget *receiver, QGestureEvent *event)
return receiver ? qt_sendSpontaneousEvent(receiver, event) : false;
}
+int QGestureManager::eventDeliveryDelay() const
+{
+ return eventDeliveryDelayTimeout;
+}
+
+void QGestureManager::setEventDeliveryDelay(int ms)
+{
+ eventDeliveryDelayTimeout = ms;
+}
+
QT_END_NAMESPACE
#include "moc_qgesturemanager_p.cpp"
diff --git a/src/gui/kernel/qgesturemanager_p.h b/src/gui/kernel/qgesturemanager_p.h
index ef3cdaf..c22027f 100644
--- a/src/gui/kernel/qgesturemanager_p.h
+++ b/src/gui/kernel/qgesturemanager_p.h
@@ -69,9 +69,11 @@ class Q_GUI_EXPORT QGestureManager : public QObject
public:
QGestureManager(QObject *parent);
- // should be internal
void setGestureTargetWidget(QWidget *widget);
+ int eventDeliveryDelay() const;
+ void setEventDeliveryDelay(int ms);
+
void addRecognizer(QGestureRecognizer *recognizer);
void removeRecognizer(QGestureRecognizer *recognizer);
@@ -94,6 +96,7 @@ private:
QWidget *targetWidget;
QPoint lastPos;
+ int eventDeliveryDelayTimeout;
int delayedPressTimer;
QMouseEvent lastMousePressEvent;