summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/corelib/global/qnamespace.h2
-rw-r--r--src/corelib/global/qnamespace.qdoc2
-rw-r--r--src/gui/kernel/qgesture_p.h5
-rw-r--r--src/gui/kernel/qstandardgestures.cpp55
-rw-r--r--src/gui/kernel/qstandardgestures.h1
-rw-r--r--src/gui/kernel/qwidget.cpp2
-rw-r--r--src/gui/kernel/qwidget_win.cpp28
-rw-r--r--src/gui/widgets/qabstractscrollarea.cpp6
-rw-r--r--src/gui/widgets/qplaintextedit.cpp4
-rw-r--r--src/gui/widgets/qplaintextedit_p.h1
-rw-r--r--src/gui/widgets/qtextedit.cpp2
11 files changed, 50 insertions, 58 deletions
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index a6f5907..dd17061 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -501,6 +501,8 @@ public:
WA_WState_AcceptedTouchBeginEvent = 122,
WA_TouchPadAcceptSingleTouchEvents = 123,
+ WA_DontUseStandardGestures = 124,
+
// Add new attributes before this line
WA_AttributeCount
};
diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc
index 1a0b3e6..06eea68 100644
--- a/src/corelib/global/qnamespace.qdoc
+++ b/src/corelib/global/qnamespace.qdoc
@@ -1222,6 +1222,8 @@
\value WA_TouchPadAcceptSingleTouchEvents Allows touchpad single
touch events to be sent to the widget.
+ \value WA_DontUseStandardGestures Disables standard gestures on Qt widgets.
+
\omitvalue WA_SetLayoutDirection
\omitvalue WA_InputMethodTransparent
\omitvalue WA_WState_CompressKeys
diff --git a/src/gui/kernel/qgesture_p.h b/src/gui/kernel/qgesture_p.h
index 2cfabef..ddca79e 100644
--- a/src/gui/kernel/qgesture_p.h
+++ b/src/gui/kernel/qgesture_p.h
@@ -70,7 +70,7 @@ class QGesturePrivate : public QObjectPrivate
public:
QGesturePrivate()
: gestureTarget(0), graphicsItem(0), eventFilterProxyGraphicsItem(0),
- state(Qt::NoGesture)
+ state(Qt::NoGesture), implicitGesture(false)
{
}
@@ -81,6 +81,9 @@ public:
QGraphicsItem *eventFilterProxyGraphicsItem;
Qt::GestureState state;
+
+ // the flag specifies if the gesture was created implicitely by Qt.
+ bool implicitGesture;
};
QT_END_NAMESPACE
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;
}
diff --git a/src/gui/kernel/qstandardgestures.h b/src/gui/kernel/qstandardgestures.h
index bb6f3b6..33166fe 100644
--- a/src/gui/kernel/qstandardgestures.h
+++ b/src/gui/kernel/qstandardgestures.h
@@ -78,6 +78,7 @@ private:
bool eventFilter(QObject *receiver, QEvent *event);
friend class QWidget;
+ friend class QAbstractScrollAreaPrivate;
};
class QPinchGesturePrivate;
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index 863c43e..44f9db1 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -82,8 +82,6 @@
#include "private/qstyle_p.h"
#include "private/qinputcontext_p.h"
#include "qfileinfo.h"
-#include "qstandardgestures.h"
-#include "qstandardgestures_p.h"
#if defined (Q_WS_WIN)
# include <private/qwininputcontext_p.h>
diff --git a/src/gui/kernel/qwidget_win.cpp b/src/gui/kernel/qwidget_win.cpp
index 8e60fb3..0ec7e7e 100644
--- a/src/gui/kernel/qwidget_win.cpp
+++ b/src/gui/kernel/qwidget_win.cpp
@@ -2062,29 +2062,21 @@ void QWidgetPrivate::registerTouchWindow()
void QWidgetPrivate::winSetupGestures()
{
Q_Q(QWidget);
- if (!q)
- return;
- if (!q->isVisible())
+ if (!q || !q->isVisible())
return;
QApplicationPrivate *qAppPriv = QApplicationPrivate::instance();
- bool needh = false;
- bool needv = false;
- bool singleFingerPanEnabled = false;
QApplicationPrivate::WidgetStandardGesturesMap::const_iterator it =
qAppPriv->widgetGestures.find(q);
if (it == qAppPriv->widgetGestures.end())
return;
const QStandardGestures &gestures = it.value();
- WId winid = 0;
+ WId winid = q->effectiveWinId();
- if (QAbstractScrollArea *asa = qobject_cast<QAbstractScrollArea*>(q)) {
- winid = asa->viewport()->internalWinId();
- if (!winid) {
- QWidget *nativeParent = asa->viewport()->nativeParentWidget();
- if (!nativeParent)
- return;
- winid = nativeParent->internalWinId();
- }
+ bool needh = false;
+ bool needv = false;
+ bool singleFingerPanEnabled = false;
+
+ if (QAbstractScrollArea *asa = qobject_cast<QAbstractScrollArea*>(q->parent())) {
QScrollBar *hbar = asa->horizontalScrollBar();
QScrollBar *vbar = asa->verticalScrollBar();
Qt::ScrollBarPolicy hbarpolicy = asa->horizontalScrollBarPolicy();
@@ -2094,12 +2086,6 @@ void QWidgetPrivate::winSetupGestures()
needv = (vbarpolicy == Qt::ScrollBarAlwaysOn ||
(vbarpolicy == Qt::ScrollBarAsNeeded && vbar->minimum() < vbar->maximum()));
singleFingerPanEnabled = asa->d_func()->singleFingerPanEnabled;
- } else {
- winid = q->internalWinId();
- if (!winid) {
- if (QWidget *nativeParent = q->nativeParentWidget())
- winid = nativeParent->internalWinId();
- }
}
if (winid && qAppPriv->SetGestureConfig) {
GESTURECONFIG gc[3];
diff --git a/src/gui/widgets/qabstractscrollarea.cpp b/src/gui/widgets/qabstractscrollarea.cpp
index 770e769..6de7c10 100644
--- a/src/gui/widgets/qabstractscrollarea.cpp
+++ b/src/gui/widgets/qabstractscrollarea.cpp
@@ -54,6 +54,7 @@
#ifdef Q_WS_WIN
#include "qstandardgestures.h"
+#include <private/qstandardgestures_p.h>
#endif
#include "qabstractscrollarea_p.h"
@@ -299,8 +300,11 @@ void QAbstractScrollAreaPrivate::init()
layoutChildren();
#ifdef Q_WS_WIN
- panGesture = new QPanGesture(viewport);
+ panGesture = new QPanGesture(viewport, q);
+ panGesture->d_func()->implicitGesture = true;
+ QObject::connect(panGesture, SIGNAL(started()), q, SLOT(_q_gestureTriggered()));
QObject::connect(panGesture, SIGNAL(triggered()), q, SLOT(_q_gestureTriggered()));
+ QObject::connect(panGesture, SIGNAL(finished()), q, SLOT(_q_gestureTriggered()));
#endif // Q_WS_WIN
}
diff --git a/src/gui/widgets/qplaintextedit.cpp b/src/gui/widgets/qplaintextedit.cpp
index c79e482..085341c 100644
--- a/src/gui/widgets/qplaintextedit.cpp
+++ b/src/gui/widgets/qplaintextedit.cpp
@@ -794,10 +794,6 @@ void QPlainTextEditPrivate::init(const QString &txt)
viewport->setCursor(Qt::IBeamCursor);
#endif
originalOffsetY = 0;
-#ifdef Q_WS_WIN
- panGesture = new QPanGesture(q);
- QObject::connect(panGesture, SIGNAL(triggered()), q, SLOT(_q_gestureTriggered()));
-#endif
}
void QPlainTextEditPrivate::_q_repaintContents(const QRectF &contentsRect)
diff --git a/src/gui/widgets/qplaintextedit_p.h b/src/gui/widgets/qplaintextedit_p.h
index 7ff0c03..cda1d92 100644
--- a/src/gui/widgets/qplaintextedit_p.h
+++ b/src/gui/widgets/qplaintextedit_p.h
@@ -182,7 +182,6 @@ public:
#ifdef Q_WS_WIN
void _q_gestureTriggered();
- QPanGesture *panGesture;
#endif
};
diff --git a/src/gui/widgets/qtextedit.cpp b/src/gui/widgets/qtextedit.cpp
index 547a4fb..cc79464 100644
--- a/src/gui/widgets/qtextedit.cpp
+++ b/src/gui/widgets/qtextedit.cpp
@@ -67,8 +67,6 @@
#include <qtexttable.h>
#include <qvariant.h>
-#include <qstandardgestures.h>
-
#include <qinputcontext.h>
#endif