From bdcb1414647207cf92921431cfe49491bd06c439 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 23 Apr 2020 08:00:15 +0200 Subject: Windows: Fix wrong default font sizes after changing scaling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use the ForDpi versions of retrieving non clientMetrics. Pick-to: 5.15 Task-number: QTBUG-82267 Change-Id: I434f6980c47258bfe40d38723d3f66d71217e186 Reviewed-by: André de la Rocha Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowstheme.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp index 7f47cd712f..25e083fd5c 100644 --- a/src/plugins/platforms/windows/qwindowstheme.cpp +++ b/src/plugins/platforms/windows/qwindowstheme.cpp @@ -51,6 +51,7 @@ #if QT_CONFIG(systemtrayicon) # include "qwindowssystemtrayicon.h" #endif +#include "qwindowsscreen.h" #include "qt_windows.h" #include #include @@ -564,13 +565,32 @@ void QWindowsTheme::refresh() refreshFonts(); } +#ifndef QT_NO_DEBUG_STREAM +QDebug operator<<(QDebug d, const LOGFONT &lf); // in platformsupport + +QDebug operator<<(QDebug d, const NONCLIENTMETRICS &m) +{ + QDebugStateSaver saver(d); + d.nospace(); + d.noquote(); + d << "NONCLIENTMETRICS(iMenu=" << m.iMenuWidth << 'x' << m.iMenuHeight + << ", lfCaptionFont=" << m.lfCaptionFont << ", lfSmCaptionFont=" + << m.lfSmCaptionFont << ", lfMenuFont=" << m.lfMenuFont + << ", lfMessageFont=" << m.lfMessageFont << ", lfStatusFont=" + << m.lfStatusFont << ')'; + return d; +} +#endif // QT_NO_DEBUG_STREAM + void QWindowsTheme::refreshFonts() { clearFonts(); if (!QGuiApplication::desktopSettingsAware()) return; NONCLIENTMETRICS ncm; - QWindowsContext::nonClientMetrics(&ncm); + auto screenManager = QWindowsContext::instance()->screenManager(); + QWindowsContext::nonClientMetricsForScreen(&ncm, screenManager.screens().value(0)); + qCDebug(lcQpaWindows) << __FUNCTION__ << ncm; const QFont menuFont = QWindowsFontDatabase::LOGFONT_to_QFont(ncm.lfMenuFont); const QFont messageBoxFont = QWindowsFontDatabase::LOGFONT_to_QFont(ncm.lfMessageFont); const QFont statusFont = QWindowsFontDatabase::LOGFONT_to_QFont(ncm.lfStatusFont); -- cgit v1.2.3