Add debug output for QGestureEvent and QGesture classes.
Task-number: QTBUG-15768 Task-number: QTBUG-40461 Change-Id: I3fe29f71ddf39c76efaca02d2b70494378d147dc Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
This commit is contained in:
parent
ed3fc4ea47
commit
bd09405792
@ -108,7 +108,7 @@ void ImageWidget::mouseDoubleClickEvent(QMouseEvent *)
|
||||
//! [gesture event handler]
|
||||
bool ImageWidget::gestureEvent(QGestureEvent *event)
|
||||
{
|
||||
qCDebug(lcExample) << "gestureEvent():" << event->gestures().size();
|
||||
qCDebug(lcExample) << "gestureEvent():" << event;
|
||||
if (QGesture *swipe = event->gesture(Qt::SwipeGesture))
|
||||
swipeTriggered(static_cast<QSwipeGesture *>(swipe));
|
||||
else if (QGesture *pan = event->gesture(Qt::PanGesture))
|
||||
@ -132,7 +132,7 @@ void ImageWidget::panTriggered(QPanGesture *gesture)
|
||||
}
|
||||
#endif
|
||||
QPointF delta = gesture->delta();
|
||||
qCDebug(lcExample) << "panTriggered():" << delta;
|
||||
qCDebug(lcExample) << "panTriggered():" << gesture;
|
||||
horizontalOffset += delta.x();
|
||||
verticalOffset += delta.y();
|
||||
update();
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "private/qstandardgestures_p.h"
|
||||
#include "qgraphicsview.h"
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
#ifndef QT_NO_GESTURES
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
@ -1124,7 +1125,81 @@ QPointF QGestureEvent::mapToGraphicsScene(const QPointF &gesturePoint) const
|
||||
|
||||
\sa QEvent::ignore()
|
||||
*/
|
||||
#endif
|
||||
#endif // Q_NO_USING_KEYWORD
|
||||
|
||||
#ifndef QT_NO_DEBUG_STREAM
|
||||
|
||||
static void formatGestureHeader(QDebug d, const char *className, const QGesture *gesture)
|
||||
{
|
||||
d << className << "(state=" << gesture->state();
|
||||
if (gesture->hasHotSpot())
|
||||
d << ",hotSpot=" << gesture->hotSpot();
|
||||
}
|
||||
|
||||
Q_WIDGETS_EXPORT QDebug operator<<(QDebug d, const QGesture *gesture)
|
||||
{
|
||||
QDebugStateSaver saver(d);
|
||||
d.nospace();
|
||||
switch (gesture->gestureType()) {
|
||||
case Qt::TapGesture:
|
||||
formatGestureHeader(d, "QTapGesture", gesture);
|
||||
d << ",position=" << static_cast<const QTapGesture*>(gesture)->position() << ')';
|
||||
break;
|
||||
case Qt::TapAndHoldGesture: {
|
||||
const QTapAndHoldGesture *tap = static_cast<const QTapAndHoldGesture*>(gesture);
|
||||
formatGestureHeader(d, "QTapAndHoldGesture", tap);
|
||||
d << ",position=" << tap->position() << ",timeout=" << tap->timeout() << ')';
|
||||
}
|
||||
break;
|
||||
case Qt::PanGesture: {
|
||||
const QPanGesture *pan = static_cast<const QPanGesture*>(gesture);
|
||||
formatGestureHeader(d, "QPanGesture", pan);
|
||||
d << ",lastOffset=" << pan->lastOffset() << ",offset=" << pan->offset()
|
||||
<< ",acceleration=" << pan->acceleration()
|
||||
<< ",delta=" << pan->delta() << ')';
|
||||
}
|
||||
break;
|
||||
case Qt::PinchGesture: {
|
||||
const QPinchGesture *pinch = static_cast<const QPinchGesture*>(gesture);
|
||||
formatGestureHeader(d, "QPinchGesture", pinch);
|
||||
d << ",totalChangeFlags=" << pinch->totalChangeFlags()
|
||||
<< ",changeFlags=" << pinch->changeFlags()
|
||||
<< ",startCenterPoint=" << pinch->startCenterPoint()
|
||||
<< ",lastCenterPoint=" << pinch->lastCenterPoint()
|
||||
<< ",centerPoint=" << pinch->centerPoint()
|
||||
<< ",totalScaleFactor=" << pinch->totalScaleFactor()
|
||||
<< ",lastScaleFactor=" << pinch->lastScaleFactor()
|
||||
<< ",scaleFactor=" << pinch->scaleFactor()
|
||||
<< ",totalRotationAngle=" << pinch->totalRotationAngle()
|
||||
<< ",lastRotationAngle=" << pinch->lastRotationAngle()
|
||||
<< ",rotationAngle=" << pinch->rotationAngle() << ')';
|
||||
}
|
||||
break;
|
||||
case Qt::SwipeGesture: {
|
||||
const QSwipeGesture *swipe = static_cast<const QSwipeGesture*>(gesture);
|
||||
formatGestureHeader(d, "QSwipeGesture", swipe);
|
||||
d << ",horizontalDirection=" << swipe->horizontalDirection()
|
||||
<< ",verticalDirection=" << swipe->verticalDirection()
|
||||
<< ",swipeAngle=" << swipe->swipeAngle() << ')';
|
||||
}
|
||||
break;
|
||||
default:
|
||||
formatGestureHeader(d, "Custom gesture", gesture);
|
||||
d << ",type=" << gesture->gestureType() << ')';
|
||||
break;
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
Q_WIDGETS_EXPORT QDebug operator<<(QDebug d, const QGestureEvent *gestureEvent)
|
||||
{
|
||||
QDebugStateSaver saver(d);
|
||||
d.nospace();
|
||||
d << "QGestureEvent(" << gestureEvent->gestures() << ')';
|
||||
return d;
|
||||
}
|
||||
|
||||
#endif // !QT_NO_DEBUG_STREAM
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
@ -315,6 +315,11 @@ private:
|
||||
friend class QGestureManager;
|
||||
};
|
||||
|
||||
# ifndef QT_NO_DEBUG_STREAM
|
||||
Q_WIDGETS_EXPORT QDebug operator<<(QDebug, const QGesture *);
|
||||
Q_WIDGETS_EXPORT QDebug operator<<(QDebug, const QGestureEvent *);
|
||||
# endif
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
Q_DECLARE_METATYPE(QGesture::GestureCancelPolicy)
|
||||
|
Loading…
x
Reference in New Issue
Block a user