summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp44
-rw-r--r--src/gui/graphicsview/qgraphicsitem_p.h4
-rw-r--r--src/gui/graphicsview/qgraphicsproxywidget.cpp16
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp120
-rw-r--r--src/gui/graphicsview/qgraphicsscene_p.h5
-rw-r--r--src/gui/graphicsview/qgraphicssceneevent.cpp9
-rw-r--r--src/gui/graphicsview/qgraphicssceneevent.h1
-rw-r--r--src/gui/graphicsview/qgraphicsview.cpp1
-rw-r--r--src/gui/kernel/qgesture.h2
-rw-r--r--src/gui/kernel/qgesture_p.h4
-rw-r--r--src/gui/kernel/qgesturemanager.cpp38
-rw-r--r--src/gui/kernel/qgesturemanager_p.h7
-rw-r--r--src/gui/kernel/qwidget.cpp22
-rw-r--r--src/gui/kernel/qwidget_p.h1
14 files changed, 216 insertions, 58 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index e2b8115..d9f450a 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -5802,6 +5802,7 @@ QVariant QGraphicsItem::inputMethodQuery(Qt::InputMethodQuery query) const
*/
int QGraphicsItem::grabGesture(Qt::GestureType gesture)
{
+ /// TODO: if we are QGraphicsProxyWidget we should subscribe the widget to gesture as well.
return grabGesture(qt_getStandardGestureTypeName(gesture));
}
@@ -5817,12 +5818,30 @@ int QGraphicsItem::grabGesture(Qt::GestureType gesture)
int QGraphicsItem::grabGesture(const QString &gesture)
{
int id = QGestureManager::instance()->makeGestureId(gesture);
- d_ptr->gestures << id;
- if (d_ptr->scene)
- d_ptr->scene->d_func()->grabGesture(this, id);
+ d_ptr->grabGesture(id);
return id;
}
+void QGraphicsItemPrivate::grabGesture(int id)
+{
+ Q_Q(QGraphicsItem);
+ gestures << id;
+ if (scene)
+ scene->d_func()->grabGesture(q, id);
+}
+
+bool QGraphicsItemPrivate::releaseGesture(int id)
+{
+ Q_Q(QGraphicsItem);
+ if (gestures.contains(id)) {
+ if (scene)
+ scene->d_func()->releaseGesture(q, id);
+ gestures.remove(id);
+ return true;
+ }
+ return false;
+}
+
/*!
\since 4.6
@@ -5833,10 +5852,9 @@ int QGraphicsItem::grabGesture(const QString &gesture)
*/
void QGraphicsItem::releaseGesture(int gestureId)
{
- if (d_ptr->scene)
- d_ptr->scene->d_func()->releaseGesture(this, gestureId);
- QGestureManager::instance()->releaseGestureId(gestureId);
- d_ptr->gestures.remove(gestureId);
+ /// TODO: if we are QGraphicsProxyWidget we should unsubscribe the widget from gesture as well.
+ if (d_ptr->releaseGesture(gestureId))
+ QGestureManager::instance()->releaseGestureId(gestureId);
}
/*!
@@ -5854,6 +5872,18 @@ void QGraphicsItem::setGestureEnabled(int gestureId, bool enable)
//###
}
+bool QGraphicsItemPrivate::hasGesture(const QString &name) const
+{
+ QGestureManager *gm = QGestureManager::instance();
+ QSet<int>::const_iterator it = gestures.begin(),
+ e = gestures.end();
+ for (; it != e; ++it) {
+ if (gm->gestureNameFromId(*it) == name)
+ return true;
+ }
+ return false;
+}
+
/*!
This virtual function is called by QGraphicsItem to notify custom items
that some part of the item's state changes. By reimplementing this
diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h
index 1d3a316..e9e36fa 100644
--- a/src/gui/graphicsview/qgraphicsitem_p.h
+++ b/src/gui/graphicsview/qgraphicsitem_p.h
@@ -300,6 +300,10 @@ public:
int depth;
QSet<int> gestures;
+ bool hasGesture(const QString &gesture) const;
+ void grabGesture(int id);
+ bool releaseGesture(int id);
+
// Packed 32 bytes
quint32 acceptedMouseButtons : 5;
quint32 visible : 1;
diff --git a/src/gui/graphicsview/qgraphicsproxywidget.cpp b/src/gui/graphicsview/qgraphicsproxywidget.cpp
index 01b7593..2d7490c 100644
--- a/src/gui/graphicsview/qgraphicsproxywidget.cpp
+++ b/src/gui/graphicsview/qgraphicsproxywidget.cpp
@@ -48,6 +48,7 @@
#include "private/qgraphicsproxywidget_p.h"
#include "private/qwidget_p.h"
#include "private/qapplication_p.h"
+#include "private/qgesturemanager_p.h"
#include <QtCore/qdebug.h>
#include <QtGui/qevent.h>
@@ -275,7 +276,7 @@ void QGraphicsProxyWidgetPrivate::sendWidgetMouseEvent(QGraphicsSceneMouseEvent
QWidget *embeddedMouseGrabberPtr = (QWidget *)embeddedMouseGrabber;
QApplicationPrivate::sendMouseEvent(receiver, mouseEvent, alienWidget, widget,
- &embeddedMouseGrabberPtr, lastWidgetUnderMouse);
+ &embeddedMouseGrabberPtr, lastWidgetUnderMouse, event->spontaneous());
embeddedMouseGrabber = embeddedMouseGrabberPtr;
// Handle enter/leave events when last button is released from mouse
@@ -648,6 +649,9 @@ void QGraphicsProxyWidgetPrivate::setWidget_helper(QWidget *newWidget, bool auto
q->setAttribute(Qt::WA_OpaquePaintEvent);
widget = newWidget;
+ foreach(int gestureId, widget->d_func()->gestures) {
+ grabGesture(gestureId);
+ }
// Changes only go from the widget to the proxy.
enabledChangeMode = QGraphicsProxyWidgetPrivate::WidgetToProxyMode;
@@ -871,6 +875,16 @@ bool QGraphicsProxyWidget::event(QEvent *event)
}
break;
}
+ case QEvent::GraphicsSceneGesture: {
+ qDebug() << "QGraphicsProxyWidget: graphicsscenegesture";
+ if (d->widget && d->widget->isVisible()) {
+ QGraphicsSceneGestureEvent *ge = static_cast<QGraphicsSceneGestureEvent*>(event);
+ //### TODO: widget->childAt(): decompose gesture event and find widget under hotspots.
+ QGestureManager::instance()->sendGestureEvent(d->widget, ge->gestures().toSet(), ge->cancelledGestures());
+ return true;
+ }
+ break;
+ }
default:
break;
}
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index 3d4bb5c..9fdb46f 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -248,6 +248,7 @@ static const int QGRAPHICSSCENE_INDEXTIMER_TIMEOUT = 2000;
#include <private/qt_x11_p.h>
#endif
#include <private/qgesturemanager_p.h>
+#include <private/qgesture_p.h>
QT_BEGIN_NAMESPACE
@@ -3953,40 +3954,44 @@ bool QGraphicsScene::event(QEvent *event)
update();
break;
case QEvent::GraphicsSceneGesture: {
+ qDebug() << "GraphicsSceneGesture";
QGraphicsSceneGestureEvent *ev = static_cast<QGraphicsSceneGestureEvent*>(event);
- QList<QString> gestureTypes = ev->gestureTypes();
QGraphicsView *view = qobject_cast<QGraphicsView*>(ev->widget());
if (!view) {
qWarning("QGraphicsScene::event: gesture event was received without a view");
break;
}
- // find graphics items that intersects with gestures hot spots.
- QPolygonF poly;
- QMap<QString, QPointF> sceneHotSpots;
- foreach(const QString &type, gestureTypes) {
- QPointF pt = ev->mapToScene(ev->gesture(type)->hotSpot());
- sceneHotSpots.insert(type, pt);
- poly << pt;
+ // get a list of gestures that just started.
+ QSet<QGesture*> startedGestures;
+ QList<QGesture*> gestures = ev->gestures();
+ for(QList<QGesture*>::const_iterator it = gestures.begin(), e = gestures.end();
+ it != e; ++it) {
+ QGesture *g = *it;
+ QGesturePrivate *gd = g->d_func();
+ if (g->state() == Qt::GestureStarted || gd->singleshot) {
+ startedGestures.insert(g);
+ }
}
- QList<QGraphicsItem*> itemsInGestureArea = items(poly, Qt::IntersectsItemBoundingRect);
-
- foreach(QGraphicsItem *item, itemsInGestureArea) {
- QMap<QString, QPointF>::const_iterator it = sceneHotSpots.begin(),
- e = sceneHotSpots.end();
- for(; it != e; ++it) {
- if (item->contains(item->mapFromScene(it.value()))) {
- const QString gestureName = it.key();
- foreach(int gestureId, item->d_ptr->gestures) {
- if (QGestureManager::instance()->gestureNameFromId(gestureId) == gestureName) {
- d->sendEvent(item, ev);
- if (ev->isAccepted())
- break;
- }
+ if (!startedGestures.isEmpty()) {
+ // find a target for each started gesture.
+ for(QSet<QGesture*>::const_iterator it = startedGestures.begin(), e = startedGestures.end();
+ it != e; ++it) {
+ QGesture *g = *it;
+ QGesturePrivate *gd = g->d_func();
+ QList<QGraphicsItem*> itemsInGestureArea = items(g->hotSpot());
+ const QString gestureName = g->type();
+ foreach(QGraphicsItem *item, itemsInGestureArea) {
+ if (item->d_func()->hasGesture(gestureName)) {
+ Q_ASSERT(gd->graphicsItem == 0);
+ gd->graphicsItem = item;
+ d->itemsWithGestures[item].insert(g);
+ break;
}
}
}
}
+ d->sendGestureEvent(ev->gestures().toSet(), ev->cancelledGestures());
}
break;
case QEvent::GraphicsSceneTouchBegin:
@@ -4010,6 +4015,74 @@ bool QGraphicsScene::event(QEvent *event)
return true;
}
+void QGraphicsScenePrivate::sendGestureEvent(const QSet<QGesture*> &gestures, const QSet<QString> &cancelled)
+{
+ qDebug() << "QGraphicsScenePrivate::sendGestureEvent:" << gestures;
+ Q_Q(QGraphicsScene);
+ typedef QMap<QGraphicsItem*, QSet<QGesture*> > ItemGesturesMap;
+ ItemGesturesMap itemGestures;
+ QSet<QGesture*> startedGestures;
+ for(QSet<QGesture*>::const_iterator it = gestures.begin(), e = gestures.end();
+ it != e; ++it) {
+ QGesture *g = *it;
+ Q_ASSERT(g != 0);
+ QGesturePrivate *gd = g->d_func();
+ if (gd->graphicsItem != 0) {
+ itemGestures[gd->graphicsItem].insert(g);
+ if (g->state() == Qt::GestureStarted || gd->singleshot)
+ startedGestures.insert(g);
+ }
+ }
+
+ qDebug() << "QGraphicsScenePrivate::sendGestureEvent: started: " << startedGestures;
+ QSet<QGesture*> ignoredGestures;
+ for(ItemGesturesMap::const_iterator it = itemGestures.begin(), e = itemGestures.end();
+ it != e; ++it) {
+ QGraphicsItem *receiver = it.key();
+ Q_ASSERT(receiver != 0);
+ QGraphicsSceneGestureEvent event;
+ event.setGestures(it.value());
+ event.setCancelledGestures(cancelled);
+ qDebug() << "QGraphicsScenePrivate::sendGestureEvent: sending to " << receiver << it.value();
+ bool processed = sendEvent(receiver, &event);
+ QSet<QGesture*> started = startedGestures.intersect(it.value());
+ if (event.isAccepted())
+ foreach(QGesture *g, started)
+ g->accept();
+ if (!started.isEmpty() && !(processed && event.isAccepted())) {
+ // there are started gestures event that weren't
+ // accepted, so propagating each gesture independently.
+ QSet<QGesture*>::const_iterator it = started.begin(),
+ e = started.end();
+ for(; it != e; ++it) {
+ QGesture *g = *it;
+ qDebug() << "result: " << g << ":" << processed << g->isAccepted();
+ if (processed && g->isAccepted()) {
+ continue;
+ }
+ QGesturePrivate *gd = g->d_func();
+ QGraphicsItem *item = gd->graphicsItem;
+ gd->graphicsItem = 0;
+
+ //### THIS IS BS, DONT FORGET TO REWRITE THIS CODE
+ // need to make sure we try to deliver event just once to each widget
+ const QString gestureType = g->type();
+ QList<QGraphicsItem*> itemsUnderGesture = q->items(g->hotSpot());
+ for (int i = 0; i < itemsUnderGesture.size(); ++i) {
+ QGraphicsItem *item = itemsUnderGesture.at(i);
+ if (item != receiver && item->d_func()->hasGesture(gestureType)) {
+ ignoredGestures.insert(g);
+ gd->graphicsItem = item;
+ break;
+ }
+ }
+ }
+ }
+ }
+ if (!ignoredGestures.isEmpty())
+ sendGestureEvent(ignoredGestures, cancelled);
+}
+
/*!
\reimp
@@ -5641,12 +5714,13 @@ void QGraphicsScenePrivate::grabGesture(QGraphicsItem *item, int gestureId)
foreach(QGraphicsView *view, views)
view->d_func()->grabGesture(gestureId);
}
- itemsWithGestures << item;
+ (void)itemsWithGestures[item];
grabbedGestures << gestureId;
}
void QGraphicsScenePrivate::releaseGesture(QGraphicsItem *item, int gestureId)
{
+ itemsWithGestures.remove(item);
//###
}
diff --git a/src/gui/graphicsview/qgraphicsscene_p.h b/src/gui/graphicsview/qgraphicsscene_p.h
index 7928a45..160ba49 100644
--- a/src/gui/graphicsview/qgraphicsscene_p.h
+++ b/src/gui/graphicsview/qgraphicsscene_p.h
@@ -74,6 +74,7 @@ QT_BEGIN_NAMESPACE
class QGraphicsView;
class QGraphicsWidget;
+class QGesture;
class QGraphicsScenePrivate : public QObjectPrivate
{
@@ -267,10 +268,12 @@ public:
void resolvePalette();
void updatePalette(const QPalette &palette);
- QSet<QGraphicsItem*> itemsWithGestures;
+ // items with gestures -> list of started gestures.
+ QMap<QGraphicsItem*, QSet<QGesture*> > itemsWithGestures;
QSet<int> grabbedGestures;
void grabGesture(QGraphicsItem *item, int gestureId);
void releaseGesture(QGraphicsItem *item, int gestureId);
+ void sendGestureEvent(const QSet<QGesture*> &gestures, const QSet<QString> &cancelled);
mutable QVector<QTransform> sceneTransformCache;
mutable QBitArray validTransforms;
diff --git a/src/gui/graphicsview/qgraphicssceneevent.cpp b/src/gui/graphicsview/qgraphicssceneevent.cpp
index d5d0fb9..2c5c946 100644
--- a/src/gui/graphicsview/qgraphicssceneevent.cpp
+++ b/src/gui/graphicsview/qgraphicssceneevent.cpp
@@ -1895,6 +1895,15 @@ void QGraphicsSceneGestureEvent::setGestures(const QList<QGesture*> &gestures)
}
/*!
+ Set a list of gesture objects containing extended information about \a gestures.
+*/
+void QGraphicsSceneGestureEvent::setGestures(const QSet<QGesture*> &gestures)
+{
+ foreach(QGesture *g, gestures)
+ m_gestures.insert(g->type(), g);
+}
+
+/*!
Sets the accept flag of the all gestures inside the event object,
the equivalent of calling \l{QEvent::accept()}{accept()} or
\l{QEvent::setAccepted()}{setAccepted(true)}.
diff --git a/src/gui/graphicsview/qgraphicssceneevent.h b/src/gui/graphicsview/qgraphicssceneevent.h
index 01cdab9..8b24d33 100644
--- a/src/gui/graphicsview/qgraphicssceneevent.h
+++ b/src/gui/graphicsview/qgraphicssceneevent.h
@@ -325,6 +325,7 @@ public:
const QGesture* gesture(const QString &type) const;
QList<QGesture*> gestures() const;
void setGestures(const QList<QGesture*> &gestures);
+ void setGestures(const QSet<QGesture*> &gestures);
QSet<QString> cancelledGestures() const;
void setCancelledGestures(const QSet<QString> &cancelledGestures);
diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp
index 2d2113c..6a20139 100644
--- a/src/gui/graphicsview/qgraphicsview.cpp
+++ b/src/gui/graphicsview/qgraphicsview.cpp
@@ -2977,6 +2977,7 @@ bool QGraphicsView::viewportEvent(QEvent *event)
gestureEvent.setGestures(ev->gestures());
gestureEvent.setCancelledGestures(ev->cancelledGestures());
QApplication::sendEvent(d->scene, &gestureEvent);
+ event->setAccepted(gestureEvent.isAccepted());
if (gestureEvent.isAccepted())
return true;
}
diff --git a/src/gui/kernel/qgesture.h b/src/gui/kernel/qgesture.h
index d220232..bf501f2 100644
--- a/src/gui/kernel/qgesture.h
+++ b/src/gui/kernel/qgesture.h
@@ -110,6 +110,8 @@ private:
friend class QGestureManager;
friend class QApplication;
+ friend class QGraphicsScene;
+ friend class QGraphicsScenePrivate;
friend class QGestureRecognizerPan;
friend class QDoubleTapGestureRecognizer;
friend class QTapAndHoldGestureRecognizer;
diff --git a/src/gui/kernel/qgesture_p.h b/src/gui/kernel/qgesture_p.h
index d2d77cc..0f2e791 100644
--- a/src/gui/kernel/qgesture_p.h
+++ b/src/gui/kernel/qgesture_p.h
@@ -60,13 +60,14 @@
QT_BEGIN_NAMESPACE
+class QGraphicsItem;
class QGesturePrivate : public QObjectPrivate
{
Q_DECLARE_PUBLIC(QGesture)
public:
QGesturePrivate()
- : state(Qt::NoGesture), singleshot(0), duration(0) { }
+ : state(Qt::NoGesture), graphicsItem(0), singleshot(0), duration(0) { }
void init(const QPoint &startPos, const QPoint &lastPos,
const QPoint &pos, const QRect &rect,
@@ -86,6 +87,7 @@ public:
Qt::GestureState state;
QPointer<QWidget> widget;
+ QGraphicsItem *graphicsItem;
uint singleshot:1;
QRect rect;
diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp
index 2750df4..23127cb 100644
--- a/src/gui/kernel/qgesturemanager.cpp
+++ b/src/gui/kernel/qgesturemanager.cpp
@@ -53,7 +53,7 @@
#include "qdebug.h"
-// #define GESTURE_DEBUG
+#define GESTURE_DEBUG
#ifndef GESTURE_DEBUG
# define DEBUG if (0) qDebug
#else
@@ -170,6 +170,7 @@ bool QGestureManager::filterEvent(QWidget *receiver, QEvent *event)
foreach(QGestureRecognizer *r, finishedGestures) {
if (QGesture *gesture = r->getGesture()) {
gestures << gesture;
+ qDebug() << "SINGLESHOT" << gesture;
gesture->d_func()->singleshot = true;
}
}
@@ -277,7 +278,9 @@ bool QGestureManager::filterEvent(QWidget *receiver, QEvent *event)
foreach(QGestureRecognizer *r, finishedGestures) {
if (QGesture *gesture = r->getGesture()) {
gestures << gesture;
- gesture->d_func()->singleshot = activeGestures.contains(r);
+ gesture->d_func()->singleshot = !activeGestures.contains(r);
+ if (gesture->d_func()->singleshot)
+ qDebug() << "SINGLESHOT:" << gesture;
}
}
activeGestures -= finishedGestures;
@@ -492,18 +495,6 @@ void QGestureManager::recognizerStateChanged(QGestureRecognizer::Result result)
}
}
-bool QGestureManager::widgetHasGesture(QWidget *widget, QGesture *gesture) const
-{
- const QString gestureName = gesture->type();
- QSet<int>::iterator it = widget->d_func()->gestures.begin(),
- e = widget->d_func()->gestures.end();
- for (; it != e; ++it) {
- if (gestureNameFromId(*it) == gestureName)
- return true;
- }
- return false;
-}
-
bool QGestureManager::sendGestureEvent(QWidget *receiver, const QSet<QGesture*> &gestures,
const QSet<QString> &cancelled)
{
@@ -519,13 +510,16 @@ bool QGestureManager::sendGestureEvent(QWidget *receiver, const QSet<QGesture*>
it != e; ++it) {
QGesture *g = *it;
QGesturePrivate *gd = g->d_func();
- if (!gd->widget && (g->state() == Qt::GestureStarted || gd->singleshot)) {
+ qDebug() << "sendGestureEvent:" << g << g->state() << "singleshot = " << gd->singleshot;
+ if (receiver && (g->state() == Qt::GestureStarted || gd->singleshot)) {
startedGestures.insert(g);
// find the target widget
QWidget *w = receiver;
QPoint offset;
+ const QString gestureType = g->type();
while (w) {
- if (widgetHasGesture(w, g))
+ qDebug() << w << w->d_func()->gestures;
+ if (w->d_func()->hasGesture(gestureType))
break;
if (w->isWindow()) {
w = 0;
@@ -536,6 +530,7 @@ bool QGestureManager::sendGestureEvent(QWidget *receiver, const QSet<QGesture*>
}
if (!w) // no widget in the tree that accepts this gesture.
continue;
+ qDebug() << "QGestureManager::sendGestureEvent:" << g << "setting widget to " << w;
gd->widget = w;
g->translate(offset);
}
@@ -556,10 +551,14 @@ bool QGestureManager::sendGestureEvent(QWidget *receiver, const QSet<QGesture*>
Q_ASSERT(receiver != 0 /*should be taken care above*/);
// TODO: send cancelled gesture event to the widget that received the original gesture!
QGestureEvent event(it.value(), cancelled);
+ qDebug() << "QGestureManager::sendGestureEvent: sending now: " << receiver << it.value();
bool processed = qt_sendSpontaneousEvent(receiver, &event);
QSet<QGesture*> started = startedGestures.intersect(it.value());
+ if (event.isAccepted())
+ foreach(QGesture *g, started)
+ g->accept();
if (!started.isEmpty() && !(processed && event.isAccepted())) {
- // there are started gestures event that weren't
+ // there are started gestures events that weren't
// accepted, so propagating each gesture independently.
QSet<QGesture*>::const_iterator it = started.begin(),
e = started.end();
@@ -579,9 +578,10 @@ bool QGestureManager::sendGestureEvent(QWidget *receiver, const QSet<QGesture*>
g->translate(w->pos());
w = w->parentWidget();
QPoint offset;
+ const QString gestureType = g->type();
while (w) {
- if (widgetHasGesture(w, g)) {
- DEBUG() << "QGestureManager: sendGestureEvent:" << w << "didn't accept gesture" << g;
+ if (w->d_func()->hasGesture(gestureType)) {
+ DEBUG() << "QGestureManager::sendGestureEvent:" << w << "didn't accept gesture" << g;
ignoredGestures.insert(g);
break;
}
diff --git a/src/gui/kernel/qgesturemanager_p.h b/src/gui/kernel/qgesturemanager_p.h
index 18183e2..138def5 100644
--- a/src/gui/kernel/qgesturemanager_p.h
+++ b/src/gui/kernel/qgesturemanager_p.h
@@ -86,6 +86,9 @@ public:
// declared in qapplication.cpp
static QGestureManager* instance();
+ bool sendGestureEvent(QWidget *receiver, const QSet<QGesture*> &gestures,
+ const QSet<QString> &cancelled = QSet<QString>());
+
protected:
void timerEvent(QTimerEvent *event);
@@ -93,10 +96,6 @@ private slots:
void recognizerStateChanged(QGestureRecognizer::Result);
private:
- bool widgetHasGesture(QWidget *widget, QGesture *gesture) const;
- bool sendGestureEvent(QWidget *receiver, const QSet<QGesture*> &gestures,
- const QSet<QString> &cancelled = QSet<QString>());
-
QSet<QGestureRecognizer*> activeGestures;
QMap<QGestureRecognizer*, int> maybeGestures;
QSet<QGestureRecognizer*> recognizers;
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index 3a146e5..7920139 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -10970,7 +10970,10 @@ QWindowSurface *QWidget::windowSurface() const
int QWidget::grabGesture(const QString &gesture)
{
Q_D(QWidget);
- return d->grabGesture(QGestureManager::instance()->makeGestureId(gesture));
+ int id = d->grabGesture(QGestureManager::instance()->makeGestureId(gesture));
+ if (d->extra && d->extra->proxyWidget)
+ d->extra->proxyWidget->QGraphicsItem::d_ptr->grabGesture(id);
+ return id;
}
int QWidgetPrivate::grabGesture(int gestureId)
@@ -10993,6 +10996,18 @@ bool QWidgetPrivate::releaseGesture(int gestureId)
return false;
}
+bool QWidgetPrivate::hasGesture(const QString &name) const
+{
+ QGestureManager *gm = QGestureManager::instance();
+ QSet<int>::const_iterator it = gestures.begin(),
+ e = gestures.end();
+ for (; it != e; ++it) {
+ if (gm->gestureNameFromId(*it) == name)
+ return true;
+ }
+ return false;
+}
+
/*!
\since 4.6
@@ -11018,8 +11033,11 @@ int QWidget::grabGesture(Qt::GestureType gesture)
void QWidget::releaseGesture(int gestureId)
{
Q_D(QWidget);
- if (d->releaseGesture(gestureId))
+ if (d->releaseGesture(gestureId)) {
+ if (d->extra && d->extra->proxyWidget)
+ d->extra->proxyWidget->QGraphicsItem::d_ptr->releaseGesture(gestureId);
QGestureManager::instance()->releaseGestureId(gestureId);
+ }
}
/*!
diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h
index a603b44..b2ae75e 100644
--- a/src/gui/kernel/qwidget_p.h
+++ b/src/gui/kernel/qwidget_p.h
@@ -521,6 +521,7 @@ public:
QSet<int> gestures;
int grabGesture(int gestureId);
bool releaseGesture(int gestureId);
+ bool hasGesture(const QString &type) const;
// Bit fields.
uint high_attributes[3]; // the low ones are in QWidget::widget_attributes