summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBradley T. Hughes <bradley.hughes@nokia.com>2009-03-19 14:29:51 (GMT)
committerDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-05-11 14:51:40 (GMT)
commit05767badad6408438c6dcffa29318f681522a55a (patch)
treee1d4698739296e229ce8a445ee5393bfc28c661b /src
parent9467195595d8672c3bb1a58e1f0882ba9223f8d3 (diff)
downloadQt-05767badad6408438c6dcffa29318f681522a55a.zip
Qt-05767badad6408438c6dcffa29318f681522a55a.tar.gz
Qt-05767badad6408438c6dcffa29318f681522a55a.tar.bz2
Store the QGestureManager in QApplicationPrivate
... since we don't want these to persist after QApplication has been destroyed
Diffstat (limited to 'src')
-rw-r--r--src/gui/kernel/qapplication.cpp26
-rw-r--r--src/gui/kernel/qapplication_p.h2
-rw-r--r--src/gui/kernel/qgesturemanager.cpp4
-rw-r--r--src/gui/kernel/qgesturemanager_p.h2
4 files changed, 21 insertions, 13 deletions
diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp
index bcc25b9..d9a39c7 100644
--- a/src/gui/kernel/qapplication.cpp
+++ b/src/gui/kernel/qapplication.cpp
@@ -137,8 +137,6 @@ int QApplicationPrivate::autoMaximizeThreshold = -1;
bool QApplicationPrivate::autoSipEnabled = false;
#endif
-Q_GLOBAL_STATIC(QGestureManager, gestureManager);
-
QApplicationPrivate::QApplicationPrivate(int &argc, char **argv, QApplication::Type type)
: QCoreApplicationPrivate(argc, argv)
{
@@ -162,6 +160,8 @@ QApplicationPrivate::QApplicationPrivate(int &argc, char **argv, QApplication::T
directPainters = 0;
#endif
+ gestureManager = 0;
+
if (!self)
self = this;
}
@@ -3709,22 +3709,22 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
if (e->spontaneous()) {
if (QApplication::testAttribute(Qt::AA_EnableGestures)) {
QWidget *w = static_cast<QWidget*>(receiver);
- QGestureManager *gm = gestureManager();
// if we are in gesture mode, we send all mouse events
// directly to gesture recognizer.
- if (gm->inGestureMode()) {
- if (gm->filterEvent(e))
+ if (!d->gestureManager)
+ d->gestureManager = new QGestureManager(this);
+ if (d->gestureManager->inGestureMode()) {
+ if (d->gestureManager->filterEvent(e))
return true;
} else {
- QMouseEvent* mouse = static_cast<QMouseEvent*>(e);
if (w && (mouse->type() != QEvent::MouseMove || mouse->buttons() != 0)) {
// find the gesture target widget
QWidget *target = w;
while (target && target->d_func()->gestures.isEmpty())
target = target->parentWidget();
if (target) {
- gm->setGestureTargetWidget(target);
- if (gm->filterEvent(e))
+ d->gestureManager->setGestureTargetWidget(target);
+ if (d->gestureManager->filterEvent(e))
return true;
}
}
@@ -5095,7 +5095,10 @@ bool QApplicationPrivate::shouldSetFocus(QWidget *w, Qt::FocusPolicy policy)
*/
void QApplication::addGestureRecognizer(QGestureRecognizer *recognizer)
{
- gestureManager()->addRecognizer(recognizer);
+ Q_D(QApplication);
+ if (!d->gestureManager)
+ d->gestureManager = new QGestureManager(this);
+ d->gestureManager->addRecognizer(recognizer);
}
/*!
@@ -5105,7 +5108,10 @@ void QApplication::addGestureRecognizer(QGestureRecognizer *recognizer)
*/
void QApplication::removeGestureRecognizer(QGestureRecognizer *recognizer)
{
- gestureManager()->removeRecognizer(recognizer);
+ Q_D(QApplication);
+ if (!d->gestureManager)
+ return;
+ d->gestureManager->removeRecognizer(recognizer);
}
/*! \fn QDecoration &QApplication::qwsDecoration()
diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h
index 40cd4ae..a6cb927 100644
--- a/src/gui/kernel/qapplication_p.h
+++ b/src/gui/kernel/qapplication_p.h
@@ -80,6 +80,7 @@ class QGraphicsSystem;
class QInputContext;
class QObject;
class QWidget;
+class QGestureManager;
extern bool qt_is_gui_used;
#ifndef QT_NO_CLIPBOARD
@@ -429,6 +430,7 @@ public:
#endif
// map<gesture id -> number of grabbed widgets (something like refcount)
+ QGestureManager *gestureManager;
QMap<int, int> grabbedGestures;
static void updateTouchPointsForWidget(QWidget *widget, QTouchEvent *touchEvent);
diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp
index 0e2cea8..753d712 100644
--- a/src/gui/kernel/qgesturemanager.cpp
+++ b/src/gui/kernel/qgesturemanager.cpp
@@ -64,8 +64,8 @@ bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event);
static const unsigned int maximumGestureRecognitionTimeout = 2000;
-QGestureManager::QGestureManager()
- : targetWidget(0), state(NotGesture)
+QGestureManager::QGestureManager(QObject *parent)
+ : QObject(parent), targetWidget(0), state(NotGesture)
{
recognizers << new QDoubleTapGestureRecognizer();
recognizers << new QTapAndHoldGestureRecognizer();
diff --git a/src/gui/kernel/qgesturemanager_p.h b/src/gui/kernel/qgesturemanager_p.h
index 18eed71..2500ecf 100644
--- a/src/gui/kernel/qgesturemanager_p.h
+++ b/src/gui/kernel/qgesturemanager_p.h
@@ -67,7 +67,7 @@ class Q_GUI_EXPORT QGestureManager : public QObject
{
Q_OBJECT
public:
- QGestureManager();
+ QGestureManager(QObject *parent);
// should be internal
void setGestureTargetWidget(QWidget *widget);