Make the logicalDpi() default implementation return 96

Remove the code which calculates physical DPI and
call logicalBaseDpi() instead.

This will make sure that Qt gets a device pixel ratio
of 1.0 by default, for the cases where the platform
plugin does not implement logicalDpi() itself.

Task-number: QTBUG-87035
Change-Id: I08433c9465be03d27b3decccb0e2e7e5e6aff0ae
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Morten Johan Sørvig 2020-09-30 15:26:59 +02:00 committed by Tor Arne Vestbø
parent 54232d6ea9
commit 9103d82d01

View File

@ -174,21 +174,16 @@ QSizeF QPlatformScreen::physicalSize() const
Reimplement this function in subclass to return the logical horizontal
and vertical dots per inch metrics of the screen.
The logical dots per inch metrics are used by QFont to convert point sizes
to pixel sizes.
The logical dots per inch metrics are used by Qt to scale the user interface.
The default implementation uses the screen pixel size and physical size to
compute the metrics.
The default implementation returns logicalBaseDpi(), which results in a
UI scale factor of 1.0.
\sa physicalSize
*/
QDpi QPlatformScreen::logicalDpi() const
{
QSizeF ps = physicalSize();
QSize s = geometry().size();
return QDpi(25.4 * s.width() / ps.width(),
25.4 * s.height() / ps.height());
return logicalBaseDpi();
}
// Helper function for accessing the platform screen logical dpi
@ -205,7 +200,7 @@ QPair<qreal, qreal> QPlatformScreen::overrideDpi(const QPair<qreal, qreal> &in)
default implementation returns 96.
QtGui will use this value (together with logicalDpi) to compute
the scale factor when high-DPI scaling is enabled:
the scale factor when high-DPI scaling is enabled, as follows:
factor = logicalDPI / baseDPI
*/
QDpi QPlatformScreen::logicalBaseDpi() const