Round physical dpi when calculating scale factor
(For the QT_USE_PHYSICAL_DPI use case) The physical DPI is nominally computed from the physical screen size, however when QT_USE_PHYSICAL_DPI is set that size has typically been overridden with a fake size by the user, such that the resulting DPI calculation will yield some specific integer DPI. Round this DPI value in order to arrive at a nice scale factor, e.g. 144/96 = 1.5 instead of 144.01/96 = 1.5001 Change-Id: I665394e98a818b3a8f46408f3193cac4411f458d Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
0bd705d91b
commit
ad10fd2a6f
@ -293,7 +293,7 @@ qreal QHighDpiScaling::rawScaleFactor(const QPlatformScreen *screen)
|
||||
QSize sz = screen->geometry().size();
|
||||
QSizeF psz = screen->physicalSize();
|
||||
qreal platformPhysicalDpi = ((sz.height() / psz.height()) + (sz.width() / psz.width())) * qreal(25.4 * 0.5);
|
||||
factor = qreal(platformPhysicalDpi) / qreal(platformBaseDpi.first);
|
||||
factor = qRound(platformPhysicalDpi) / qreal(platformBaseDpi.first);
|
||||
} else {
|
||||
const QDpi platformLogicalDpi = QPlatformScreen::overrideDpi(screen->logicalDpi());
|
||||
factor = qreal(platformLogicalDpi.first) / qreal(platformBaseDpi.first);
|
||||
|
Loading…
Reference in New Issue
Block a user