QStyle: Use primary screen DPI as default DPI

Change d603ee68 made the default DPI be 96, for cases
where a style option is not provided.

This causes inconsistencies, since there are in fact
several cases where QStyle API is called without a
style option.

Restore historical Qt behavior of using the primary
screen DPI. Single-screen systems should now be consistent,
as before.

Task-number: QTBUG-82356
Change-Id: I849934ca2e5604b9fb2f045ed4f6058f3e0426ff
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
This commit is contained in:
Morten Johan Sørvig 2020-02-20 11:25:49 +01:00
parent fb6acf08bb
commit 4e1c41a26e

View File

@ -101,7 +101,13 @@ Q_WIDGETS_EXPORT qreal dpi(const QStyleOption *option)
if (option)
return option->fontMetrics.fontDpi();
// Fall back to historical Qt behavior: hardocded 72 DPI on mac,
// primary screen DPI on other platforms.
#ifdef Q_OS_DARWIN
return qstyleBaseDpi;
#else
return qt_defaultDpiX();
#endif
}
Q_WIDGETS_EXPORT qreal dpiScaled(qreal value, qreal dpi)