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 (const auto ptr = qobject_cast<QGuiApplication *>(QGuiApplication::instance())) {
connect(ptr, &QGuiApplication::paletteChanged, this, &Theme::systemPaletteChanged);
connect(ptr->styleHints(), &QStyleHints::colorSchemeChanged, this, &Theme::darkModeChanged);
#ifdef Q_OS_WIN
// 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;
}
}