summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/kernel/qgesturemanager.cpp16
-rw-r--r--src/gui/kernel/qgesturemanager_p.h2
-rw-r--r--src/gui/kernel/qwidget.cpp16
-rw-r--r--src/gui/kernel/qwidget.h1
4 files changed, 35 insertions, 0 deletions
diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp
index dc76c3f..df88f9e 100644
--- a/src/gui/kernel/qgesturemanager.cpp
+++ b/src/gui/kernel/qgesturemanager.cpp
@@ -129,6 +129,21 @@ void QGestureManager::unregisterGestureRecognizer(Qt::GestureType type)
}
}
+void QGestureManager::cleanupCachedGestures(QObject *target, Qt::GestureType type)
+{
+ QMap<ObjectGesture, QGesture *>::Iterator iter = objectGestures.begin();
+ while (iter != objectGestures.end()) {
+ ObjectGesture objectGesture = iter.key();
+ if (objectGesture.gesture == type && target == objectGesture.object.data()) {
+ delete iter.value();
+ iter = objectGestures.erase(iter);
+ } else {
+ ++iter;
+ }
+ }
+}
+
+// get or create a QGesture object that will represent the state for a given object, used by the recognizer
QGesture *QGestureManager::getState(QObject *object, Qt::GestureType type)
{
// if the widget is being deleted we should be carefull and not to
@@ -332,6 +347,7 @@ void QGestureManager::cleanupGesturesForRemovedRecognizer(QGesture *gesture)
}
}
+// return true if accepted (consumed)
bool QGestureManager::filterEvent(QWidget *receiver, QEvent *event)
{
QSet<Qt::GestureType> types;
diff --git a/src/gui/kernel/qgesturemanager_p.h b/src/gui/kernel/qgesturemanager_p.h
index eef45d2..96c2fb7 100644
--- a/src/gui/kernel/qgesturemanager_p.h
+++ b/src/gui/kernel/qgesturemanager_p.h
@@ -79,6 +79,8 @@ public:
// declared in qapplication.cpp
static QGestureManager* instance();
+ void cleanupCachedGestures(QObject *target, Qt::GestureType type);
+
protected:
void timerEvent(QTimerEvent *event);
bool filterEventThroughContexts(const QMap<QObject *, Qt::GestureType> &contexts,
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index 5fa9a92..c10db90 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -11708,6 +11708,22 @@ void QWidget::grabGesture(Qt::GestureType gesture, Qt::GestureContext context)
(void)QGestureManager::instance(); // create a gesture manager
}
+/*!
+ Unsubscribes the widget to a given \a gesture type
+
+ \sa QGestureEvent
+ \since 4.6
+*/
+void QWidget::ungrabGesture(Qt::GestureType gesture)
+{
+ Q_D(QWidget);
+ if (d->gestureContext.remove(gesture)) {
+ QGestureManager *manager = QGestureManager::instance();
+ manager->cleanupCachedGestures(this, gesture);
+ }
+}
+
+
QT_END_NAMESPACE
#include "moc_qwidget.cpp"
diff --git a/src/gui/kernel/qwidget.h b/src/gui/kernel/qwidget.h
index e603a1a..fce3f09 100644
--- a/src/gui/kernel/qwidget.h
+++ b/src/gui/kernel/qwidget.h
@@ -355,6 +355,7 @@ public:
void setGraphicsEffect(QGraphicsEffect *effect);
void grabGesture(Qt::GestureType type, Qt::GestureContext context = Qt::WidgetWithChildrenGesture);
+ void ungrabGesture(Qt::GestureType type);
public Q_SLOTS:
void setWindowTitle(const QString &);