From d7fea8e5d2146af4df40b136c8265287f3a8a8c5 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 4 Aug 2014 12:57:55 +0200 Subject: Improve qDebug output for QTabletEvent Change-Id: Ic2819eaa5ed0e3666062f00994b72dee0b2cba66 Reviewed-by: Friedemann Kleint --- src/gui/kernel/qevent.cpp | 23 ++++++++++++++++++++--- src/gui/kernel/qevent.h | 7 +++++++ 2 files changed, 27 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 5f009e75fa..457428f569 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -3622,10 +3622,27 @@ static void formatDropEvent(QDebug d, const QDropEvent *e) static void formatTabletEvent(QDebug d, const QTabletEvent *e) { const QEvent::Type type = e->type(); - d << eventClassName(type) << '(' << eventTypeName(type) << ", pos=" << e->posF() - << ", pointerType=" << e->pointerType() - << ", pressure=" << e->pressure() << ", rotation=" << e->rotation() + + 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 + << ", uniqueId=" << e->uniqueId() + << ", pos=" << e->posF() + << ", z=" << e->z() + << ", xTilt=" << e->xTilt() + << ", yTilt=" << e->yTilt() << ", " << DebugHelper::mouseButtonsToString(e->buttons()).constData(); + if (type == QEvent::TabletPress || type == QEvent::TabletMove) + d << ", pressure=" << e->pressure(); + if (e->device() == QTabletEvent::RotationStylus || e->device() == QTabletEvent::FourDMouse) + d << ", rotation=" << e->rotation(); + if (e->device() == QTabletEvent::Airbrush) + d << ", tangentialPressure=" << e->tangentialPressure(); } # endif // !QT_NO_TABLETEVENT diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index 346c0a4ba0..e123845f66 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -223,6 +223,9 @@ protected: #ifndef QT_NO_TABLETEVENT class Q_GUI_EXPORT QTabletEvent : public QInputEvent { + Q_GADGET + Q_ENUMS(TabletDevice) + Q_ENUMS(PointerType) public: enum TabletDevice { NoDevice, Puck, Stylus, Airbrush, FourDMouse, XFreeEraser /*internal*/, RotationStylus }; @@ -761,7 +764,11 @@ public: enum InfoFlag { Pen = 0x0001 }; +#ifndef Q_MOC_RUN + // otherwise moc gives + // Error: Meta object features not supported for nested classes Q_DECLARE_FLAGS(InfoFlags, InfoFlag) +#endif explicit TouchPoint(int id = -1); TouchPoint(const TouchPoint &other); -- cgit v1.2.3