From b5ee908f6c83a8df0720a311adc0087530460e6c Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Mon, 28 Oct 2019 14:17:59 +0800 Subject: [PATCH] Fix screen scaling factor calculation For some users on Windows the physicalDotsPerInch() could return values that are smaller than the normal 96 DPI which leads to big dialog sizes taking the entire screen. So we need to ensure it is at least 96 DPI. Closes #11405, #11407. --- src/gui/utils.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/utils.cpp b/src/gui/utils.cpp index 7d3f68e21..6e895841e 100644 --- a/src/gui/utils.cpp +++ b/src/gui/utils.cpp @@ -52,7 +52,10 @@ qreal Utils::Gui::screenScalingFactor(const QWidget *widget) #ifdef Q_OS_WIN const int screenNumber = qApp->desktop()->screenNumber(widget); const QScreen *screen = QApplication::screens()[screenNumber]; - return (screen->logicalDotsPerInch() / screen->physicalDotsPerInch()); + // Workaround for QScreen::physicalDotsPerInch() that could return + // values that are smaller than the normal 96 DPI on Windows + const qreal physicalDPI = qMax(screen->physicalDotsPerInch(), 96); + return (screen->logicalDotsPerInch() / physicalDPI); #elif defined(Q_OS_MAC) return 1; #else