From 0a09a6341ddff4397461deb98b8d7a28ca3c9dca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 25 Jun 2019 18:36:04 +0200 Subject: Sync implementation of QGuiApplication and QApplication setPalette The two static setPalette methods in QApplication and QGuiApplication should have the same behavior in terms of what signals and events they emit. Change-Id: I54579d490e31f3783e2d4fea689ca799a070ff1d Reviewed-by: Timur Pocheptsov --- src/gui/kernel/qguiapplication.cpp | 7 ++++--- src/widgets/kernel/qapplication.cpp | 9 +++------ 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index bab525f809..7adba40fbd 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -3299,7 +3299,7 @@ void QGuiApplication::setPalette(const QPalette &pal) QCoreApplication::setAttribute(Qt::AA_SetPalette); if (qGuiApp) - emit qGuiApp->paletteChanged(*QGuiApplicationPrivate::app_pal); + qGuiApp->d_func()->sendApplicationPaletteChange(); } void QGuiApplicationPrivate::applyWindowGeometrySpecificationTo(QWindow *window) @@ -4101,7 +4101,6 @@ void QGuiApplicationPrivate::notifyThemeChanged() if (!testAttribute(Qt::AA_SetPalette)) { clearPalette(); initPalette(); - emit qGuiApp->paletteChanged(*app_pal); sendApplicationPaletteChange(); } if (!(applicationResourceFlags & ApplicationFontExplicitlySet)) { @@ -4115,7 +4114,9 @@ void QGuiApplicationPrivate::notifyThemeChanged() void QGuiApplicationPrivate::sendApplicationPaletteChange(bool toAllWidgets, const char *className) { Q_UNUSED(toAllWidgets) - Q_UNUSED(className) + + if (!className) + emit qGuiApp->paletteChanged(*QGuiApplicationPrivate::app_pal); if (!is_app_running || is_app_closing) return; diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 6120e0e164..9b1202c491 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -1390,14 +1390,11 @@ void QApplicationPrivate::setPalette_helper(const QPalette &palette, const char* hash->insert(className, pal); } + if (!className && (!QApplicationPrivate::sys_pal || !palette.isCopyOf(*QApplicationPrivate::sys_pal))) + QCoreApplication::setAttribute(Qt::AA_SetPalette); if (qApp) qApp->d_func()->sendApplicationPaletteChange(all, className); - - if (!className && (!QApplicationPrivate::sys_pal || !palette.isCopyOf(*QApplicationPrivate::sys_pal))) { - QCoreApplication::setAttribute(Qt::AA_SetPalette); - emit qGuiApp->paletteChanged(*QGuiApplicationPrivate::app_pal); - } } /*! @@ -4433,7 +4430,7 @@ void QApplicationPrivate::sendApplicationPaletteChange(bool toAllWidgets, const if (!is_app_running || is_app_closing) return; - QGuiApplicationPrivate::sendApplicationPaletteChange(); + QGuiApplicationPrivate::sendApplicationPaletteChange(toAllWidgets, className); QEvent event(QEvent::ApplicationPaletteChange); const QWidgetList widgets = QApplication::allWidgets(); -- cgit v1.2.3