diff options
-rw-r--r-- | src/corelib/global/qnamespace.h | 1 | ||||
-rw-r--r-- | src/corelib/global/qnamespace.qdoc | 3 | ||||
-rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 1 | ||||
-rw-r--r-- | src/widgets/kernel/qapplication.cpp | 1 | ||||
-rw-r--r-- | tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp | 17 |
5 files changed, 23 insertions, 0 deletions
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index 745fb442f2..79ddf81b38 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -492,6 +492,7 @@ public: AA_UseOpenGLES = 16, AA_UseSoftwareOpenGL = 17, AA_ShareOpenGLContexts = 18, + AA_SetPalette = 19, // Add new attributes before this line AA_AttributeCount diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 8ebe0da11f..f9d968d47b 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -194,6 +194,9 @@ instances that belong to different top-level windows. This value has been added in Qt 5.4. + \value AA_SetPalette Indicates whether a palette was explicitly set on the + QApplication/QGuiApplication. This value has been added in Qt 5.5. + The following values are obsolete: \value AA_ImmediateWidgetCreation This attribute is no longer fully diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 3e2b692cd0..926ec16f19 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -2757,6 +2757,7 @@ void QGuiApplication::setPalette(const QPalette &pal) else *QGuiApplicationPrivate::app_pal = pal; applicationResourceFlags |= ApplicationPaletteExplicitlySet; + QCoreApplication::setAttribute(Qt::AA_SetPalette); emit qGuiApp->paletteChanged(*QGuiApplicationPrivate::app_pal); } diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 00f590ebc2..ed10beddd4 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -1508,6 +1508,7 @@ void QApplicationPrivate::setPalette_helper(const QPalette &palette, const char* QApplicationPrivate::set_pal = new QPalette(palette); else *QApplicationPrivate::set_pal = palette; + QCoreApplication::setAttribute(Qt::AA_SetPalette); } } diff --git a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp index b921e1519f..19365bffdd 100644 --- a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp +++ b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp @@ -76,6 +76,7 @@ private slots: void genericPluginsAndWindowSystemEvents(); void layoutDirection(); void globalShareContext(); + void testSetPaletteAttribute(); void staticFunctions(); @@ -968,6 +969,22 @@ void tst_QGuiApplication::globalShareContext() #endif } +void tst_QGuiApplication::testSetPaletteAttribute() +{ + QCoreApplication::setAttribute(Qt::AA_SetPalette, false); + int argc = 1; + char *argv[] = { const_cast<char*>("tst_qguiapplication") }; + + QGuiApplication app(argc, argv); + + QVERIFY(!QCoreApplication::testAttribute(Qt::AA_SetPalette)); + QPalette palette; + palette.setColor(QPalette::Foreground, Qt::red); + QGuiApplication::setPalette(palette); + + QVERIFY(QCoreApplication::testAttribute(Qt::AA_SetPalette)); +} + // Test that static functions do not crash if there is no application instance. void tst_QGuiApplication::staticFunctions() { |