windows: make native styles support QT_SCALE_FACTOR
Calculate the native metrics scale factor using DPI from the screen instead of using devicePixelRatio from the widget. This way the native metrics scale factor becomes independent of whatever modifications QtGui applies to the DPR. This matches its use case of scaling native metrics returned by win32 API. Task-number: QTBUG-86344 Change-Id: I0d3c73956520e2bc4a56b23ea3cb8e1f0c36fcf1 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
This commit is contained in:
parent
2a34d4bc66
commit
e3201e7124
@ -373,7 +373,10 @@ static QScreen *screenOf(const QWidget *w)
|
||||
// and account for secondary screens with differing logical DPI.
|
||||
qreal QWindowsStylePrivate::nativeMetricScaleFactor(const QWidget *widget)
|
||||
{
|
||||
qreal result = qreal(1) / QWindowsStylePrivate::devicePixelRatio(widget);
|
||||
const QPlatformScreen *screen = screenOf(widget)->handle();
|
||||
const qreal scale = screen ? (screen->logicalDpi().first / screen->logicalBaseDpi().first)
|
||||
: QWindowsStylePrivate::appDevicePixelRatio();
|
||||
qreal result = qreal(1) / scale;
|
||||
if (QGuiApplicationPrivate::screen_list.size() > 1) {
|
||||
const QScreen *primaryScreen = QGuiApplication::primaryScreen();
|
||||
const QScreen *screen = screenOf(widget);
|
||||
|
Loading…
x
Reference in New Issue
Block a user