summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMorten Sorvig <msorvig@trolltech.com>2009-09-03 10:19:11 (GMT)
committerMorten Sorvig <msorvig@trolltech.com>2009-09-03 10:19:11 (GMT)
commit75078d7b20155ba192b88ec54008e07d1ee44676 (patch)
treee170f474aaed28d2476dc2d134f3be27e76c3741 /src
parent0dcf114697309f3f23f9717b608fa2be1813fe94 (diff)
parentf55a2e6b2b3d97e74c3368552a6fba412d86e0b9 (diff)
downloadQt-75078d7b20155ba192b88ec54008e07d1ee44676.zip
Qt-75078d7b20155ba192b88ec54008e07d1ee44676.tar.gz
Qt-75078d7b20155ba192b88ec54008e07d1ee44676.tar.bz2
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/qt into 4.6
Diffstat (limited to 'src')
-rw-r--r--src/corelib/global/qnamespace.h2
-rw-r--r--src/corelib/global/qnamespace.qdoc2
-rw-r--r--src/corelib/io/qfsfileengine_win.cpp8
-rw-r--r--src/gui/kernel/qgesture.cpp7
-rw-r--r--src/gui/kernel/qgesture_p.h5
-rw-r--r--src/gui/kernel/qstandardgestures.cpp204
-rw-r--r--src/gui/kernel/qstandardgestures.h28
-rw-r--r--src/gui/kernel/qstandardgestures_p.h18
-rw-r--r--src/gui/kernel/qwidget.cpp2
-rw-r--r--src/gui/kernel/qwidget_win.cpp28
-rw-r--r--src/gui/painting/qpainter.cpp68
-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
-rw-r--r--src/script/api/qscriptstring.cpp1
16 files changed, 276 insertions, 110 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/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp
index 5ff0716..a5ed95c 100644
--- a/src/corelib/io/qfsfileengine_win.cpp
+++ b/src/corelib/io/qfsfileengine_win.cpp
@@ -89,7 +89,8 @@ typedef INT_PTR intptr_t;
# define INVALID_FILE_ATTRIBUTES (DWORD (-1))
#endif
-#if !defined(REPARSE_DATA_BUFFER_HEADER_SIZE) && !defined(Q_OS_WINCE)
+#if !defined(Q_OS_WINCE)
+# if !defined(REPARSE_DATA_BUFFER_HEADER_SIZE)
typedef struct _REPARSE_DATA_BUFFER {
ULONG ReparseTag;
USHORT ReparseDataLength;
@@ -115,8 +116,9 @@ typedef struct _REPARSE_DATA_BUFFER {
} GenericReparseBuffer;
};
} REPARSE_DATA_BUFFER, *PREPARSE_DATA_BUFFER;
+# define REPARSE_DATA_BUFFER_HEADER_SIZE FIELD_OFFSET(REPARSE_DATA_BUFFER, GenericReparseBuffer)
+# endif // !defined(REPARSE_DATA_BUFFER_HEADER_SIZE)
-# define REPARSE_DATA_BUFFER_HEADER_SIZE FIELD_OFFSET(REPARSE_DATA_BUFFER, GenericReparseBuffer)
# ifndef MAXIMUM_REPARSE_DATA_BUFFER_SIZE
# define MAXIMUM_REPARSE_DATA_BUFFER_SIZE 16384
# endif
@@ -126,7 +128,7 @@ typedef struct _REPARSE_DATA_BUFFER {
# ifndef FSCTL_GET_REPARSE_POINT
# define FSCTL_GET_REPARSE_POINT CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 42, METHOD_BUFFERED, FILE_ANY_ACCESS)
# endif
-#endif
+#endif // !defined(Q_OS_WINCE)
QT_BEGIN_NAMESPACE
diff --git a/src/gui/kernel/qgesture.cpp b/src/gui/kernel/qgesture.cpp
index bd37f68..7831893 100644
--- a/src/gui/kernel/qgesture.cpp
+++ b/src/gui/kernel/qgesture.cpp
@@ -241,15 +241,18 @@ void QGesture::updateState(Qt::GestureState state)
return;
}
const Qt::GestureState oldState = d->state;
- d->state = state;
if (state != Qt::NoGesture && oldState > state) {
// comparing the state as ints: state should only be changed from
// started to (optionally) updated and to finished.
+ d->state = state;
qWarning("QGesture::updateState: incorrect new state");
return;
}
- if (oldState == Qt::NoGesture)
+ if (oldState == Qt::NoGesture) {
+ d->state = Qt::GestureStarted;
emit started();
+ }
+ d->state = state;
if (state == Qt::GestureUpdated)
emit triggered();
else if (state == Qt::GestureFinished)
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 cc30049..8e76715 100644
--- a/src/gui/kernel/qstandardgestures.cpp
+++ b/src/gui/kernel/qstandardgestures.cpp
@@ -47,6 +47,7 @@
#include <private/qapplication_p.h>
#include <private/qevent_p.h>
#include <private/qwidget_p.h>
+#include <qmath.h>
QT_BEGIN_NAMESPACE
@@ -90,9 +91,12 @@ QPanGesture::QPanGesture(QWidget *gestureTarget, QObject *parent)
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)
@@ -103,7 +107,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)
@@ -133,8 +137,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();
@@ -164,11 +173,12 @@ bool QPanGesture::eventFilter(QObject *receiver, QEvent *event)
return false;
}
if (state() == Qt::NoGesture) {
- d->lastOffset = d->totalOffset = QSize();
+ d->lastOffset = d->totalOffset = d->offset = QSize();
} else {
- d->lastOffset = QSize(ev->position.x() - d->lastPosition.x(),
- ev->position.y() - d->lastPosition.y());
- d->totalOffset += d->lastOffset;
+ d->lastOffset = d->offset;
+ d->offset = QSize(ev->position.x() - d->lastPosition.x(),
+ ev->position.y() - d->lastPosition.y());
+ d->totalOffset += d->offset;
}
d->lastPosition = ev->position;
updateState(nextState);
@@ -181,23 +191,29 @@ 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) {
QTouchEvent::TouchPoint p = ev->touchPoints().at(0);
d->lastPosition = p.pos().toPoint();
- d->lastOffset = d->totalOffset = QSize();
+ d->lastOffset = d->totalOffset = d->offset = QSize();
} else if (event->type() == QEvent::TouchEnd) {
if (state() != Qt::NoGesture) {
if (ev->touchPoints().size() == 2) {
QTouchEvent::TouchPoint p1 = ev->touchPoints().at(0);
QTouchEvent::TouchPoint p2 = ev->touchPoints().at(1);
- d->lastOffset =
+ d->lastOffset = d->offset;
+ d->offset =
QSize(p1.pos().x() - p1.lastPos().x() + p2.pos().x() - p2.lastPos().x(),
p1.pos().y() - p1.lastPos().y() + p2.pos().y() - p2.lastPos().y()) / 2;
- d->totalOffset += d->lastOffset;
+ d->totalOffset += d->offset;
}
updateState(Qt::GestureFinished);
}
@@ -206,10 +222,11 @@ bool QPanGesture::filterEvent(QEvent *event)
if (ev->touchPoints().size() == 2) {
QTouchEvent::TouchPoint p1 = ev->touchPoints().at(0);
QTouchEvent::TouchPoint p2 = ev->touchPoints().at(1);
- d->lastOffset =
+ d->lastOffset = d->offset;
+ d->offset =
QSize(p1.pos().x() - p1.lastPos().x() + p2.pos().x() - p2.lastPos().x(),
p1.pos().y() - p1.lastPos().y() + p2.pos().y() - p2.lastPos().y()) / 2;
- d->totalOffset += d->lastOffset;
+ d->totalOffset += d->offset;
if (d->totalOffset.width() > 10 || d->totalOffset.height() > 10 ||
d->totalOffset.width() < -10 || d->totalOffset.height() < -10) {
updateState(Qt::GestureUpdated);
@@ -219,7 +236,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);
@@ -252,8 +268,9 @@ bool QPanGesture::filterEvent(QEvent *event)
QPointF mousePos = QCursor::pos();
QPointF dist = mousePos - d->lastPosition;
d->lastPosition = mousePos;
- d->lastOffset = QSizeF(dist.x(), dist.y());
- d->totalOffset += d->lastOffset;
+ d->lastOffset = d->offset;
+ d->offset = QSizeF(dist.x(), dist.y());
+ d->totalOffset += d->offset;
updateState(Qt::GestureUpdated);
}
} else if (state() == Qt::NoGesture) {
@@ -273,7 +290,7 @@ bool QPanGesture::filterEvent(QEvent *event)
void QPanGesture::reset()
{
Q_D(QPanGesture);
- d->lastOffset = d->totalOffset = QSize(0, 0);
+ d->lastOffset = d->totalOffset = d->offset = QSize(0, 0);
d->lastPosition = QPoint(0, 0);
#if defined(QT_MAC_USE_COCOA)
@@ -298,8 +315,7 @@ QSizeF QPanGesture::totalOffset() const
/*!
\property QPanGesture::lastOffset
- Specifies a pan offset since the last time the gesture was
- triggered.
+ Specifies a pan offset the last time the gesture was triggered.
*/
QSizeF QPanGesture::lastOffset() const
{
@@ -307,6 +323,18 @@ QSizeF QPanGesture::lastOffset() const
return d->lastOffset;
}
+/*!
+ \property QPanGesture::offset
+
+ Specifies the current pan offset since the last time the gesture was
+ triggered.
+*/
+QSizeF QPanGesture::offset() const
+{
+ Q_D(const QPanGesture);
+ return d->offset;
+}
+
//////////////////////////////////////////////////////////////////////////////
/*!
@@ -360,8 +388,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)
@@ -380,39 +413,80 @@ bool QPinchGesture::eventFilter(QObject *receiver, QEvent *event)
// next we might receive the first gesture update event, so we
// prepare for it.
d->state = Qt::NoGesture;
- d->scaleFactor = d->lastScaleFactor = 1;
- d->rotationAngle = d->lastRotationAngle = 0;
+ d->changes = 0;
+ d->totalScaleFactor = d->scaleFactor = d->lastScaleFactor = 1.;
+ d->totalRotationAngle = d->rotationAngle = d->lastRotationAngle = 0.;
d->startCenterPoint = d->centerPoint = d->lastCenterPoint = QPointF();
#if defined(Q_WS_WIN)
d->initialDistance = 0;
+ d->lastSequenceId = ev->sequenceId;
#endif
return false;
- case QNativeGestureEvent::Rotate:
- d->scaleFactor = 0;
+ case QNativeGestureEvent::Rotate: {
+ d->lastScaleFactor = d->scaleFactor;
d->lastRotationAngle = d->rotationAngle;
-#if defined(Q_WS_WIN)
- d->rotationAngle = -1 * GID_ROTATE_ANGLE_FROM_ARGUMENT(ev->argument);
-#elif defined(Q_WS_MAC)
- d->rotationAngle = ev->percentage;
-#endif
+#if defined(Q_WS_MAC)
+ d->rotationAngle += ev->percentage;
nextState = Qt::GestureUpdated;
+#elif defined(Q_WS_WIN)
+ // This is a workaround for an issue with the native rotation
+ // gesture on Windows 7. For some reason the rotation angle in the
+ // first WM_GESTURE message in a sequence contains value that is
+ // off a little bit and causes the rotating item to "jump", so
+ // we just ignore the first WM_GESTURE in every sequence.
+ bool windowsRotateWorkaround = false;
+ if (!d->lastSequenceId) {
+ windowsRotateWorkaround = true;
+ d->lastSequenceId = ev->sequenceId;
+ }
+ if (d->lastSequenceId > 0 && d->lastSequenceId != (ulong)-1 && ev->sequenceId != d->lastSequenceId) {
+ // this is the first WM_GESTURE message in a sequence.
+ d->totalRotationAngle += d->rotationAngle;
+ windowsRotateWorkaround = true;
+ // a magic value to mark that the next WM_GESTURE message is
+ // the second message in a sequence and we should clear the
+ // lastRotationAngle
+ d->lastSequenceId = (ulong)-1;
+ }
+ if (!windowsRotateWorkaround) {
+ d->rotationAngle = -1 * GID_ROTATE_ANGLE_FROM_ARGUMENT(ev->argument) * 180. / M_PI;
+ if (d->lastSequenceId == (ulong)-1) {
+ // a special case since we need to set the lastRotationAngle to
+ // rotationAngle when the first WM_GESTURE is received in each
+ // sequence.
+ d->lastRotationAngle = d->rotationAngle;
+ }
+ d->lastSequenceId = ev->sequenceId;
+ }
+ if (!windowsRotateWorkaround)
+ nextState = Qt::GestureUpdated;
+#endif
+ d->changes = QPinchGesture::RotationAngleChanged;
event->accept();
break;
+ }
case QNativeGestureEvent::Zoom:
- d->rotationAngle = 0;
+ d->lastRotationAngle = d->rotationAngle;
+ d->lastScaleFactor = d->scaleFactor;
#if defined(Q_WS_WIN)
if (d->initialDistance != 0) {
- d->lastScaleFactor = d->scaleFactor;
int distance = int(qint64(ev->argument));
- d->scaleFactor = (qreal) distance / d->initialDistance;
+ if (d->lastSequenceId && ev->sequenceId != d->lastSequenceId) {
+ d->totalScaleFactor *= d->scaleFactor;
+ d->initialDistance = int(qint64(ev->argument));
+ d->lastScaleFactor = d->scaleFactor = (qreal) distance / d->initialDistance;
+ } else {
+ d->scaleFactor = (qreal) distance / d->initialDistance;
+ }
+ d->lastSequenceId = ev->sequenceId;
} else {
d->initialDistance = int(qint64(ev->argument));
}
#elif defined(Q_WS_MAC)
- d->lastScaleFactor = d->scaleFactor;
- d->scaleFactor = ev->percentage;
+ d->scaleFactor += ev->percentage;
#endif
nextState = Qt::GestureUpdated;
+ d->changes = QPinchGesture::ScaleFactorChanged;
event->accept();
break;
case QNativeGestureEvent::GestureEnd:
@@ -427,6 +501,8 @@ bool QPinchGesture::eventFilter(QObject *receiver, QEvent *event)
d->startCenterPoint = d->centerPoint;
d->lastCenterPoint = d->centerPoint;
d->centerPoint = static_cast<QWidget*>(receiver)->mapFromGlobal(ev->position);
+ if (d->lastCenterPoint != d->centerPoint)
+ d->changes |= QPinchGesture::CenterPointChanged;
updateState(nextState);
return true;
}
@@ -438,6 +514,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;
}
@@ -446,16 +528,44 @@ bool QPinchGesture::filterEvent(QEvent *event)
void QPinchGesture::reset()
{
Q_D(QPinchGesture);
- d->scaleFactor = d->lastScaleFactor = 0;
- d->rotationAngle = d->lastRotationAngle = 0;
+ d->changes = 0;
+ d->totalScaleFactor = d->scaleFactor = d->lastScaleFactor = 1.;
+ d->totalRotationAngle = d->rotationAngle = d->lastRotationAngle = 0.;
d->startCenterPoint = d->centerPoint = d->lastCenterPoint = QPointF();
QGesture::reset();
}
/*!
+ \property QPinchGesture::whatChanged
+
+ Specifies which values were changed in the gesture.
+*/
+QPinchGesture::WhatChanged QPinchGesture::whatChanged() const
+{
+ return d_func()->changes;
+}
+
+/*!
+ \property QPinchGesture::totalScaleFactor
+
+ Specifies a total scale factor of the pinch gesture since the gesture
+ started.
+*/
+qreal QPinchGesture::totalScaleFactor() const
+{
+ Q_D(const QPinchGesture);
+ return d->totalScaleFactor * d->scaleFactor;
+}
+
+/*!
\property QPinchGesture::scaleFactor
Specifies a scale factor of the pinch gesture.
+
+ If the gesture consists of several pinch sequences (i.e. zoom and rotate
+ sequences), then this property specifies the scale factor in the current
+ sequence. When pinching changes the rotation angle only, the value of this
+ property is 1.
*/
qreal QPinchGesture::scaleFactor() const
{
@@ -473,9 +583,29 @@ qreal QPinchGesture::lastScaleFactor() const
}
/*!
+ \property QPinchGesture::totalRotationAngle
+
+ Specifies a total rotation angle of the gesture since the gesture started.
+
+ The angle is specified in degrees.
+*/
+qreal QPinchGesture::totalRotationAngle() const
+{
+ Q_D(const QPinchGesture);
+ return d->totalRotationAngle + d->rotationAngle;
+}
+
+/*!
\property QPinchGesture::rotationAngle
Specifies a rotation angle of the gesture.
+
+ If the gesture consists of several pinch sequences (i.e. zoom and rotate
+ sequences), then this property specifies the rotation angle in the current
+ sequence. When pinching changes the scale factor only, the value of this
+ property is 0.
+
+ The angle is specified in degrees.
*/
qreal QPinchGesture::rotationAngle() const
{
@@ -486,6 +616,8 @@ qreal QPinchGesture::rotationAngle() const
\property QPinchGesture::lastRotationAngle
Specifies a previous rotation angle of the gesture.
+
+ The angle is specified in degrees.
*/
qreal QPinchGesture::lastRotationAngle() const
{
diff --git a/src/gui/kernel/qstandardgestures.h b/src/gui/kernel/qstandardgestures.h
index bb6f3b6..53c4416 100644
--- a/src/gui/kernel/qstandardgestures.h
+++ b/src/gui/kernel/qstandardgestures.h
@@ -61,6 +61,7 @@ class Q_GUI_EXPORT QPanGesture : public QGesture
Q_PROPERTY(QSizeF totalOffset READ totalOffset)
Q_PROPERTY(QSizeF lastOffset READ lastOffset)
+ Q_PROPERTY(QSizeF offset READ offset)
public:
QPanGesture(QWidget *gestureTarget, QObject *parent = 0);
@@ -69,6 +70,7 @@ public:
QSizeF totalOffset() const;
QSizeF lastOffset() const;
+ QSizeF offset() const;
protected:
void reset();
@@ -78,6 +80,7 @@ private:
bool eventFilter(QObject *receiver, QEvent *event);
friend class QWidget;
+ friend class QAbstractScrollAreaPrivate;
};
class QPinchGesturePrivate;
@@ -86,31 +89,48 @@ class Q_GUI_EXPORT QPinchGesture : public QGesture
Q_OBJECT
Q_DECLARE_PRIVATE(QPinchGesture)
- Q_PROPERTY(qreal scaleFactor READ scaleFactor)
+public:
+ enum WhatChange {
+ ScaleFactorChanged = 0x1,
+ RotationAngleChanged = 0x2,
+ CenterPointChanged = 0x4
+ };
+ Q_DECLARE_FLAGS(WhatChanged, WhatChange)
+
+ Q_PROPERTY(WhatChanged whatChanged READ whatChanged)
+
+ Q_PROPERTY(qreal totalScaleFactor READ totalScaleFactor)
Q_PROPERTY(qreal lastScaleFactor READ lastScaleFactor)
+ Q_PROPERTY(qreal scaleFactor READ scaleFactor)
- Q_PROPERTY(qreal rotationAngle READ rotationAngle)
+ Q_PROPERTY(qreal totalRotationAngle READ totalRotationAngle)
Q_PROPERTY(qreal lastRotationAngle READ lastRotationAngle)
+ Q_PROPERTY(qreal rotationAngle READ rotationAngle)
Q_PROPERTY(QPointF startCenterPoint READ startCenterPoint)
Q_PROPERTY(QPointF lastCenterPoint READ lastCenterPoint)
Q_PROPERTY(QPointF centerPoint READ centerPoint)
public:
+
QPinchGesture(QWidget *gestureTarget, QObject *parent = 0);
bool filterEvent(QEvent *event);
void reset();
+ WhatChanged whatChanged() const;
+
QPointF startCenterPoint() const;
QPointF lastCenterPoint() const;
QPointF centerPoint() const;
- qreal scaleFactor() const;
+ qreal totalScaleFactor() const;
qreal lastScaleFactor() const;
+ qreal scaleFactor() const;
- qreal rotationAngle() const;
+ qreal totalRotationAngle() const;
qreal lastRotationAngle() const;
+ qreal rotationAngle() const;
private:
bool event(QEvent *event);
diff --git a/src/gui/kernel/qstandardgestures_p.h b/src/gui/kernel/qstandardgestures_p.h
index 270f307..354ebee 100644
--- a/src/gui/kernel/qstandardgestures_p.h
+++ b/src/gui/kernel/qstandardgestures_p.h
@@ -74,6 +74,7 @@ public:
QSizeF totalOffset;
QSizeF lastOffset;
+ QSizeF offset;
QPointF lastPosition;
#if defined(QT_MAC_USE_COCOA)
@@ -88,25 +89,32 @@ class QPinchGesturePrivate : public QGesturePrivate
public:
QPinchGesturePrivate()
- : scaleFactor(0), lastScaleFactor(0),
- rotationAngle(0), lastRotationAngle(0)
+ : changes(0), totalScaleFactor(0.), lastScaleFactor(0.), scaleFactor(0.),
+ totalRotationAngle(0.), lastRotationAngle(0.), rotationAngle(0.)
#ifdef Q_WS_WIN
- ,initialDistance(0)
+ ,initialDistance(0), lastSequenceId(0)
#endif
{
}
void setupGestureTarget(QObject *o);
- qreal scaleFactor;
+ QPinchGesture::WhatChanged changes;
+
+ qreal totalScaleFactor; // total scale factor, excluding the current sequence.
qreal lastScaleFactor;
- qreal rotationAngle;
+ qreal scaleFactor; // scale factor in the current sequence.
+
+ qreal totalRotationAngle; // total rotation angle, excluding the current sequence.
qreal lastRotationAngle;
+ qreal rotationAngle; // rotation angle in the current sequence.
+
QPointF startCenterPoint;
QPointF lastCenterPoint;
QPointF centerPoint;
#ifdef Q_WS_WIN
int initialDistance;
+ ulong lastSequenceId;
#endif
};
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/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index d82e7ee..ed400df 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -7542,9 +7542,10 @@ void qt_format_text(const QFont &fnt, const QRectF &_r,
if (!painter)
tf |= Qt::TextDontPrint;
- uint maxUnderlines = 0;
+ int maxUnderlines = 0;
int numUnderlines = 0;
- QVarLengthArray<int, 32> underlinePositions(1);
+ int underlinePositionStack[32];
+ int *underlinePositions = underlinePositionStack;
QFontMetricsF fm(fnt);
QString text = str;
@@ -7553,46 +7554,54 @@ start_lengthVariant:
bool hasMoreLengthVariants = false;
// compatible behaviour to the old implementation. Replace
// tabs by spaces
+ QChar *chr = text.data() + offset;
+ QChar *end = text.data() + text.length();
bool has_tab = false;
- int old_offset = offset;
- for (; offset < text.length(); offset++) {
- QChar chr = text.at(offset);
- if (chr == QLatin1Char('\r') || (singleline && chr == QLatin1Char('\n'))) {
- text[offset] = QLatin1Char(' ');
- } else if (chr == QLatin1Char('\n')) {
- chr = QChar::LineSeparator;
- } else if (chr == QLatin1Char('&')) {
+ while (chr != end) {
+ if (*chr == QLatin1Char('\r') || (singleline && *chr == QLatin1Char('\n'))) {
+ *chr = QLatin1Char(' ');
+ } else if (*chr == QLatin1Char('\n')) {
+ *chr = QChar::LineSeparator;
+ } else if (*chr == QLatin1Char('&')) {
++maxUnderlines;
- } else if (chr == QLatin1Char('\t')) {
- if (!expandtabs) {
- text[offset] = QLatin1Char(' ');
- } else if (!tabarraylen && !tabstops) {
- tabstops = qRound(fm.width(QLatin1Char('x'))*8);
- }
+ } else if (*chr == QLatin1Char('\t')) {
has_tab = true;
- } else if (chr == QChar(ushort(0x9c))) {
+ } else if (*chr == QChar(ushort(0x9c))) {
// string with multiple length variants
+ end = chr;
hasMoreLengthVariants = true;
break;
}
+ ++chr;
+ }
+ if (has_tab) {
+ if (!expandtabs) {
+ chr = text.data() + offset;
+ while (chr != end) {
+ if (*chr == QLatin1Char('\t'))
+ *chr = QLatin1Char(' ');
+ ++chr;
+ }
+ } else if (!tabarraylen && !tabstops) {
+ tabstops = qRound(fm.width(QLatin1Char('x'))*8);
+ }
}
- int length = offset - old_offset;
- if ((hidemnmemonic || showmnemonic) && maxUnderlines > 0) {
- underlinePositions.resize(maxUnderlines + 1);
-
- QChar *cout = text.data() + old_offset;
+ QChar *cout = end;
+ if (hidemnmemonic || showmnemonic) {
+ if (maxUnderlines > 32)
+ underlinePositions = new int[maxUnderlines];
+ cout = text.data() + offset;
QChar *cin = cout;
- int l = length;
+ int l = end - cout;
while (l) {
if (*cin == QLatin1Char('&')) {
++cin;
- --length;
--l;
if (!l)
break;
if (*cin != QLatin1Char('&') && !hidemnmemonic)
- underlinePositions[numUnderlines++] = cout - text.data() - old_offset;
+ underlinePositions[numUnderlines++] = cout - text.unicode();
}
*cout = *cin;
++cout;
@@ -7609,7 +7618,7 @@ start_lengthVariant:
qreal height = 0;
qreal width = 0;
- QString finalText = text.mid(old_offset, length);
+ QString finalText = text.mid(offset, cout - (text.data() + offset));
QStackTextEngine engine(finalText, fnt);
if (option) {
engine.option = *option;
@@ -7628,7 +7637,7 @@ start_lengthVariant:
engine.forceJustification = true;
QTextLayout textLayout(&engine);
textLayout.setCacheEnabled(true);
- textLayout.engine()->underlinePositions = underlinePositions.data();
+ textLayout.engine()->underlinePositions = underlinePositions;
if (finalText.isEmpty()) {
height = fm.height();
@@ -7697,7 +7706,7 @@ start_lengthVariant:
QRectF bounds = QRectF(r.x() + xoff, r.y() + yoff, width, height);
if (hasMoreLengthVariants && !(tf & Qt::TextLongestVariant) && !r.contains(bounds)) {
- offset++;
+ offset = end - text.data() + 1;
goto start_lengthVariant;
}
if (brect)
@@ -7726,6 +7735,9 @@ start_lengthVariant:
painter->restore();
}
}
+
+ if (underlinePositions != underlinePositionStack)
+ delete [] underlinePositions;
}
/*!
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
diff --git a/src/script/api/qscriptstring.cpp b/src/script/api/qscriptstring.cpp
index 8c818e1..94b69b9 100644
--- a/src/script/api/qscriptstring.cpp
+++ b/src/script/api/qscriptstring.cpp
@@ -39,6 +39,7 @@
**
****************************************************************************/
+#include "config.h" // compile on Windows
#include "qscriptstring.h"
#include "qscriptstring_p.h"
#include "qscriptengine.h"