summaryrefslogtreecommitdiffstats
path: root/demos/qtdemo
diff options
context:
space:
mode:
authorAlan Alpert <alan.alpert@nokia.com>2010-05-30 00:52:42 (GMT)
committerAlan Alpert <alan.alpert@nokia.com>2010-05-30 00:52:42 (GMT)
commit130cf33cdc1a1f7c2a0b33fcef0ac63b8163306d (patch)
tree0b038837e65219fd46a7c84b6142463aa2f0cefa /demos/qtdemo
parent369f899e69362b2156800f8c90dfb0bdbe5f2598 (diff)
downloadQt-130cf33cdc1a1f7c2a0b33fcef0ac63b8163306d.zip
Qt-130cf33cdc1a1f7c2a0b33fcef0ac63b8163306d.tar.gz
Qt-130cf33cdc1a1f7c2a0b33fcef0ac63b8163306d.tar.bz2
Some tweaks on the QML-enhanced QtDemo
-don't crash if we aren't showing the FPS -different method of unloading the QML example when hidden -fix screwed up background when scaled.
Diffstat (limited to 'demos/qtdemo')
-rw-r--r--demos/qtdemo/menumanager.cpp25
-rw-r--r--demos/qtdemo/menumanager.h1
-rw-r--r--demos/qtdemo/qmlShell.qml1
3 files changed, 17 insertions, 10 deletions
diff --git a/demos/qtdemo/menumanager.cpp b/demos/qtdemo/menumanager.cpp
index 9e2ba6b..a2ceb0e 100644
--- a/demos/qtdemo/menumanager.cpp
+++ b/demos/qtdemo/menumanager.cpp
@@ -378,13 +378,19 @@ void MenuManager::launchQmlExample(const QString &name)
return;
}
}
+ if(!Colors::noBlur){
+ QImage qmlBgImage(this->window->rect().size(), QImage::Format_ARGB32_Premultiplied);
+ QPainter painter(&qmlBgImage);
+ if(Colors::showFps)
+ this->window->fpsLabel->setOpacity(0);
+ this->window->render(&painter);
+ if(Colors::showFps)
+ this->window->fpsLabel->setOpacity(1.0);
+ Qt::ImageConversionFlags convFlags = Qt::AvoidDither | Qt::NoOpaqueDetection;
+ this->declarativeEngine->rootContext()->setContextProperty("bgAppPixmap", QVariant(QPixmap::fromImage(qmlBgImage, convFlags)));
+ }
- QPainter painter(qmlBgImage);
- this->window->fpsLabel->setOpacity(0);
- this->window->render(&painter);
- this->window->fpsLabel->setOpacity(1.0);
- Qt::ImageConversionFlags convFlags = Qt::AvoidDither | Qt::NoOpaqueDetection;
- this->declarativeEngine->rootContext()->setContextProperty("bgAppPixmap", QVariant(QPixmap::fromImage(*qmlBgImage, convFlags)));
+ qmlRoot->setProperty("qmlFile", QVariant(""));//unload component
qmlRoot->setProperty("show", QVariant(true));
qmlRoot->setProperty("qmlFile", QUrl::fromLocalFile(file.fileName()));
}
@@ -439,10 +445,11 @@ void MenuManager::init(MainWindow *window)
// Note that we paint the background into a static image for a theorized performance improvement when blurring
// It has not yet been determined what, if any, speed up this gives (but is left in 'cause the QML expects it now)
- this->qmlBgImage = new QImage(window->sceneRect().size().toSize(), QImage::Format_ARGB32);
- this->qmlBgImage->fill(0);
declarativeEngine->rootContext()->setContextProperty("useBlur", !Colors::noBlur);
- declarativeEngine->rootContext()->setContextProperty("bgAppPixmap", QVariant(QPixmap::fromImage(*qmlBgImage)));
+ QImage qmlBgImage(this->window->rect().size(), QImage::Format_ARGB32_Premultiplied);
+ qmlBgImage.fill(0);
+ this->declarativeEngine->rootContext()->setContextProperty("bgAppPixmap", QVariant(QPixmap::fromImage(qmlBgImage)));
+
QDeclarativeComponent component(declarativeEngine, QUrl("qrc:qml/qmlShell.qml"), this);
qmlRoot = 0;
if(component.isReady())
diff --git a/demos/qtdemo/menumanager.h b/demos/qtdemo/menumanager.h
index e90e02c..5e14204 100644
--- a/demos/qtdemo/menumanager.h
+++ b/demos/qtdemo/menumanager.h
@@ -85,7 +85,6 @@ public:
QDeclarativeEngine* declarativeEngine;
QDeclarativeItem *qmlRoot;
- QImage *qmlBgImage;
private slots:
void exampleFinished();
diff --git a/demos/qtdemo/qmlShell.qml b/demos/qtdemo/qmlShell.qml
index b9021e8..b1ee79a 100644
--- a/demos/qtdemo/qmlShell.qml
+++ b/demos/qtdemo/qmlShell.qml
@@ -167,6 +167,7 @@ Item {
SequentialAnimation{
PropertyAction { target: bg; property: useBlur?"y":"opacity";}//fade in blurred background only if blurred
NumberAnimation{ properties: "opacity"; easing.type: Easing.InQuad; duration: 500}
+ PropertyAction { target: loader; property: "focus"; value: true}//Might be needed to ensure the focus stays with us
}
}
]