summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2020-11-02 15:55:30 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2020-11-09 23:24:58 +0100
commit650b436635a8723a671862e311ff3484c5ea4666 (patch)
tree2a8d494538c044e475a00b1e4b72e87b6f9135d1
parentd8a2ffcea2df1335b4d5c65586d6658a6ddf8588 (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>
-rw-r--r--src/gui/kernel/qevent.cpp60
-rw-r--r--src/gui/kernel/qpointingdevice.cpp25
2 files changed, 50 insertions, 35 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)
diff --git a/src/gui/kernel/qpointingdevice.cpp b/src/gui/kernel/qpointingdevice.cpp
index 24ce68e430..eba17f52ee 100644
--- a/src/gui/kernel/qpointingdevice.cpp
+++ b/src/gui/kernel/qpointingdevice.cpp
@@ -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';
}