Enable checking for whether the system palette was explicitly set
In order to obey a palette set globally on QApplication, an application attribute for checking if it's set at all is added. Task-number: QTBUG-39800 Change-Id: I26b965e6e18e0e1ca4df03cf343b3527df3636b2 Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
This commit is contained in:
parent
6526a4e136
commit
8fb881900c
@ -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
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user