From dd6080ceac38c84581c89c77eb0d7d8285b55c94 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Thu, 21 Aug 2014 15:30:41 +0200 Subject: [PATCH] Debug logging support for QNativeGestureEvent The most useful information is what kind of gesture the event represents, but it was missing until now. Also added a line of documentation about the NativeGesture event type. Change-Id: I1ba3c951dcc5751e937d762d9b647ab0bf8d93b8 Reviewed-by: Allan Sandfeld Jensen --- src/corelib/global/qnamespace.h | 1 + src/corelib/kernel/qcoreevent.cpp | 1 + src/gui/kernel/qevent.cpp | 9 ++++++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index 485193b071..0da868602c 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -98,6 +98,7 @@ Qt { #ifndef QT_NO_GESTURES Q_ENUMS(GestureState) Q_ENUMS(GestureType) + Q_ENUMS(NativeGestureType) #endif Q_ENUMS(CursorMoveStyle) Q_ENUMS(TimerType) diff --git a/src/corelib/kernel/qcoreevent.cpp b/src/corelib/kernel/qcoreevent.cpp index 8d5a39115a..bc54a2ae74 100644 --- a/src/corelib/kernel/qcoreevent.cpp +++ b/src/corelib/kernel/qcoreevent.cpp @@ -184,6 +184,7 @@ QT_BEGIN_NAMESPACE \value MouseMove Mouse move (QMouseEvent). \value MouseTrackingChange The mouse tracking state has changed. \value Move Widget's position changed (QMoveEvent). + \value NativeGesture The system has detected a gesture (QNativeGestureEvent). \value OrientationChange The screens orientation has changes (QScreenOrientationChangeEvent) \value Paint Screen update necessary (QPaintEvent). \value PaletteChange Palette of the widget changed. diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 1b853411f8..29f9c35356 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -3595,6 +3595,12 @@ public: static const int enumIdx = QObject::staticQtMetaObject.indexOfEnumerator("FocusReason"); return QObject::staticQtMetaObject.enumerator(enumIdx).valueToKey(reason); } + + static const char *nativeGestureTypeToString(Qt::NativeGestureType type) + { + static const int enumIdx = QObject::staticQtMetaObject.indexOfEnumerator("NativeGestureType"); + return QObject::staticQtMetaObject.enumerator(enumIdx).valueToKey(type); + } }; } // namespace @@ -3775,7 +3781,8 @@ QDebug operator<<(QDebug dbg, const QEvent *e) # ifndef QT_NO_GESTURES case QEvent::NativeGesture: { const QNativeGestureEvent *ne = static_cast(e); - dbg << "QNativeGestureEvent(localPos=" << ne->localPos() << ", value=" << ne->value() << ')'; + dbg << "QNativeGestureEvent(" << DebugHelper::nativeGestureTypeToString(ne->gestureType()) + << "localPos=" << ne->localPos() << ", value=" << ne->value() << ')'; } break; # endif // !QT_NO_GESTURES