Skip to content

Commit

Permalink
Windows: Fix wrong default font sizes after changing scaling
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Oliver Wolff <[email protected]>
  • Loading branch information
FriedemannKleint committed May 26, 2020
1 parent ec3ba72 commit bdcb141
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/plugins/platforms/windows/qwindowstheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
#if QT_CONFIG(systemtrayicon)
# include "qwindowssystemtrayicon.h"
#endif
#include "qwindowsscreen.h"
#include "qt_windows.h"
#include <commctrl.h>
#include <objbase.h>
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit bdcb141

Please sign in to comment.