Windows QPA: Update theme fonts when the primary screen changes

Call into the theme to update the fonts on a change. This
at least helps in the case of disabled High DPI scaling.

Task-number: QTBUG-77144
Change-Id: I2c8fd85259403eaaeea56cd096f99116fc6bba9a
Reviewed-by: André de la Rocha <andre.rocha@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
bb10
Friedemann Kleint 2019-08-14 12:25:41 +02:00
parent c53f843001
commit f6b34ce173
2 changed files with 8 additions and 1 deletions

View File

@ -42,6 +42,7 @@
#include "qwindowswindow.h"
#include "qwindowsintegration.h"
#include "qwindowscursor.h"
#include "qwindowstheme.h"
#include <QtCore/qt_windows.h>
@ -547,10 +548,13 @@ bool QWindowsScreenManager::handleScreenChanges()
// Look for changed monitors, add new ones
const WindowsScreenDataList newDataList = monitorData();
const bool lockScreen = newDataList.size() == 1 && (newDataList.front().flags & QWindowsScreenData::LockScreen);
bool primaryScreenChanged = false;
for (const QWindowsScreenData &newData : newDataList) {
const int existingIndex = indexOfMonitor(m_screens, newData.name);
if (existingIndex != -1) {
m_screens.at(existingIndex)->handleChanges(newData);
if (existingIndex == 0)
primaryScreenChanged = true;
} else {
QWindowsScreen *newScreen = new QWindowsScreen(newData);
m_screens.push_back(newScreen);
@ -567,6 +571,8 @@ bool QWindowsScreenManager::handleScreenChanges()
removeScreen(i);
} // for existing screens
} // not lock screen
if (primaryScreenChanged)
QWindowsTheme::instance()->refreshFonts();
return true;
}

View File

@ -85,6 +85,8 @@ public:
static bool useNativeMenus();
void refreshFonts();
static const char *name;
private:
@ -92,7 +94,6 @@ private:
void clearPalettes();
void refreshPalettes();
void clearFonts();
void refreshFonts();
void refreshIconPixmapSizes();
static QWindowsTheme *m_instance;