diff options
author | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2009-03-06 13:42:51 (GMT) |
---|---|---|
committer | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2009-05-11 13:42:39 (GMT) |
commit | 3cad576b7ce221ca92c07a513c4c0fbe9886f8e5 (patch) | |
tree | 54d36ca587a642bb25e0473631477b51c3ad66d7 | |
parent | b231b0bcd36d531d3558cee12be263a98391b9db (diff) | |
download | Qt-3cad576b7ce221ca92c07a513c4c0fbe9886f8e5.zip Qt-3cad576b7ce221ca92c07a513c4c0fbe9886f8e5.tar.gz Qt-3cad576b7ce221ca92c07a513c4c0fbe9886f8e5.tar.bz2 |
Fixes: Add missing functions for a adding custom gesture recognizers.
-rw-r--r-- | src/gui/kernel/qapplication.cpp | 23 | ||||
-rw-r--r-- | src/gui/kernel/qapplication.h | 4 | ||||
-rw-r--r-- | src/gui/kernel/qgesturemanager.cpp | 10 | ||||
-rw-r--r-- | src/gui/kernel/qgesturemanager_p.h | 3 |
4 files changed, 33 insertions, 7 deletions
diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 88871a4..104271d 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -137,7 +137,7 @@ int QApplicationPrivate::autoMaximizeThreshold = -1; bool QApplicationPrivate::autoSipEnabled = false; #endif -QGestureManager *gestureManager = 0; +Q_GLOBAL_STATIC(QGestureManager, gestureManager); QApplicationPrivate::QApplicationPrivate(int &argc, char **argv, QApplication::Type type) : QCoreApplicationPrivate(argc, argv) @@ -3709,12 +3709,11 @@ bool QApplication::notify(QObject *receiver, QEvent *e) if (e->spontaneous()) { if (QApplication::testAttribute(Qt::AA_EnableGestures)) { QWidget *w = static_cast<QWidget*>(receiver); - if (!gestureManager) - gestureManager = new QGestureManager; + QGestureManager *gm = gestureManager(); // if we are in gesture mode, we send all mouse events // directly to gesture recognizer. - if (gestureManager->inGestureMode()) { - if (gestureManager->filterEvent(e)) + if (gm->inGestureMode()) { + if (gm->filterEvent(e)) return true; } else { QMouseEvent* mouse = static_cast<QMouseEvent*>(e); @@ -3724,8 +3723,8 @@ bool QApplication::notify(QObject *receiver, QEvent *e) while (target && target->gestures().isEmpty()) target = target->parentWidget(); if (target) { - gestureManager->setGestureTargetWidget(target); - if (gestureManager->filterEvent(e)) + gm->setGestureTargetWidget(target); + if (gm->filterEvent(e)) return true; } } @@ -5090,6 +5089,16 @@ bool QApplicationPrivate::shouldSetFocus(QWidget *w, Qt::FocusPolicy policy) return true; } +void QApplication::addGestureRecognizer(QGestureRecognizer *recognizer) +{ + gestureManager()->addRecognizer(recognizer); +} + +void QApplication::removeGestureRecognizer(QGestureRecognizer *recognizer) +{ + gestureManager()->removeRecognizer(recognizer); +} + /*! \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 634226f..70458ef 100644 --- a/src/gui/kernel/qapplication.h +++ b/src/gui/kernel/qapplication.h @@ -71,6 +71,7 @@ class QStyle; class QEventLoop; class QIcon; class QInputContext; +class QGestureRecognizer; template <typename T> class QList; class QLocale; #if defined(Q_WS_QWS) @@ -266,6 +267,9 @@ public: static bool keypadNavigationEnabled(); #endif + void addGestureRecognizer(QGestureRecognizer *recognizer); + void removeGestureRecognizer(QGestureRecognizer *recognizer); + 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 c9bf0df..7954ae9 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -83,6 +83,16 @@ QGestureManager::QGestureManager() this, SLOT(recognizerTriggered(QGestureRecognizer::Result))); } +void QGestureManager::addRecognizer(QGestureRecognizer *recognizer) +{ + recognizers << recognizer; +} + +void QGestureManager::removeRecognizer(QGestureRecognizer *recognizer) +{ + recognizers.remove(recognizer); +} + bool QGestureManager::filterEvent(QEvent *event) { if (!QApplication::testAttribute(Qt::AA_EnableGestures)) diff --git a/src/gui/kernel/qgesturemanager_p.h b/src/gui/kernel/qgesturemanager_p.h index 1079cc4..762b70d 100644 --- a/src/gui/kernel/qgesturemanager_p.h +++ b/src/gui/kernel/qgesturemanager_p.h @@ -72,6 +72,9 @@ public: // should be internal void setGestureTargetWidget(QWidget *widget); + void addRecognizer(QGestureRecognizer *recognizer); + void removeRecognizer(QGestureRecognizer *recognizer); + bool filterEvent(QEvent *event); bool inGestureMode(); |