Use old palette change detection method on Windows 10 and under

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2024-11-05 17:02:32 +09:00 коммит произвёл Matthieu Gallien
Родитель 7c2102547d
Коммит d2d91bb105
1 изменённых файлов: 9 добавлений и 2 удалений

Просмотреть файл

@ -969,8 +969,15 @@ void Theme::connectToPaletteSignal()
{ {
if (!_paletteSignalsConnected) { if (!_paletteSignalsConnected) {
if (const auto ptr = qobject_cast<QGuiApplication *>(QGuiApplication::instance())) { if (const auto ptr = qobject_cast<QGuiApplication *>(QGuiApplication::instance())) {
connect(ptr, &QGuiApplication::paletteChanged, this, &Theme::systemPaletteChanged); #ifdef Q_OS_WIN
connect(ptr->styleHints(), &QStyleHints::colorSchemeChanged, this, &Theme::darkModeChanged); // Windows 10 does not have proper dark mode support via Qt 6 so hack detection
if (!IsWindows11OrGreater()) {
connect(ptr, &QGuiApplication::paletteChanged, this, &Theme::darkModeChanged);
} else
#endif
{
connect(ptr->styleHints(), &QStyleHints::colorSchemeChanged, this, &Theme::darkModeChanged);
}
_paletteSignalsConnected = true; _paletteSignalsConnected = true;
} }
} }