Share updates to QGuiApplicationPrivate::app_pal via helper function
Change-Id: I2f582358efaadcd33b39c52317222322c589423f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
This commit is contained in:
parent
445c1a873f
commit
0c37bc11b5
@ -3293,12 +3293,8 @@ QPalette QGuiApplication::palette()
|
||||
*/
|
||||
void QGuiApplication::setPalette(const QPalette &pal)
|
||||
{
|
||||
if (QGuiApplicationPrivate::app_pal && pal.isCopyOf(*QGuiApplicationPrivate::app_pal))
|
||||
if (!QGuiApplicationPrivate::setPalette(pal))
|
||||
return;
|
||||
if (!QGuiApplicationPrivate::app_pal)
|
||||
QGuiApplicationPrivate::app_pal = new QPalette(pal);
|
||||
else
|
||||
*QGuiApplicationPrivate::app_pal = pal;
|
||||
|
||||
QCoreApplication::setAttribute(Qt::AA_SetPalette);
|
||||
|
||||
@ -3306,6 +3302,19 @@ void QGuiApplication::setPalette(const QPalette &pal)
|
||||
qGuiApp->d_func()->sendApplicationPaletteChange();
|
||||
}
|
||||
|
||||
bool QGuiApplicationPrivate::setPalette(const QPalette &palette)
|
||||
{
|
||||
if (app_pal && palette.isCopyOf(*app_pal))
|
||||
return false;
|
||||
|
||||
if (!app_pal)
|
||||
app_pal = new QPalette(palette);
|
||||
else
|
||||
*app_pal = palette;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void QGuiApplicationPrivate::applyWindowGeometrySpecificationTo(QWindow *window)
|
||||
{
|
||||
windowGeometrySpecification.applyTo(window);
|
||||
|
@ -323,6 +323,8 @@ public:
|
||||
|
||||
static void resetCachedDevicePixelRatio();
|
||||
|
||||
static bool setPalette(const QPalette &palette);
|
||||
|
||||
protected:
|
||||
virtual void notifyThemeChanged();
|
||||
virtual void sendApplicationPaletteChange(bool toAllWidgets = false, const char *className = nullptr);
|
||||
|
@ -1374,12 +1374,8 @@ void QApplicationPrivate::setPalette_helper(const QPalette &palette, const char*
|
||||
bool all = false;
|
||||
PaletteHash *hash = app_palettes();
|
||||
if (!className) {
|
||||
if (QApplicationPrivate::app_pal && pal.isCopyOf(*QApplicationPrivate::app_pal))
|
||||
if (!QGuiApplicationPrivate::setPalette(pal))
|
||||
return;
|
||||
if (!QApplicationPrivate::app_pal)
|
||||
QApplicationPrivate::app_pal = new QPalette(pal);
|
||||
else
|
||||
*QApplicationPrivate::app_pal = pal;
|
||||
|
||||
if (!QApplicationPrivate::sys_pal || !palette.isCopyOf(*QApplicationPrivate::sys_pal))
|
||||
QCoreApplication::setAttribute(Qt::AA_SetPalette);
|
||||
|
Loading…
x
Reference in New Issue
Block a user