From c49c96fbb13912a749942f8f90a6d91656a11852 Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Sun, 1 Sep 2013 12:03:57 +0300 Subject: [PATCH] Reinitialize system palette when setting a new style. Task-number: QTBUG-29565 Change-Id: I5ac95d52c453aec9e2160a135dc1afdd9583eed3 Reviewed-by: Eskil Abrahamsen Blomfeldt Reviewed-by: BogDan Vatra --- src/widgets/kernel/qapplication.cpp | 3 +++ src/widgets/kernel/qapplication_qpa.cpp | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index af3d134a5a..a8d13c64ee 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -1073,7 +1073,10 @@ void QApplication::setStyle(QStyle *style) if (QApplicationPrivate::set_pal) { QApplication::setPalette(*QApplicationPrivate::set_pal); } else if (QApplicationPrivate::sys_pal) { + clearSystemPalette(); + initSystemPalette(); QApplicationPrivate::initializeWidgetPaletteHash(); + QApplicationPrivate::initializeWidgetFontHash(); QApplicationPrivate::setPalette_helper(*QApplicationPrivate::sys_pal, /*className=*/0, /*clearWidgetPaletteHash=*/false); } else if (!QApplicationPrivate::sys_pal) { // Initialize the sys_pal if it hasn't happened yet... diff --git a/src/widgets/kernel/qapplication_qpa.cpp b/src/widgets/kernel/qapplication_qpa.cpp index b947f1b497..1f8e950d00 100644 --- a/src/widgets/kernel/qapplication_qpa.cpp +++ b/src/widgets/kernel/qapplication_qpa.cpp @@ -275,6 +275,8 @@ void QApplicationPrivate::initializeWidgetPaletteHash() QPlatformTheme *platformTheme = QGuiApplicationPrivate::platformTheme(); if (!platformTheme) return; + qt_app_palettes_hash()->clear(); + setPossiblePalette(platformTheme->palette(QPlatformTheme::ToolButtonPalette), "QToolButton"); setPossiblePalette(platformTheme->palette(QPlatformTheme::ButtonPalette), "QAbstractButton"); setPossiblePalette(platformTheme->palette(QPlatformTheme::CheckBoxPalette), "QCheckBox"); @@ -298,6 +300,8 @@ void QApplicationPrivate::initializeWidgetFontHash() if (!theme) return; FontHash *fontHash = qt_app_fonts_hash(); + fontHash->clear(); + if (const QFont *font = theme->font(QPlatformTheme::MenuFont)) fontHash->insert(QByteArrayLiteral("QMenu"), *font); if (const QFont *font = theme->font(QPlatformTheme::MenuBarFont))