summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qstandardgestures.cpp
diff options
context:
space:
mode:
authorDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-09-01 09:10:53 (GMT)
committerDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-09-03 09:30:54 (GMT)
commita1a0ea71d8861e2b794f2f9b55447d50fc520de3 (patch)
tree4501c80ddb47c3dbe9526c16f8ede26716054a54 /src/gui/kernel/qstandardgestures.cpp
parent0d5b6dccf5fa854632e61971364629b36e0d3857 (diff)
downloadQt-a1a0ea71d8861e2b794f2f9b55447d50fc520de3.zip
Qt-a1a0ea71d8861e2b794f2f9b55447d50fc520de3.tar.gz
Qt-a1a0ea71d8861e2b794f2f9b55447d50fc520de3.tar.bz2
Improved the gesture api.
Added a new widget attribute Qt::WA_DontUseStandardGestures that disables all implicit gestures (i.e. gestures that are automatically enabled by Qt itself). This change also changes the way gestures are handled on QAbstractScrollArea-based widgets on Windows - the gestures are supposed to be created on the viewport widget. Reviewed-by: Bradley T. Hughes
Diffstat (limited to 'src/gui/kernel/qstandardgestures.cpp')
-rw-r--r--src/gui/kernel/qstandardgestures.cpp55
1 files changed, 29 insertions, 26 deletions
diff --git a/src/gui/kernel/qstandardgestures.cpp b/src/gui/kernel/qstandardgestures.cpp
index 4e0c27f..f6534d1 100644
--- a/src/gui/kernel/qstandardgestures.cpp
+++ b/src/gui/kernel/qstandardgestures.cpp
@@ -87,22 +87,15 @@ QPanGesture::QPanGesture(QWidget *gestureTarget, QObject *parent)
setObjectName(QLatin1String("QPanGesture"));
}
-/*!
- \internal
- An internal constructor to mark the gesture implicitely created by Qt.
-*/
-QPanGesture::QPanGesture(QWidget *gestureTarget, QObject *parent, void*)
- : QGesture(*new QPanGesturePrivate, gestureTarget, parent)
-{
- setObjectName(QLatin1String("QPanGesture"));
-}
-
void QPanGesturePrivate::setupGestureTarget(QObject *newGestureTarget)
{
Q_Q(QPanGesture);
+ QApplicationPrivate *qAppPriv = QApplicationPrivate::instance();
+
if (gestureTarget && gestureTarget->isWidgetType()) {
QWidget *w = static_cast<QWidget*>(gestureTarget.data());
- QApplicationPrivate::instance()->widgetGestures[w].pan = 0;
+ if (qAppPriv->widgetGestures[w].pan == q)
+ qAppPriv->widgetGestures[w].pan = 0;
#if defined(Q_WS_WIN)
qt_widget_private(w)->winSetupGestures();
#elif defined(Q_WS_MAC)
@@ -113,7 +106,7 @@ void QPanGesturePrivate::setupGestureTarget(QObject *newGestureTarget)
if (newGestureTarget && newGestureTarget->isWidgetType()) {
QWidget *w = static_cast<QWidget*>(newGestureTarget);
- QApplicationPrivate::instance()->widgetGestures[w].pan = q;
+ qAppPriv->widgetGestures[w].pan = q;
#if defined(Q_WS_WIN)
qt_widget_private(w)->winSetupGestures();
#elif defined(Q_WS_MAC)
@@ -143,8 +136,13 @@ bool QPanGesture::event(QEvent *event)
bool QPanGesture::eventFilter(QObject *receiver, QEvent *event)
{
-#ifdef Q_WS_WIN
Q_D(QPanGesture);
+
+ if (d->implicitGesture && d->gestureTarget && d->gestureTarget->isWidgetType() &&
+ static_cast<QWidget*>(d->gestureTarget.data())->testAttribute(Qt::WA_DontUseStandardGestures))
+ return false;
+
+#ifdef Q_WS_WIN
if (receiver->isWidgetType() && event->type() == QEvent::NativeGesture) {
QNativeGestureEvent *ev = static_cast<QNativeGestureEvent*>(event);
QApplicationPrivate *qAppPriv = QApplicationPrivate::instance();
@@ -191,8 +189,13 @@ bool QPanGesture::eventFilter(QObject *receiver, QEvent *event)
/*! \internal */
bool QPanGesture::filterEvent(QEvent *event)
{
-#if defined(Q_WS_WIN)
Q_D(QPanGesture);
+
+ if (d->implicitGesture && d->gestureTarget && d->gestureTarget->isWidgetType() &&
+ static_cast<QWidget*>(d->gestureTarget.data())->testAttribute(Qt::WA_DontUseStandardGestures))
+ return false;
+
+#if defined(Q_WS_WIN)
const QTouchEvent *ev = static_cast<const QTouchEvent*>(event);
if (event->type() == QEvent::TouchBegin) {
@@ -229,7 +232,6 @@ bool QPanGesture::filterEvent(QEvent *event)
#elif defined(QT_MAC_USE_COCOA)
// The following implements single touch
// panning on Mac:
- Q_D(QPanGesture);
const int panBeginDelay = 300;
const int panBeginRadius = 3;
const QTouchEvent *ev = static_cast<const QTouchEvent*>(event);
@@ -341,16 +343,6 @@ QPinchGesture::QPinchGesture(QWidget *gestureTarget, QObject *parent)
setObjectName(QLatin1String("QPinchGesture"));
}
-/*!
- \internal
- An internal constructor to mark the gesture implicitely created by Qt.
-*/
-QPinchGesture::QPinchGesture(QWidget *gestureTarget, QObject *parent, void*)
- : QGesture(*new QPinchGesturePrivate, gestureTarget, parent)
-{
- setObjectName(QLatin1String("QPinchGesture"));
-}
-
void QPinchGesturePrivate::setupGestureTarget(QObject *newGestureTarget)
{
Q_Q(QPinchGesture);
@@ -380,8 +372,13 @@ bool QPinchGesture::event(QEvent *event)
bool QPinchGesture::eventFilter(QObject *receiver, QEvent *event)
{
-#if defined(Q_WS_WIN) || defined(Q_WS_MAC)
Q_D(QPinchGesture);
+
+ if (d->implicitGesture && d->gestureTarget && d->gestureTarget->isWidgetType() &&
+ static_cast<QWidget*>(d->gestureTarget.data())->testAttribute(Qt::WA_DontUseStandardGestures))
+ return false;
+
+#if defined(Q_WS_WIN) || defined(Q_WS_MAC)
if (receiver->isWidgetType() && event->type() == QEvent::NativeGesture) {
QNativeGestureEvent *ev = static_cast<QNativeGestureEvent*>(event);
#if defined(Q_WS_WIN)
@@ -458,6 +455,12 @@ bool QPinchGesture::eventFilter(QObject *receiver, QEvent *event)
/*! \internal */
bool QPinchGesture::filterEvent(QEvent *event)
{
+ Q_D(QPinchGesture);
+
+ if (d->implicitGesture && d->gestureTarget && d->gestureTarget->isWidgetType() &&
+ static_cast<QWidget*>(d->gestureTarget.data())->testAttribute(Qt::WA_DontUseStandardGestures))
+ return false;
+
Q_UNUSED(event);
return false;
}