summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYann Bodson <yann.bodson@nokia.com>2009-07-15 05:43:35 (GMT)
committerYann Bodson <yann.bodson@nokia.com>2009-07-15 05:43:35 (GMT)
commit46fa45fd0f2a40580951903437a5fd1b6c5237ad (patch)
tree3a364421cfb651fa9763daabffd67d155aac9ebd /src
parent59b3e3ba52891197510115f912e7934ac1784d7c (diff)
downloadQt-46fa45fd0f2a40580951903437a5fd1b6c5237ad.zip
Qt-46fa45fd0f2a40580951903437a5fd1b6c5237ad.tar.gz
Qt-46fa45fd0f2a40580951903437a5fd1b6c5237ad.tar.bz2
Make QmlPalette properties notifiable.
Handle palette changes in QmlPalette.
Diffstat (limited to 'src')
-rw-r--r--src/declarative/util/qmlpalette.cpp25
-rw-r--r--src/declarative/util/qmlpalette.h31
2 files changed, 42 insertions, 14 deletions
diff --git a/src/declarative/util/qmlpalette.cpp b/src/declarative/util/qmlpalette.cpp
index 670966d..eda0ded 100644
--- a/src/declarative/util/qmlpalette.cpp
+++ b/src/declarative/util/qmlpalette.cpp
@@ -41,6 +41,7 @@
#include "private/qobject_p.h"
#include "qmlpalette.h"
+#include <QApplication>
QT_BEGIN_NAMESPACE
@@ -63,7 +64,9 @@ QmlPalette::QmlPalette(QObject *parent)
: QObject(*(new QmlPalettePrivate), parent)
{
Q_D(QmlPalette);
+ d->palette = qApp->palette();
d->group = QPalette::Active;
+ qApp->installEventFilter(this);
}
QmlPalette::~QmlPalette()
@@ -160,4 +163,26 @@ QPalette QmlPalette::palette() const
return d->palette;
}
+bool QmlPalette::eventFilter(QObject *watched, QEvent *event)
+{
+ if (watched == qApp) {
+ if (event->type() == QEvent::ApplicationPaletteChange) {
+ QApplication::postEvent(this, new QEvent(QEvent::ApplicationPaletteChange));
+ return false;
+ }
+ }
+ return QObject::eventFilter(watched, event);
+}
+
+bool QmlPalette::event(QEvent *event)
+{
+ Q_D(QmlPalette);
+ if (event->type() == QEvent::ApplicationPaletteChange) {
+ d->palette = qApp->palette();
+ emit paletteChanged();
+ return true;
+ }
+ return QObject::event(event);
+}
+
QT_END_NAMESPACE
diff --git a/src/declarative/util/qmlpalette.h b/src/declarative/util/qmlpalette.h
index f176764..1401ad1 100644
--- a/src/declarative/util/qmlpalette.h
+++ b/src/declarative/util/qmlpalette.h
@@ -62,19 +62,19 @@ public:
QmlPalette(QObject *parent=0);
~QmlPalette();
- Q_PROPERTY(QColor window READ window CONSTANT)
- Q_PROPERTY(QColor windowText READ windowText CONSTANT)
- Q_PROPERTY(QColor base READ base CONSTANT)
- Q_PROPERTY(QColor alternateBase READ alternateBase CONSTANT)
- Q_PROPERTY(QColor button READ button CONSTANT)
- Q_PROPERTY(QColor buttonText READ buttonText CONSTANT)
- Q_PROPERTY(QColor light READ light CONSTANT)
- Q_PROPERTY(QColor midlight READ midlight CONSTANT)
- Q_PROPERTY(QColor dark READ dark CONSTANT)
- Q_PROPERTY(QColor mid READ mid CONSTANT)
- Q_PROPERTY(QColor shadow READ shadow CONSTANT)
- Q_PROPERTY(QColor highlight READ highlight CONSTANT)
- Q_PROPERTY(QColor highlightedText READ highlightedText CONSTANT)
+ Q_PROPERTY(QColor window READ window NOTIFY paletteChanged)
+ Q_PROPERTY(QColor windowText READ windowText NOTIFY paletteChanged)
+ Q_PROPERTY(QColor base READ base NOTIFY paletteChanged)
+ Q_PROPERTY(QColor alternateBase READ alternateBase NOTIFY paletteChanged)
+ Q_PROPERTY(QColor button READ button NOTIFY paletteChanged)
+ Q_PROPERTY(QColor buttonText READ buttonText NOTIFY paletteChanged)
+ Q_PROPERTY(QColor light READ light NOTIFY paletteChanged)
+ Q_PROPERTY(QColor midlight READ midlight NOTIFY paletteChanged)
+ Q_PROPERTY(QColor dark READ dark NOTIFY paletteChanged)
+ Q_PROPERTY(QColor mid READ mid NOTIFY paletteChanged)
+ Q_PROPERTY(QColor shadow READ shadow NOTIFY paletteChanged)
+ Q_PROPERTY(QColor highlight READ highlight NOTIFY paletteChanged)
+ Q_PROPERTY(QColor highlightedText READ highlightedText NOTIFY paletteChanged)
QColor window() const;
QColor windowText() const;
@@ -98,8 +98,11 @@ public:
void setColorGroup(QPalette::ColorGroup);
+ bool virtual eventFilter(QObject *watched, QEvent *event);
+ bool virtual event(QEvent *event);
+
Q_SIGNALS:
- void updated();
+ void paletteChanged();
};
QT_END_NAMESPACE