Update defaults for QPaintDevice

A few values have meaningful defaults, for the rest only warn about
implemented metric.

Pick-to: 6.8
Change-Id: I80c6c8dba6c8d2715daac0463a411bc5117f0bc0
Reviewed-by: David Faure <david.faure@kdab.com>
(cherry picked from commit da1fbf6053c07df76a4d2518103bdfc40d59cfa8)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Allan Sandfeld Jensen 2025-01-27 15:14:20 +01:00 committed by Qt Cherry-pick Bot
parent 89ee514a27
commit a69fdf6410

View File

@ -85,24 +85,36 @@ int QPaintDevice::metric(PaintDeviceMetric m) const
// have implemented PdmDevicePixelRatio. // have implemented PdmDevicePixelRatio.
if (m == PdmDevicePixelRatioScaled) if (m == PdmDevicePixelRatioScaled)
return this->metric(PdmDevicePixelRatio) * devicePixelRatioFScale(); return this->metric(PdmDevicePixelRatio) * devicePixelRatioFScale();
if (m == PdmNumColors)
return 0;
if (m == PdmDevicePixelRatio)
return 1;
qWarning("QPaintDevice::metrics: Device has no metric information"); qWarning("QPaintDevice::metrics: Device has no metric information");
if (m == PdmDpiX) { switch (m) {
case PdmDevicePixelRatioScaled:
case PdmDevicePixelRatio:
case PdmNumColors:
Q_UNREACHABLE();
break;
case PdmDpiX:
case PdmDpiY:
return 72; return 72;
} else if (m == PdmDpiY) { case PdmDevicePixelRatioF_EncodedA:
return 72; case PdmDevicePixelRatioF_EncodedB:
} else if (m == PdmNumColors) {
// FIXME: does this need to be a real value?
return 256;
} else if (m == PdmDevicePixelRatio) {
return 1;
} else if (m == PdmDevicePixelRatioF_EncodedA || m == PdmDevicePixelRatioF_EncodedB) {
return 0; return 0;
} else { case PdmWidth:
qDebug("Unrecognised metric %d!",m); case PdmHeight:
case PdmWidthMM:
case PdmHeightMM:
case PdmDepth:
case PdmPhysicalDpiX:
case PdmPhysicalDpiY:
return 0; return 0;
} }
qDebug("Unrecognized metric %d!", m);
return 0;
} }
QT_END_NAMESPACE QT_END_NAMESPACE