summaryrefslogtreecommitdiffstats
path: root/demos/qtdemo/menumanager.cpp
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/menumanager.cpp
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/menumanager.cpp')
-rw-r--r--demos/qtdemo/menumanager.cpp25
1 files changed, 16 insertions, 9 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())