diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/graphicsview/qgraphicsscene.cpp | 10 | ||||
-rw-r--r-- | src/gui/kernel/qapplication.cpp | 15 | ||||
-rw-r--r-- | src/gui/kernel/qapplication_p.h | 2 | ||||
-rw-r--r-- | src/gui/kernel/qgesturemanager.cpp | 9 | ||||
-rw-r--r-- | src/gui/kernel/qgesturemanager_p.h | 4 |
5 files changed, 21 insertions, 19 deletions
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index e2e5714..034d1f7 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -1132,8 +1132,9 @@ bool QGraphicsScenePrivate::filterEvent(QGraphicsItem *item, QEvent *event) bool QGraphicsScenePrivate::sendEvent(QGraphicsItem *item, QEvent *event) { if (QGraphicsObject *object = item->toGraphicsObject()) { - if (qt_gestureManager) { - if (qt_gestureManager->filterEvent(object, event)) + QGestureManager *gestureManager = QApplicationPrivate::instance()->gestureManager; + if (gestureManager) { + if (gestureManager->filterEvent(object, event)) return true; } } @@ -6152,9 +6153,10 @@ void QGraphicsScenePrivate::cancelGesturesForChildren(QGesture *original, QWidge } } - Q_ASSERT(qt_gestureManager); // it would be very odd if we got called without a manager. + QGestureManager *gestureManager = QApplicationPrivate::instance()->gestureManager; + Q_ASSERT(gestureManager); // it would be very odd if we got called without a manager. for (setIter = canceledGestures.begin(); setIter != canceledGestures.end(); ++setIter) { - qt_gestureManager->recycle(*setIter); + gestureManager->recycle(*setIter); gestureTargets.remove(*setIter); } } diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 79fd3ad..12fe797 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -177,6 +177,7 @@ QApplicationPrivate::QApplicationPrivate(int &argc, char **argv, QApplication::T directPainters = 0; #endif + gestureManager = 0; gestureWidget = 0; if (!self) @@ -3632,7 +3633,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e) } // walk through parents and check for gestures - if (qt_gestureManager) { + if (d->gestureManager) { switch (e->type()) { case QEvent::Paint: case QEvent::MetaCall: @@ -3664,13 +3665,13 @@ bool QApplication::notify(QObject *receiver, QEvent *e) break; default: if (receiver->isWidgetType()) { - if (qt_gestureManager->filterEvent(static_cast<QWidget *>(receiver), e)) + if (d->gestureManager->filterEvent(static_cast<QWidget *>(receiver), e)) return true; } else { // a special case for events that go to QGesture objects. // We pass the object to the gesture manager and it'll figure // out if it's QGesture or not. - if (qt_gestureManager->filterEvent(receiver, e)) + if (d->gestureManager->filterEvent(receiver, e)) return true; } } @@ -5678,6 +5679,14 @@ Q_GUI_EXPORT void qt_translateRawTouchEvent(QWidget *window, QApplicationPrivate::translateRawTouchEvent(window, deviceType, touchPoints); } +QGestureManager* QGestureManager::instance() +{ + QApplicationPrivate *qAppPriv = QApplicationPrivate::instance(); + if (!qAppPriv->gestureManager) + qAppPriv->gestureManager = new QGestureManager(qApp); + return qAppPriv->gestureManager; +} + QT_END_NAMESPACE #include "moc_qapplication.cpp" diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index e23b5bc..f8943a8 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -84,6 +84,7 @@ class QInputContext; class QObject; class QWidget; class QSocketNotifier; +class QGestureManager; extern bool qt_is_gui_used; #ifndef QT_NO_CLIPBOARD @@ -509,6 +510,7 @@ public: void sendSyntheticEnterLeave(QWidget *widget); #endif + QGestureManager *gestureManager; QWidget *gestureWidget; QMap<int, QWeakPointer<QWidget> > widgetForTouchPointId; diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index f642938..89ad94d 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -67,15 +67,6 @@ QT_BEGIN_NAMESPACE -QGestureManager *qt_gestureManager = 0; - -QGestureManager* QGestureManager::instance() -{ - if (!qt_gestureManager) - qt_gestureManager = new QGestureManager(qApp); - return qt_gestureManager; -} - QGestureManager::QGestureManager(QObject *parent) : QObject(parent), state(NotGesture), m_lastCustomGestureId(0) { diff --git a/src/gui/kernel/qgesturemanager_p.h b/src/gui/kernel/qgesturemanager_p.h index 06dcc3e..a0ff83f 100644 --- a/src/gui/kernel/qgesturemanager_p.h +++ b/src/gui/kernel/qgesturemanager_p.h @@ -78,7 +78,7 @@ public: bool filterEvent(QGraphicsObject *receiver, QEvent *event); #endif //QT_NO_GRAPHICSVIEW - static QGestureManager* instance(); + static QGestureManager* instance(); // declared in qapplication.cpp void cleanupCachedGestures(QObject *target, Qt::GestureType type); @@ -142,8 +142,6 @@ private: void cancelGesturesForChildren(QGesture *originatingGesture); }; -extern QGestureManager *qt_gestureManager; - QT_END_NAMESPACE #endif // QGESTUREMANAGER_P_H |