macOS: Make QMacStyle::standardPalette() reflect the platform theme

This palette isn't usually used, and the platform theme's palette is
preferred, but if a client asks for the standard palette (e.g. as
used in the styles example) we should try to report a palette that
gives the system look.

Change-Id: Ie5e58c890c13c716a9e9b5093b954a737e550dee
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
Tor Arne Vestbø 2019-06-19 11:43:14 +02:00
parent 6d61b10f65
commit d5adaacbb2

View File

@ -2555,11 +2555,12 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QW
QPalette QMacStyle::standardPalette() const QPalette QMacStyle::standardPalette() const
{ {
QPalette pal = QCommonStyle::standardPalette(); auto platformTheme = QGuiApplicationPrivate::platformTheme();
pal.setColor(QPalette::Disabled, QPalette::Dark, QColor(191, 191, 191)); auto styleNames = platformTheme->themeHint(QPlatformTheme::StyleNames);
pal.setColor(QPalette::Active, QPalette::Dark, QColor(191, 191, 191)); if (styleNames.toStringList().contains("macintosh"))
pal.setColor(QPalette::Inactive, QPalette::Dark, QColor(191, 191, 191)); return *platformTheme->palette();
return pal; else
return QStyle::standardPalette();
} }
int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w, int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w,