diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-11-02 15:55:30 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-11-09 23:24:58 +0100 |
commit | 650b436635a8723a671862e311ff3484c5ea4666 (patch) | |
tree | 2a8d494538c044e475a00b1e4b72e87b6f9135d1 /src/gui/kernel/qevent.cpp | |
parent | d8a2ffcea2df1335b4d5c65586d6658a6ddf8588 (diff) |
Improve QPointerEvent qDebug operators
Use the property=value format consistently for the QPointerEvent types.
Abbreviate property names for compactness, but show more info.
Omit device seatName(), pointerType(), capabilities(), maximumPoints()
and uniqueId() when they are uninteresting. In the case of uniqueId()
it's uninteresting when it's not valid (-1) rather than when it's 0.
Add QMouseEvent::scenePosition().
Change-Id: Ia076c5958e8f7032929517401d332b07d2fd0e78
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/gui/kernel/qevent.cpp')
-rw-r--r-- | src/gui/kernel/qevent.cpp | 60 |
1 files changed, 34 insertions, 26 deletions
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 5e9643d82f..52f348a16f 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -3905,23 +3905,23 @@ static void formatTabletEvent(QDebug d, const QTabletEvent *e) d << eventClassName(type) << '('; QtDebugUtils::formatQEnum(d, type); - d << ", deviceType="; + d << " deviceType="; QtDebugUtils::formatQEnum(d, e->deviceType()); - d << ", pointerType="; + d << " pointerType="; QtDebugUtils::formatQEnum(d, e->pointerType()); - d << ", uniqueId=" << e->pointingDevice()->uniqueId().numericId() - << ", pos=" << e->position() - << ", z=" << e->z() - << ", xTilt=" << e->xTilt() - << ", yTilt=" << e->yTilt() - << ", "; + d << " uniqueId=" << e->pointingDevice()->uniqueId().numericId() + << " pos=" << e->position() + << " z=" << e->z() + << " xTilt=" << e->xTilt() + << " yTilt=" << e->yTilt() + << " "; QtDebugUtils::formatQFlags(d, e->buttons()); if (type == QEvent::TabletPress || type == QEvent::TabletMove) - d << ", pressure=" << e->pressure(); + d << " pressure=" << e->pressure(); if (e->device()->hasCapability(QInputDevice::Capability::Rotation)) - d << ", rotation=" << e->rotation(); + d << " rotation=" << e->rotation(); if (e->deviceType() == QInputDevice::DeviceType::Airbrush) - d << ", tangentialPressure=" << e->tangentialPressure(); + d << " tangentialPressure=" << e->tangentialPressure(); } # endif // QT_CONFIG(tabletevent) @@ -3939,23 +3939,29 @@ QDebug operator<<(QDebug dbg, const QEventPoint &tp) { QDebugStateSaver saver(dbg); dbg.nospace(); - dbg << "QEventPoint(" << tp.id() << " ts " << tp.timestamp() << " ("; + dbg << "QEventPoint(id=" << tp.id() << " ts=" << tp.timestamp(); + dbg << " pos="; QtDebugUtils::formatQPoint(dbg, tp.position()); - dbg << " scene "; + dbg << " scn="; QtDebugUtils::formatQPoint(dbg, tp.scenePosition()); - dbg << " global "; + dbg << " gbl="; QtDebugUtils::formatQPoint(dbg, tp.globalPosition()); - dbg << ") "; + dbg << ' '; QtDebugUtils::formatQEnum(dbg, tp.state()); - dbg << " pressure " << tp.pressure() << " ellipse (" - << tp.ellipseDiameters().width() << " x " << tp.ellipseDiameters().height() - << " angle " << tp.rotation() << ") vel ("; + if (!qFuzzyIsNull(tp.pressure()) && !qFuzzyCompare(tp.pressure(), 1)) + dbg << " pressure=" << tp.pressure(); + if (!tp.ellipseDiameters().isEmpty() || !qFuzzyIsNull(tp.rotation())) { + dbg << " ellipse=(" + << tp.ellipseDiameters().width() << "x" << tp.ellipseDiameters().height() + << " \u2221 " << tp.rotation() << ')'; + } + dbg << " vel="; QtDebugUtils::formatQPoint(dbg, tp.velocity().toPointF()); - dbg << ") start ("; + dbg << " press="; QtDebugUtils::formatQPoint(dbg, tp.pressPosition()); - dbg << ") last ("; + dbg << " last="; QtDebugUtils::formatQPoint(dbg, tp.lastPosition()); - dbg << ") delta ("; + dbg << " \u0394 "; QtDebugUtils::formatQPoint(dbg, tp.position() - tp.lastPosition()); dbg << ')'; return dbg; @@ -3996,19 +4002,21 @@ QT_WARNING_POP dbg << "QMouseEvent("; QtDebugUtils::formatQEnum(dbg, type); if (type != QEvent::MouseMove && type != QEvent::NonClientAreaMouseMove) { - dbg << ", "; + dbg << ' '; QtDebugUtils::formatQEnum(dbg, button); } if (buttons && button != buttons) { - dbg << ", buttons="; + dbg << " btns="; QtDebugUtils::formatQFlags(dbg, buttons); } QtDebugUtils::formatNonNullQFlags(dbg, ", ", me->modifiers()); - dbg << ", pos="; + dbg << " pos="; QtDebugUtils::formatQPoint(dbg, me->position()); - dbg << ", globalPos="; + dbg << " scn="; + QtDebugUtils::formatQPoint(dbg, me->scenePosition()); + dbg << " gbl="; QtDebugUtils::formatQPoint(dbg, me->globalPosition()); - dbg << ", dev=" << me->device() << ')'; + dbg << " dev=" << me->device() << ')'; } break; # if QT_CONFIG(wheelevent) |