diff options
Diffstat (limited to 'tools/qmlviewer/qmlviewer.cpp')
-rw-r--r-- | tools/qmlviewer/qmlviewer.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp index db0dc18..b6ce619 100644 --- a/tools/qmlviewer/qmlviewer.cpp +++ b/tools/qmlviewer/qmlviewer.cpp @@ -17,6 +17,7 @@ #include "qmlviewer.h" #include <QtDeclarative/qmlcontext.h> #include <QtDeclarative/qmlengine.h> +#include "qmlpalette.h" #include "qml.h" #include <private/qperformancelog_p.h> #include "qfxtestengine.h" @@ -133,6 +134,8 @@ QmlViewer::QmlViewer(QFxTestEngine::TestMode testMode, const QString &testDir, Q devicemode = false; skin = 0; canvas = 0; + palette = 0; + disabledPalette = 0; record_autotime = 0; record_period = 20; @@ -383,6 +386,7 @@ void QmlViewer::openQml(const QString& fileName) } } + setupPalettes(); canvas->setUrl(url); QTime t; @@ -407,6 +411,18 @@ void QmlViewer::openQml(const QString& fileName) #endif } +void QmlViewer:: setupPalettes() +{ + delete palette; + palette = new QmlPalette; + QmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("activePalette", palette); + + delete disabledPalette; + disabledPalette = new QmlPalette; + disabledPalette->setColorGroup(QPalette::Disabled); + ctxt->setContextProperty("disabledPalette", disabledPalette); +} void QmlViewer::setSkin(const QString& skinDirectory) { @@ -486,6 +502,15 @@ void QmlViewer::setRecordFile(const QString& f) record_file = f; } +bool QmlViewer::event(QEvent *event) +{ + if (event->type() == QEvent::PaletteChange) { + setupPalette(); + return true; + } + return QWidget::event(event); +} + void QmlViewer::setRecordPeriod(int ms) { record_period = ms; |