QGuiApplication::paletteChanged(const QPalette &palette) [signal]
This allows QQuickSystemPalette to listen to palette changes without installing an expensive event filter on the application object. Change-Id: I8b693e047d993c444e393d7a714a5709692c3560 Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com> Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
This commit is contained in:
parent
b31c9d8c03
commit
82d906a20d
@ -2652,6 +2652,15 @@ QClipboard * QGuiApplication::clipboard()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\since 5.4
|
||||||
|
\fn void QGuiApplication::paletteChanged(const QPalette &palette)
|
||||||
|
|
||||||
|
This signal is emitted when the \a palette of the application changes.
|
||||||
|
|
||||||
|
\sa palette()
|
||||||
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Returns the default application palette.
|
Returns the default application palette.
|
||||||
|
|
||||||
@ -2678,6 +2687,7 @@ void QGuiApplication::setPalette(const QPalette &pal)
|
|||||||
else
|
else
|
||||||
*QGuiApplicationPrivate::app_pal = pal;
|
*QGuiApplicationPrivate::app_pal = pal;
|
||||||
applicationResourceFlags |= ApplicationPaletteExplicitlySet;
|
applicationResourceFlags |= ApplicationPaletteExplicitlySet;
|
||||||
|
emit qGuiApp->paletteChanged(*QGuiApplicationPrivate::app_pal);
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect QGuiApplicationPrivate::applyWindowGeometrySpecification(const QRect &windowGeometry, const QWindow *window)
|
QRect QGuiApplicationPrivate::applyWindowGeometrySpecification(const QRect &windowGeometry, const QWindow *window)
|
||||||
|
@ -174,6 +174,7 @@ Q_SIGNALS:
|
|||||||
void commitDataRequest(QSessionManager &sessionManager);
|
void commitDataRequest(QSessionManager &sessionManager);
|
||||||
void saveStateRequest(QSessionManager &sessionManager);
|
void saveStateRequest(QSessionManager &sessionManager);
|
||||||
#endif
|
#endif
|
||||||
|
void paletteChanged(const QPalette &pal);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool event(QEvent *);
|
bool event(QEvent *);
|
||||||
|
@ -45,6 +45,7 @@
|
|||||||
#include <QtGui/QWindow>
|
#include <QtGui/QWindow>
|
||||||
#include <QtGui/QScreen>
|
#include <QtGui/QScreen>
|
||||||
#include <QtGui/QCursor>
|
#include <QtGui/QCursor>
|
||||||
|
#include <QtGui/QPalette>
|
||||||
#include <qpa/qwindowsysteminterface.h>
|
#include <qpa/qwindowsysteminterface.h>
|
||||||
#include <qgenericplugin.h>
|
#include <qgenericplugin.h>
|
||||||
|
|
||||||
@ -72,6 +73,7 @@ private slots:
|
|||||||
void abortQuitOnShow();
|
void abortQuitOnShow();
|
||||||
void changeFocusWindow();
|
void changeFocusWindow();
|
||||||
void keyboardModifiers();
|
void keyboardModifiers();
|
||||||
|
void palette();
|
||||||
void modalWindow();
|
void modalWindow();
|
||||||
void quitOnLastWindowClosed();
|
void quitOnLastWindowClosed();
|
||||||
void genericPluginsAndWindowSystemEvents();
|
void genericPluginsAndWindowSystemEvents();
|
||||||
@ -434,6 +436,31 @@ void tst_QGuiApplication::keyboardModifiers()
|
|||||||
window->close();
|
window->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_QGuiApplication::palette()
|
||||||
|
{
|
||||||
|
int argc = 1;
|
||||||
|
char *argv[] = { const_cast<char*>("tst_qguiapplication") };
|
||||||
|
QGuiApplication app(argc, argv);
|
||||||
|
QSignalSpy signalSpy(&app, SIGNAL(paletteChanged(QPalette)));
|
||||||
|
|
||||||
|
QPalette oldPalette = QGuiApplication::palette();
|
||||||
|
QPalette newPalette = QPalette(Qt::red);
|
||||||
|
|
||||||
|
QGuiApplication::setPalette(newPalette);
|
||||||
|
QCOMPARE(QGuiApplication::palette(), newPalette);
|
||||||
|
QCOMPARE(signalSpy.count(), 1);
|
||||||
|
QCOMPARE(signalSpy.at(0).at(0), QVariant(newPalette));
|
||||||
|
|
||||||
|
QGuiApplication::setPalette(oldPalette);
|
||||||
|
QCOMPARE(QGuiApplication::palette(), oldPalette);
|
||||||
|
QCOMPARE(signalSpy.count(), 2);
|
||||||
|
QCOMPARE(signalSpy.at(1).at(0), QVariant(oldPalette));
|
||||||
|
|
||||||
|
QGuiApplication::setPalette(oldPalette);
|
||||||
|
QCOMPARE(QGuiApplication::palette(), oldPalette);
|
||||||
|
QCOMPARE(signalSpy.count(), 2);
|
||||||
|
}
|
||||||
|
|
||||||
class BlockableWindow : public QWindow
|
class BlockableWindow : public QWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Loading…
Reference in New Issue
Block a user