diff options
author | Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> | 2015-03-04 16:48:44 +0100 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> | 2015-03-04 16:49:00 +0100 |
commit | 38b5e9f8ba7686152fe5199f2a40c013e6a322e0 (patch) | |
tree | 8986796a85dfc338698bce617fb33aac3af475f8 /src | |
parent | c0a5e8c9d77aefd6c403af39908e56414a921522 (diff) | |
parent | 8ac63a3323585de28428df3f376bdf3f3c2a67fb (diff) |
Merge remote-tracking branch 'origin/5.5' into dev
Change-Id: Idd21ab419588ee8b893649e3227d41c46a32e519
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/doc/snippets/code/doc_src_properties.cpp | 2 | ||||
-rw-r--r-- | src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp | 17 | ||||
-rw-r--r-- | src/corelib/doc/src/objectmodel/properties.qdoc | 10 | ||||
-rw-r--r-- | src/corelib/global/qnamespace.h | 1 | ||||
-rw-r--r-- | src/corelib/kernel/qobject.cpp | 67 | ||||
-rw-r--r-- | src/gui/image/qimage_conversions.cpp | 117 | ||||
-rw-r--r-- | src/gui/image/qjpeghandler.cpp | 18 | ||||
-rw-r--r-- | src/gui/kernel/qevent.cpp | 120 | ||||
-rw-r--r-- | src/gui/painting/qbezier.cpp | 4 | ||||
-rw-r--r-- | src/widgets/kernel/qstandardgestures.cpp | 10 |
10 files changed, 218 insertions, 148 deletions
diff --git a/src/corelib/doc/snippets/code/doc_src_properties.cpp b/src/corelib/doc/snippets/code/doc_src_properties.cpp index d07c7cb947..8978d1a067 100644 --- a/src/corelib/doc/snippets/code/doc_src_properties.cpp +++ b/src/corelib/doc/snippets/code/doc_src_properties.cpp @@ -93,13 +93,13 @@ class MyClass : public QObject { Q_OBJECT Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY priorityChanged) - Q_ENUMS(Priority) public: MyClass(QObject *parent = 0); ~MyClass(); enum Priority { High, Low, VeryHigh, VeryLow }; + Q_ENUM(Priority) void setPriority(Priority priority) { diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp b/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp index 0bf67fce31..b0048014a4 100644 --- a/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp @@ -376,38 +376,37 @@ Q_PROPERTY(QString title READ title WRITE setTitle USER true) class MyClass : public QObject { Q_OBJECT - Q_ENUMS(Priority) public: MyClass(QObject *parent = 0); ~MyClass(); enum Priority { High, Low, VeryHigh, VeryLow }; + Q_ENUM(Priority) void setPriority(Priority priority); Priority priority() const; }; //! [38] -//! [39a] +//! [39] class QLibrary : public QObject { - ... - Q_FLAGS(LoadHint LoadHints) - ... -//! [39a] + Q_OBJECT -//! [39b] - ... public: + ... + enum LoadHint { ResolveAllSymbolsHint = 0x01, ExportExternalSymbolsHint = 0x02, LoadArchiveMemberHint = 0x04 }; Q_DECLARE_FLAGS(LoadHints, LoadHint) + Q_FLAG(LoadHints) ... -//! [39b] +} +//! [39] //! [40] diff --git a/src/corelib/doc/src/objectmodel/properties.qdoc b/src/corelib/doc/src/objectmodel/properties.qdoc index 5db1410e6f..abb0720fe9 100644 --- a/src/corelib/doc/src/objectmodel/properties.qdoc +++ b/src/corelib/doc/src/objectmodel/properties.qdoc @@ -207,7 +207,7 @@ section of the class. The required \c READ function is named \c priority, and we include a \c WRITE function named \c setPriority. The enumeration type must be registered with the \l {Meta-Object - System} using the Q_ENUMS() macro. Registering an enumeration type + System} using the Q_ENUM() macro. Registering an enumeration type makes the enumerator names available for use in calls to QObject::setProperty(). We must also provide our own declarations for the \c READ and \c WRITE functions. The declaration of MyClass @@ -228,18 +228,18 @@ In the example, the enumeration type that is the property type is declared in MyClass and registered with the \l{Meta-Object System} - using the Q_ENUMS() macro. This makes the enumeration values + using the Q_ENUM() macro. This makes the enumeration values available as strings for use as in the call to \l{QObject::}{setProperty()}. Had the enumeration type been declared in another class, its fully qualified name (i.e., OtherClass::Priority) would be required, and that other class would also have to inherit QObject and register - the enumeration type there using the Q_ENUMS() macro. + the enumeration type there using the Q_ENUM() macro. - A similar macro, Q_FLAGS(), is also available. Like Q_ENUMS(), it + A similar macro, Q_FLAG(), is also available. Like Q_ENUM(), it registers an enumeration type, but it marks the type as being a set of \e flags, i.e. values that can be OR'd together. An I/O class might have enumeration values \c Read and \c Write and then - QObject::setProperty() could accept \c{Read | Write}. Q_FLAGS() + QObject::setProperty() could accept \c{Read | Write}. Q_FLAG() should be used to register this enumeration type. \section1 Dynamic Properties diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index 2cde1bae81..e115cedc51 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -1680,6 +1680,7 @@ public: QT_Q_ENUM(InputMethodQuery) QT_Q_FLAG(InputMethodHints) QT_Q_FLAG(InputMethodQueries) + QT_Q_FLAG(TouchPointStates) QT_Q_ENUM(ScreenOrientation) QT_Q_FLAG(ScreenOrientations) QT_Q_ENUM(ConnectionType) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 265cc68db5..40279cf2b3 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -4178,6 +4178,7 @@ QDebug operator<<(QDebug dbg, const QObject *o) /*! \macro Q_ENUMS(...) \relates QObject + \obsolete This macro registers one or several enum types to the meta-object system. @@ -4191,35 +4192,87 @@ QDebug operator<<(QDebug dbg, const QObject *o) defining it. In addition, the class \e defining the enum has to inherit QObject as well as declare the enum using Q_ENUMS(). + In new code, you should prefer the use of the Q_ENUM() macro, which makes the + type available also to the meta type system. + For instance, QMetaEnum::fromType() will not work with types declared with Q_ENUMS(). + \sa {Qt's Property System} */ /*! \macro Q_FLAGS(...) \relates QObject + \obsolete - This macro registers one or several \l{QFlags}{flags types} to the + This macro registers one or several \l{QFlags}{flags types} with the meta-object system. It is typically used in a class definition to declare that values of a given enum can be used as flags and combined using the bitwise OR operator. + \note This macro takes care of registering individual flag values + with the meta-object system, so it is unnecessary to use Q_ENUMS() + in addition to this macro. + + In new code, you should prefer the use of the Q_FLAG() macro, which makes the + type available also to the meta type system. + + \sa {Qt's Property System} +*/ + +/*! + \macro Q_ENUM(...) + \relates QObject + \since 5.5 + + This macro registers an enum type with the meta-object system. + It must be placed after the enum declaration in a class that has the Q_OBJECT or the + Q_GADGET macro. + + For example: + + \snippet code/src_corelib_kernel_qobject.cpp 38 + + Enumerations that are declared with Q_ENUM have their QMetaEnum registered in the + enclosing QMetaObject. You can also use QMetaEnum::fromType() to get the QMetaEnum. + + Registered enumerations are automatically registered also to the Qt meta + type system, making them known to QMetaType without the need to use + Q_DECLARE_METATYPE(). This will enable useful features; for example, if used + in a QVariant, you can convert them to strings. Likewise, passing them to + QDebug will print out their names. + + \sa {Qt's Property System} +*/ + + +/*! + \macro Q_FLAG(...) + \relates QObject + \since 5.5 + + This macro registers a single \l{QFlags}{flags types} with the + meta-object system. It is typically used in a class definition to declare + that values of a given enum can be used as flags and combined using the + bitwise OR operator. + + The macro must be placed after the enum declaration. + For example, in QLibrary, the \l{QLibrary::LoadHints}{LoadHints} flag is declared in the following way: - \snippet code/src_corelib_kernel_qobject.cpp 39a + \snippet code/src_corelib_kernel_qobject.cpp 39 The declaration of the flags themselves is performed in the public section - of the QLibrary class itself, using the \l Q_DECLARE_FLAGS() macro: + of the QLibrary class itself, using the \l Q_DECLARE_FLAGS() macro. - \snippet code/src_corelib_kernel_qobject.cpp 39b - - \note This macro takes care of registering individual flag values - with the meta-object system, so it is unnecessary to use Q_ENUMS() + \note The Q_FLAG macro takes care of registering individual flag values + with the meta-object system, so it is unnecessary to use Q_ENUM() in addition to this macro. \sa {Qt's Property System} */ + /*! \macro Q_OBJECT \relates QObject diff --git a/src/gui/image/qimage_conversions.cpp b/src/gui/image/qimage_conversions.cpp index a4c02bbbbe..5103d820d6 100644 --- a/src/gui/image/qimage_conversions.cpp +++ b/src/gui/image/qimage_conversions.cpp @@ -35,8 +35,8 @@ #include <private/qdrawingprimitive_sse2_p.h> #include <private/qguiapplication_p.h> #include <private/qsimd_p.h> - #include <private/qimage_p.h> +#include <qendian.h> QT_BEGIN_NAMESPACE @@ -290,6 +290,108 @@ static void convert_ARGB_to_ARGB_PM_sse4(QImageData *dest, const QImageData *src } #endif +Q_GUI_EXPORT void QT_FASTCALL qt_convert_rgb888_to_rgb32(quint32 *dest_data, const uchar *src_data, int len) +{ + int pixel = 0; + // prolog: align input to 32bit + while ((quintptr(src_data) & 0x3) && pixel < len) { + *dest_data = 0xff000000 | (src_data[0] << 16) | (src_data[1] << 8) | (src_data[2]); + src_data += 3; + ++dest_data; + ++pixel; + } + + // Handle 4 pixels at a time 12 bytes input to 16 bytes output. + for (; pixel + 3 < len; pixel += 4) { + const quint32 *src_packed = (quint32 *) src_data; + const quint32 src1 = qFromBigEndian(src_packed[0]); + const quint32 src2 = qFromBigEndian(src_packed[1]); + const quint32 src3 = qFromBigEndian(src_packed[2]); + + dest_data[0] = 0xff000000 | (src1 >> 8); + dest_data[1] = 0xff000000 | (src1 << 16) | (src2 >> 16); + dest_data[2] = 0xff000000 | (src2 << 8) | (src3 >> 24); + dest_data[3] = 0xff000000 | src3; + + src_data += 12; + dest_data += 4; + } + + // epilog: handle left over pixels + for (; pixel < len; ++pixel) { + *dest_data = 0xff000000 | (src_data[0] << 16) | (src_data[1] << 8) | (src_data[2]); + src_data += 3; + ++dest_data; + } +} + +Q_GUI_EXPORT void QT_FASTCALL qt_convert_rgb888_to_rgbx8888(quint32 *dest_data, const uchar *src_data, int len) +{ + int pixel = 0; + // prolog: align input to 32bit + while ((quintptr(src_data) & 0x3) && pixel < len) { + *dest_data = ARGB2RGBA(0xff000000 | (src_data[0] << 16) | (src_data[1] << 8) | (src_data[2])); + src_data += 3; + ++dest_data; + ++pixel; + } + + // Handle 4 pixels at a time 12 bytes input to 16 bytes output. + for (; pixel + 3 < len; pixel += 4) { + const quint32 *src_packed = (quint32 *) src_data; + const quint32 src1 = src_packed[0]; + const quint32 src2 = src_packed[1]; + const quint32 src3 = src_packed[2]; + +#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN + dest_data[0] = 0xff000000 | src1; + dest_data[1] = 0xff000000 | (src1 >> 24) | (src2 << 8); + dest_data[2] = 0xff000000 | (src2 >> 16) | (src3 << 16); + dest_data[3] = 0xff000000 | (src3 >> 8); +#else + dest_data[0] = 0xff | src1; + dest_data[1] = 0xff | (src1 << 24) | (src2 >> 8); + dest_data[2] = 0xff | (src2 << 16) | (src3 >> 16); + dest_data[3] = 0xff | (src3 << 8); +#endif + + src_data += 12; + dest_data += 4; + } + + // epilog: handle left over pixels + for (; pixel < len; ++pixel) { + *dest_data = ARGB2RGBA(0xff000000 | (src_data[0] << 16) | (src_data[1] << 8) | (src_data[2])); + src_data += 3; + ++dest_data; + } +} + +typedef void (QT_FASTCALL *Rgb888ToRgbConverter)(quint32 *dst, const uchar *src, int len); + +template <bool rgbx> +static void convert_RGB888_to_RGB(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags) +{ + Q_ASSERT(src->format == QImage::Format_RGB888); + if (rgbx) + Q_ASSERT(dest->format == QImage::Format_RGBX8888 || dest->format == QImage::Format_RGBA8888 || dest->format == QImage::Format_RGBA8888_Premultiplied); + else + Q_ASSERT(dest->format == QImage::Format_RGB32 || dest->format == QImage::Format_ARGB32 || dest->format == QImage::Format_ARGB32_Premultiplied); + Q_ASSERT(src->width == dest->width); + Q_ASSERT(src->height == dest->height); + + const uchar *src_data = (uchar *) src->data; + quint32 *dest_data = (quint32 *) dest->data; + + Rgb888ToRgbConverter line_converter= rgbx ? qt_convert_rgb888_to_rgbx8888 : qt_convert_rgb888_to_rgb32; + + for (int i = 0; i < src->height; ++i) { + line_converter(dest_data, src_data, src->width); + src_data += src->bytes_per_line; + dest_data = (quint32 *)((uchar*)dest_data + dest->bytes_per_line); + } +} + extern bool convert_ARGB_to_ARGB_PM_inplace_sse2(QImageData *data, Qt::ImageConversionFlags); static void convert_ARGB_to_RGBx(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags) @@ -2052,6 +2154,9 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat 0, 0, 0, + convert_RGB888_to_RGB<false>, + convert_RGB888_to_RGB<false>, + convert_RGB888_to_RGB<false>, 0, 0, 0, @@ -2061,12 +2166,10 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat 0, 0, 0, - 0, - 0, - 0, - 0, - 0, - 0, 0, 0, 0, 0, 0, 0 + convert_RGB888_to_RGB<true>, + convert_RGB888_to_RGB<true>, + convert_RGB888_to_RGB<true>, + 0, 0, 0, 0, 0, 0 }, // Format_RGB888 { diff --git a/src/gui/image/qjpeghandler.cpp b/src/gui/image/qjpeghandler.cpp index 13ac59ec26..b1146c4297 100644 --- a/src/gui/image/qjpeghandler.cpp +++ b/src/gui/image/qjpeghandler.cpp @@ -69,18 +69,10 @@ extern "C" { QT_BEGIN_NAMESPACE -void QT_FASTCALL convert_rgb888_to_rgb32_C(quint32 *dst, const uchar *src, int len) -{ - // Expand 24->32 bpp. - for (int i = 0; i < len; ++i) { - *dst++ = qRgb(src[0], src[1], src[2]); - src += 3; - } -} - +Q_GUI_EXPORT void QT_FASTCALL qt_convert_rgb888_to_rgb32(quint32 *dst, const uchar *src, int len); typedef void (QT_FASTCALL *Rgb888ToRgb32Converter)(quint32 *dst, const uchar *src, int len); -static Rgb888ToRgb32Converter rgb888ToRgb32ConverterPtr = convert_rgb888_to_rgb32_C; +static Rgb888ToRgb32Converter rgb888ToRgb32ConverterPtr = qt_convert_rgb888_to_rgb32; struct my_error_mgr : public jpeg_error_mgr { jmp_buf setjmp_buffer; @@ -1008,10 +1000,8 @@ QJpegHandler::QJpegHandler() #endif #if defined(QT_COMPILER_SUPPORTS_SSSE3) - // from qimage_ssse3.cpp - - if (false) { - } else if (qCpuHasFeature(SSSE3)) { + // from qimage_ssse3.cpps + if (qCpuHasFeature(SSSE3)) { rgb888ToRgb32ConverterPtr = qt_convert_rgb888_to_rgb32_ssse3; } #endif // QT_COMPILER_SUPPORTS_SSSE3 diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index a0b5eb80bf..2995457180 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -3461,29 +3461,9 @@ QShortcutEvent::~QShortcutEvent() #ifndef QT_NO_DEBUG_STREAM -static inline void formatTouchPoint(QDebug d, const QTouchEvent::TouchPoint &tp) +static inline void formatTouchEvent(QDebug d, const QTouchEvent &t) { - d << "TouchPoint(" << tp.id() << ' ' << tp.rect(); - switch (tp.state()) { - case Qt::TouchPointPressed: - d << " pressed"; - break; - case Qt::TouchPointReleased: - d << " released"; - break; - case Qt::TouchPointMoved: - d << " moved"; - break; - case Qt::TouchPointStationary: - d << " stationary"; - break; - } - d << ')'; -} - -static inline void formatTouchEvent(QDebug d, const char *name, const QTouchEvent &t) -{ - d << "QTouchEvent(" << name << " states: " << t.touchPointStates(); + d << "QTouchEvent(" << t.type() << " states: " << t.touchPointStates(); d << ", " << t.touchPoints().size() << " points: " << t.touchPoints() << ')'; } @@ -3542,14 +3522,6 @@ static inline void formatInputMethodQueryEvent(QDebug d, const QInputMethodQuery d << "})"; } -static const char *eventTypeName(QEvent::Type t) -{ - static const int enumIdx = QEvent::staticMetaObject.indexOfEnumerator("Type"); - return t <= QEvent::User - ? QEvent::staticMetaObject.enumerator(enumIdx).valueToKey(t) - : "User"; -} - static const char *eventClassName(QEvent::Type t) { switch (t) { @@ -3667,54 +3639,6 @@ static const char *eventClassName(QEvent::Type t) return "QEvent"; } -namespace { -// Make protected QObject::staticQtMetaObject accessible for formatting enums. -class DebugHelper : public QObject { -public: - static const char *mouseButtonToString(Qt::MouseButton button) - { - static const int enumIdx = QObject::staticQtMetaObject.indexOfEnumerator("MouseButtons"); - return QObject::staticQtMetaObject.enumerator(enumIdx).valueToKey(button); - } - - static QByteArray mouseButtonsToString(Qt::MouseButtons buttons) - { - QByteArray result; - for (int i = 0; (uint)(1 << i) <= Qt::MaxMouseButton; ++i) { - const Qt::MouseButton button = static_cast<Qt::MouseButton>(1 << i); - if (buttons.testFlag(button)) { - if (!result.isEmpty()) - result.append('|'); - result.append(mouseButtonToString(button)); - } - } - if (result.isEmpty()) - result.append("NoButton"); - return result; - } - - static const char *mouseEventSourceToString(Qt::MouseEventSource source) - { - static const int enumIdx = QObject::staticQtMetaObject.indexOfEnumerator("MouseEventSource"); - return QObject::staticQtMetaObject.enumerator(enumIdx).valueToKey(source); - } - - static const char *focusReasonToString(Qt::FocusReason reason) - { - static const int enumIdx = QObject::staticQtMetaObject.indexOfEnumerator("FocusReason"); - return QObject::staticQtMetaObject.enumerator(enumIdx).valueToKey(reason); - } - -# ifndef QT_NO_GESTURES - static const char *nativeGestureTypeToString(Qt::NativeGestureType type) - { - static const int enumIdx = QObject::staticQtMetaObject.indexOfEnumerator("NativeGestureType"); - return QObject::staticQtMetaObject.enumerator(enumIdx).valueToKey(type); - } -# endif // !QT_NO_GESTURES -}; -} // namespace - # ifndef QT_NO_DRAGANDDROP static void formatDropEvent(QDebug d, const QDropEvent *e) @@ -3728,7 +3652,7 @@ static void formatDropEvent(QDebug d, const QDropEvent *e) d << ", formats=" << e->mimeData()->formats(); if (const Qt::KeyboardModifiers mods = e->keyboardModifiers()) d << ", keyboardModifiers=" << mods; - d << ", " << DebugHelper::mouseButtonsToString(e->mouseButtons()).constData(); + d << ", " << e->mouseButtons(); } # endif // !QT_NO_DRAGANDDROP @@ -3739,20 +3663,15 @@ static void formatTabletEvent(QDebug d, const QTabletEvent *e) { const QEvent::Type type = e->type(); - static const int deviceEnumIdx = QTabletEvent::staticMetaObject.indexOfEnumerator("TabletDevice"); - static const int pointerTypeEnumIdx = QTabletEvent::staticMetaObject.indexOfEnumerator("PointerType"); - const char* device = QTabletEvent::staticMetaObject.enumerator(deviceEnumIdx).valueToKey(e->device()); - const char* pointerType = QTabletEvent::staticMetaObject.enumerator(pointerTypeEnumIdx).valueToKey(e->pointerType()); - - d << eventClassName(type) << '(' << eventTypeName(type) - << ", device=" << device - << ", pointerType=" << pointerType + d << eventClassName(type) << '(' << type + << ", device=" << e->device() + << ", pointerType=" << e->pointerType() << ", uniqueId=" << e->uniqueId() << ", pos=" << e->posF() << ", z=" << e->z() << ", xTilt=" << e->xTilt() << ", yTilt=" << e->yTilt() - << ", " << DebugHelper::mouseButtonsToString(e->buttons()).constData(); + << ", " << e->buttons(); if (type == QEvent::TabletPress || type == QEvent::TabletMove) d << ", pressure=" << e->pressure(); if (e->device() == QTabletEvent::RotationStylus || e->device() == QTabletEvent::FourDMouse) @@ -3766,8 +3685,7 @@ static void formatTabletEvent(QDebug d, const QTabletEvent *e) QDebug operator<<(QDebug dbg, const QTouchEvent::TouchPoint &tp) { QDebugStateSaver saver(dbg); - dbg.nospace(); - formatTouchPoint(dbg, tp); + dbg.nospace() << "TouchPoint(" << tp.id() << ' ' << tp.rect() << ' ' << tp.state() << " vel " << tp.velocity() << ')'; return dbg; } @@ -3797,16 +3715,16 @@ QDebug operator<<(QDebug dbg, const QEvent *e) const QMouseEvent *me = static_cast<const QMouseEvent*>(e); const Qt::MouseButton button = me->button(); const Qt::MouseButtons buttons = me->buttons(); - dbg << "QMouseEvent(" << eventTypeName(type); + dbg << "QMouseEvent(" << type; if (type != QEvent::MouseMove && type != QEvent::NonClientAreaMouseMove) - dbg << ", " << DebugHelper::mouseButtonToString(button); + dbg << ", " << button; if (buttons && button != buttons) - dbg << ", buttons=" << DebugHelper::mouseButtonsToString(buttons).constData(); + dbg << ", buttons=" << buttons; if (const int mods = int(me->modifiers())) dbg << ", modifiers=0x" << hex << mods << dec; dbg << ", localPos=" << me->localPos() << ", screenPos=" << me->screenPos(); if (me->source()) - dbg << ", " << DebugHelper::mouseEventSourceToString(me->source()); + dbg << ", " << me->source(); if (const Qt::MouseEventFlags flags = me->flags()) dbg << ", flags = " << hex << int(flags) << dec; dbg << ')'; @@ -3824,7 +3742,7 @@ QDebug operator<<(QDebug dbg, const QEvent *e) case QEvent::ShortcutOverride: { const QKeyEvent *ke = static_cast<const QKeyEvent *>(e); - dbg << "QKeyEvent(" << eventTypeName(type) + dbg << "QKeyEvent(" << type << ", key=0x" << hex << ke->key() << dec; if (const int mods = ke->modifiers()) dbg << ", modifiers=0x" << hex << mods << dec; @@ -3846,9 +3764,7 @@ QDebug operator<<(QDebug dbg, const QEvent *e) case QEvent::FocusAboutToChange: case QEvent::FocusIn: case QEvent::FocusOut: - dbg << "QFocusEvent(" << eventTypeName(type) << ", " - << DebugHelper::focusReasonToString(static_cast<const QFocusEvent *>(e)->reason()) - << ')'; + dbg << "QFocusEvent(" << type << ", " << static_cast<const QFocusEvent *>(e)->reason() << ')'; break; case QEvent::Move: { const QMoveEvent *me = static_cast<const QMoveEvent *>(e); @@ -3882,17 +3798,17 @@ QDebug operator<<(QDebug dbg, const QEvent *e) case QEvent::TouchBegin: case QEvent::TouchUpdate: case QEvent::TouchEnd: - formatTouchEvent(dbg, eventTypeName(type), *static_cast<const QTouchEvent*>(e)); + formatTouchEvent(dbg, *static_cast<const QTouchEvent*>(e)); break; case QEvent::ChildAdded: case QEvent::ChildPolished: case QEvent::ChildRemoved: - dbg << "QChildEvent(" << eventTypeName(type) << ", " << (static_cast<const QChildEvent*>(e))->child() << ')'; + dbg << "QChildEvent(" << type << ", " << (static_cast<const QChildEvent*>(e))->child() << ')'; break; # ifndef QT_NO_GESTURES case QEvent::NativeGesture: { const QNativeGestureEvent *ne = static_cast<const QNativeGestureEvent *>(e); - dbg << "QNativeGestureEvent(" << DebugHelper::nativeGestureTypeToString(ne->gestureType()) + dbg << "QNativeGestureEvent(" << ne->gestureType() << "localPos=" << ne->localPos() << ", value=" << ne->value() << ')'; } break; @@ -3932,7 +3848,7 @@ QDebug operator<<(QDebug dbg, const QEvent *e) dbg << ')'; break; default: - dbg << eventClassName(type) << '(' << eventTypeName(type) << ", " + dbg << eventClassName(type) << '(' << type << ", " << (const void *)e << ", type = " << e->type() << ')'; break; } diff --git a/src/gui/painting/qbezier.cpp b/src/gui/painting/qbezier.cpp index e5c9e8d773..8e0e76f787 100644 --- a/src/gui/painting/qbezier.cpp +++ b/src/gui/painting/qbezier.cpp @@ -401,8 +401,8 @@ int QBezier::shifted(QBezier *curveSegments, int maxSegments, qreal offset, floa Q_ASSERT(curveSegments); Q_ASSERT(maxSegments > 0); - if (x1 == x2 && x1 == x3 && x1 == x4 && - y1 == y2 && y1 == y3 && y1 == y4) + if (qFuzzyCompare(x1, x2) && qFuzzyCompare(x1, x3) && qFuzzyCompare(x1, x4) && + qFuzzyCompare(y1, y2) && qFuzzyCompare(y1, y3) && qFuzzyCompare(y1, y4)) return 0; --maxSegments; diff --git a/src/widgets/kernel/qstandardgestures.cpp b/src/widgets/kernel/qstandardgestures.cpp index cf9ac52de3..d19e473d18 100644 --- a/src/widgets/kernel/qstandardgestures.cpp +++ b/src/widgets/kernel/qstandardgestures.cpp @@ -44,6 +44,11 @@ QT_BEGIN_NAMESPACE +// If the change in scale for a single touch event is out of this range, +// we consider it to be spurious. +static const qreal kSingleStepScaleMax = 2.0; +static const qreal kSingleStepScaleMin = 0.1; + QGesture *QPanGestureRecognizer::create(QObject *target) { if (target && target->isWidgetType()) { @@ -197,7 +202,10 @@ QGestureRecognizer::Result QPinchGestureRecognizer::recognize(QGesture *state, d->lastScaleFactor = d->scaleFactor; QLineF line(p1.screenPos(), p2.screenPos()); QLineF lastLine(p1.lastScreenPos(), p2.lastScreenPos()); - d->scaleFactor = line.length() / lastLine.length(); + qreal newScaleFactor = line.length() / lastLine.length(); + if (newScaleFactor > kSingleStepScaleMax || newScaleFactor < kSingleStepScaleMin) + return QGestureRecognizer::Ignore; + d->scaleFactor = newScaleFactor; } d->totalScaleFactor = d->totalScaleFactor * d->scaleFactor; d->changeFlags |= QPinchGesture::ScaleFactorChanged; |