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>
bb10
Shawn Rutledge 2020-11-02 15:55:30 +01:00
parent d8a2ffcea2
commit 650b436635
2 changed files with 50 additions and 35 deletions

View File

@ -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)

View File

@ -645,16 +645,23 @@ QDebug operator<<(QDebug debug, const QPointingDevice *device)
debug.noquote();
debug << "QPointingDevice(";
if (device) {
debug << '"' << device->name() << "\", type=";
debug << '"' << device->name() << "\" ";
QtDebugUtils::formatQEnum(debug, device->type());
debug << ", id=" << Qt::hex << device->systemId() << Qt::dec << ", seat=" << device->seatName();
debug << ", pointerType=";
QtDebugUtils::formatQEnum(debug, device->pointerType());
debug << ", capabilities=";
QtDebugUtils::formatQFlags(debug, device->capabilities());
debug << ", maximumTouchPoints=" << device->maximumPoints();
if (device->uniqueId().numericId())
debug << ", uniqueId=" << Qt::hex << device->uniqueId().numericId() << Qt::dec;
debug << " id=" << Qt::hex << device->systemId() << Qt::dec;
if (!device->seatName().isEmpty())
debug << " seat=" << device->seatName();
if (device->pointerType() != QPointingDevice::PointerType::Generic) {
debug << " ptrType=";
QtDebugUtils::formatQEnum(debug, device->pointerType());
}
if (int(device->capabilities()) != int(QInputDevice::Capability::Position)) {
debug << " caps=";
QtDebugUtils::formatQFlags(debug, device->capabilities());
}
if (device->maximumPoints() > 1)
debug << " maxPts=" << device->maximumPoints();
if (device->uniqueId().isValid())
debug << " uniqueId=" << Qt::hex << device->uniqueId().numericId() << Qt::dec;
} else {
debug << '0';
}