Add debug operator for QTouchEvent::TouchPoint
dfde72e436
added debug support for
QWindowSystemInterface::TouchPoint, which is useful only near the
QPA interface; but in qtdeclarative it's useful to be able to log
individual touch points too.
Change-Id: I237d354d7018e6326e586ae3355c8aa6f781eff8
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
This commit is contained in:
parent
589894c072
commit
c1d2a04923
@ -3355,32 +3355,30 @@ QShortcutEvent::~QShortcutEvent()
|
||||
|
||||
#ifndef QT_NO_DEBUG_STREAM
|
||||
|
||||
static inline void formatTouchPoint(QDebug d, const QTouchEvent::TouchPoint &tp)
|
||||
{
|
||||
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();
|
||||
const QList<QTouchEvent::TouchPoint> points = t.touchPoints();
|
||||
const int size = points.size();
|
||||
d << ", " << size << " points: ";
|
||||
for (int i = 0; i < size; ++i) {
|
||||
if (i)
|
||||
d << ", ";
|
||||
d << points.at(i).pos() << ' ' << points.at(i).rect();
|
||||
switch (points.at(i).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 << ')';
|
||||
d << ", " << t.touchPoints().size() << " points: " << t.touchPoints() << ')';
|
||||
}
|
||||
|
||||
static void formatUnicodeString(QDebug d, const QString &s)
|
||||
@ -3647,6 +3645,14 @@ static void formatTabletEvent(QDebug d, const QTabletEvent *e)
|
||||
|
||||
# endif // !QT_NO_TABLETEVENT
|
||||
|
||||
QDebug operator<<(QDebug dbg, const QTouchEvent::TouchPoint &tp)
|
||||
{
|
||||
QDebugStateSaver saver(dbg);
|
||||
dbg.nospace();
|
||||
formatTouchPoint(dbg, tp);
|
||||
return dbg;
|
||||
}
|
||||
|
||||
QDebug operator<<(QDebug dbg, const QEvent *e)
|
||||
{
|
||||
QDebugStateSaver saver(dbg);
|
||||
|
@ -889,6 +889,10 @@ protected:
|
||||
Q_DECLARE_TYPEINFO(QTouchEvent::TouchPoint, Q_MOVABLE_TYPE);
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(QTouchEvent::TouchPoint::InfoFlags)
|
||||
|
||||
#ifndef QT_NO_DEBUG_STREAM
|
||||
Q_GUI_EXPORT QDebug operator<<(QDebug, const QTouchEvent::TouchPoint &);
|
||||
#endif
|
||||
|
||||
class Q_GUI_EXPORT QScrollPrepareEvent : public QEvent
|
||||
{
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user