summaryrefslogtreecommitdiffstats
path: root/src/plugins/styles
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2022-12-07 17:37:09 +0100
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2022-12-08 17:56:48 +0100
commita2518b4140ed88a674bf4a4fcf4576e35c698bb9 (patch)
tree2efe09a5f39ebef0298ca8fb171dc2c8c83f21b4 /src/plugins/styles
parentc62c2aac752c6b63d5afd2f7a10dd9f43c99ae7b (diff)
Overwrite dark system palette in Vista style
The Vista style uses system assets for controls, and those are never dark. Because of that we cannot support dark appearance with that style, and applications using the Vista style should always use the light system palette. Override QStyle::polish(QPalette &) in the vista style to do that. To make that palette available, move the code reading the light palette into QWindowsApplication, and call that method from both the platform theme (if the system is running in light mode) and from the Vista style (only if the system is running in dark mode). If the system is dark mode and another style is used (e.g. Fusion, which works well with a dark palette), then the palette returned by the platform theme gets used without any modifications. This requires duplicating some small inline helper functions in QWindowsTheme and QWindowsApplication. We can clean this up once the implementation is complete for both Qt Widgets and Qt Quick. Change-Id: Ia13f59a2d8414642603f9708926718daf9e8954d Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
Diffstat (limited to 'src/plugins/styles')
-rw-r--r--src/plugins/styles/windowsvista/qwindowsvistastyle.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp b/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp
index 5533a194ac..969e53b8e1 100644
--- a/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp
+++ b/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp
@@ -6,6 +6,7 @@
#include "qwindowsvistaanimation_p.h"
#include <qoperatingsystemversion.h>
#include <qscreen.h>
+#include <qstylehints.h>
#include <qwindow.h>
#include <private/qstyleanimation_p.h>
#include <private/qstylehelper_p.h>
@@ -172,10 +173,8 @@ static QRegion scaleRegion(const QRegion &region, qreal factor)
*/
bool QWindowsVistaStylePrivate::useVista(bool update)
{
- if (update) {
- useVistaTheme = IsThemeActive() && (IsAppThemed() || !QCoreApplication::instance())
- && !QWindowsStylePrivate::isDarkMode();
- }
+ if (update)
+ useVistaTheme = IsThemeActive() && (IsAppThemed() || !QCoreApplication::instance());
return useVistaTheme;
}
@@ -4791,6 +4790,14 @@ void QWindowsVistaStyle::polish(QPalette &pal)
{
Q_D(QWindowsVistaStyle);
+ if (qApp->styleHints()->appearance() == Qt::Appearance::Dark) {
+ // System runs in dark mode, but the Vista style cannot use a dark palette.
+ // Overwrite with the light system palette.
+ using QWindowsApplication = QNativeInterface::Private::QWindowsApplication;
+ if (auto nativeWindowsApp = dynamic_cast<QWindowsApplication *>(QGuiApplicationPrivate::platformIntegration()))
+ nativeWindowsApp->lightSystemPalette(pal);
+ }
+
QPixmapCache::clear();
d->alphaCache.clear();
d->hasInitColors = false;