From 9103d82d0196ba12263329af7dc37eb056700ece Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Wed, 30 Sep 2020 15:26:59 +0200 Subject: [PATCH] Make the logicalDpi() default implementation return 96 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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ø --- src/gui/kernel/qplatformscreen.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/gui/kernel/qplatformscreen.cpp b/src/gui/kernel/qplatformscreen.cpp index a89d4d007b3..0920f46975a 100644 --- a/src/gui/kernel/qplatformscreen.cpp +++ b/src/gui/kernel/qplatformscreen.cpp @@ -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 QPlatformScreen::overrideDpi(const QPair &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