diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2009-07-17 03:59:20 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2009-07-17 03:59:20 (GMT) |
commit | 43f131a0a5aaddf35b7b4b4c50468e2bb9db4965 (patch) | |
tree | b923808cc4f4cb7b940e8d15f451ca877122c29d | |
parent | c01d748e2afcf6cf31957d78c08f95bf9ec7da6e (diff) | |
parent | 68cf34dbf4c5e240188a08f7dcca3a7343e2ef7f (diff) | |
download | Qt-43f131a0a5aaddf35b7b4b4c50468e2bb9db4965.zip Qt-43f131a0a5aaddf35b7b4b4c50468e2bb9db4965.tar.gz Qt-43f131a0a5aaddf35b7b4b4c50468e2bb9db4965.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
-rw-r--r-- | demos/declarative/samegame/content/BoomBlock.qml | 10 | ||||
-rw-r--r-- | examples/declarative/minehunt/Description.qml | 4 | ||||
-rw-r--r-- | examples/declarative/minehunt/main.cpp | 4 | ||||
-rw-r--r-- | examples/declarative/minehunt/minehunt.qml | 34 | ||||
-rw-r--r-- | src/declarative/extra/qfxparticles.cpp | 44 |
5 files changed, 55 insertions, 41 deletions
diff --git a/demos/declarative/samegame/content/BoomBlock.qml b/demos/declarative/samegame/content/BoomBlock.qml index 0d05772..b7838dd 100644 --- a/demos/declarative/samegame/content/BoomBlock.qml +++ b/demos/declarative/samegame/content/BoomBlock.qml @@ -5,8 +5,9 @@ Item { id:block property int targetX: 0 property int targetY: 0 - x: Follow { source: targetX; spring: 1.2; damping: 0.1 } - y: Follow { source: targetY; spring: 1.2; damping: 0.1 } + x: Follow { source: targetX; spring: 2; damping: 0.2 } + y: Follow { source: targetY; spring: 2; damping: 0.2 } + Image { id: img source: { @@ -22,9 +23,10 @@ Item { id:block opacity: Behavior { NumberAnimation { properties:"opacity"; duration: 200 } } anchors.fill: parent } + Particles { id: particles width:1; height:1; anchors.centeredIn: parent; opacity: 0 - lifeSpan: 1000000000; count:0; streamIn: false + lifeSpan: 700; lifeSpanDeviation: 600; count:0; streamIn: false angle: 0; angleDeviation: 360; velocity: 100; velocityDeviation:30 source: { if(type == 0){ @@ -36,6 +38,7 @@ Item { id:block } } } + states: [ State{ name: "AliveState"; when: spawning == true && dying == false @@ -44,6 +47,7 @@ Item { id:block State{ name: "DeathState"; when: dying == true SetProperties { target: particles; count: 50 } SetProperties { target: particles; opacity: 1 } + SetProperties { target: particles; emitting: false } // i.e. emit only once SetProperties { target: img; opacity: 0 } } ] diff --git a/examples/declarative/minehunt/Description.qml b/examples/declarative/minehunt/Description.qml index 0241ae5..ea71d85 100644 --- a/examples/declarative/minehunt/Description.qml +++ b/examples/declarative/minehunt/Description.qml @@ -29,8 +29,4 @@ Item { wrap: true } } - filter: Shadow { - xOffset: 5 - yOffset: 5 - } } diff --git a/examples/declarative/minehunt/main.cpp b/examples/declarative/minehunt/main.cpp index 7f10757..d8e60cc 100644 --- a/examples/declarative/minehunt/main.cpp +++ b/examples/declarative/minehunt/main.cpp @@ -62,7 +62,7 @@ public: MyWidget(int = 370, int = 480, QWidget *parent=0, Qt::WindowFlags flags=0); ~MyWidget(); - Q_PROPERTY(QList<Tile *> *tiles READ tiles); + Q_PROPERTY(QList<Tile *> *tiles READ tiles CONSTANT); QList<Tile *> *tiles() { return &_tiles; } Q_PROPERTY(bool isPlaying READ isPlaying NOTIFY isPlayingChanged); @@ -134,9 +134,7 @@ MyWidget::MyWidget(int width, int height, QWidget *parent, Qt::WindowFlags flags canvas->setQml(qml, fileName); QmlContext *ctxt = canvas->rootContext(); - ctxt->activate(); ctxt->addDefaultObject(this); - ctxt->deactivate(); canvas->execute(); } diff --git a/examples/declarative/minehunt/minehunt.qml b/examples/declarative/minehunt/minehunt.qml index 03fcc8d..286e485 100644 --- a/examples/declarative/minehunt/minehunt.qml +++ b/examples/declarative/minehunt/minehunt.qml @@ -46,7 +46,7 @@ Item { text: modelData.hint color: "white" font.bold: true - opacity: modelData.hasMine == false && modelData.hint > 0 + opacity: !modelData.hasMine && modelData.hint > 0 } Image { anchors.horizontalCenter: parent.horizontalCenter @@ -57,13 +57,13 @@ Item { Explosion { anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter - explode: modelData.hasMine==true && modelData.flipped==true + explode: modelData.hasMine && modelData.flipped } } states: [ State { name: "back" - when: modelData.flipped == true + when: modelData.flipped SetProperties { target: flipable; rotation: 180 } } ] @@ -71,7 +71,19 @@ Item { Transition { SequentialAnimation { PauseAnimation { - duration: {var ret = Math.abs(flipable.parent.x-field.clickx) + Math.abs(flipable.parent.y-field.clicky); if (ret > 0) {if(modelData.hasMine==true && modelData.flipped==true){ret*3;}else{ret;}} else {0}} + duration: { + var ret = Math.abs(flipable.parent.x-field.clickx) + + Math.abs(flipable.parent.y-field.clicky); + if (ret > 0) { + if (modelData.hasMine && modelData.flipped) { + ret*3 + } else { + ret + } + } else { + 0 + } + } } NumberAnimation { easing: "easeInOutQuad" @@ -82,7 +94,17 @@ Item { ] MouseRegion { anchors.fill: parent - onClicked: { field.clickx = flipable.parent.x; field.clicky = flipable.parent.y; row = Math.floor(index/9); col = index - (Math.floor(index/9) * 9); if(mouse.button==undefined || mouse.button==Qt.RightButton){flag(row,col);}else{flip(row,col);} } + onClicked: { + field.clickx = flipable.parent.x; + field.clicky = flipable.parent.y; + row = Math.floor(index/9); + col = index - (Math.floor(index/9) * 9); + if (mouse.button==undefined || mouse.button==Qt.RightButton) { + flag(row,col); + } else { + flip(row,col); + } + } } } } @@ -146,7 +168,7 @@ Item { Image { x: 280 y: 10 - source: if(isPlaying==true){'pics/face-smile.png'}else{if(hasWon==true){'pics/face-smile-big.png'}else{'pics/face-sad.png'}} + source: isPlaying ? 'pics/face-smile.png' : hasWon ? 'pics/face-smile-big.png': 'pics/face-sad.png' MouseRegion { anchors.fill: parent onClicked: { reset() } diff --git a/src/declarative/extra/qfxparticles.cpp b/src/declarative/extra/qfxparticles.cpp index 3d59022..c31163c 100644 --- a/src/declarative/extra/qfxparticles.cpp +++ b/src/declarative/extra/qfxparticles.cpp @@ -410,7 +410,6 @@ public: }; -//TODO: Stop the clock if no visible particles and not emitting (restart on emittingChanged) void QFxParticlesPrivate::tick(int time) { Q_Q(QFxParticles); @@ -465,12 +464,9 @@ void QFxParticlesPrivate::tick(int time) } lastAdvTime = time; - if (oldCount || particles.count()) { - if (q->itemParent()) - q->itemParent()->update(); - else - q->update(); - } else if (!count) { + paintItem->updateSize(); + paintItem->update(); + if (!(oldCount || particles.count()) && (!count || !emitting)) { lastAdvTime = 0; clock.stop(); } @@ -641,7 +637,8 @@ void QFxParticles::imageLoaded() { Q_D(QFxParticles); d->image = QFxPixmap(d->url); - update(); + d->paintItem->updateSize(); + d->paintItem->update(); } void QFxParticles::setSource(const QUrl &name) @@ -656,7 +653,8 @@ void QFxParticles::setSource(const QUrl &name) if (name.isEmpty()) { d->url = name; d->image = QPixmap(); - update(); + d->paintItem->updateSize(); + d->paintItem->update(); } else { d->url = name; Q_ASSERT(!name.isRelative()); @@ -687,10 +685,11 @@ void QFxParticles::setCount(int cnt) d->count = cnt; d->addParticleTime = 0; d->addParticleCount = d->particles.count(); - if (!oldCount && d->clock.state() != QAbstractAnimation::Running){ - d->clock.start(); // infinity?? + if (!oldCount && d->clock.state() != QAbstractAnimation::Running) { + d->clock.start(); } - update(); + d->paintItem->updateSize(); + d->paintItem->update(); } } @@ -1006,6 +1005,8 @@ void QFxParticles::setEmitting(bool r) { Q_D(QFxParticles); d->emitting = r; + if (d->count && r) + d->clock.start(); } /*! \qmlproperty ParticleMotion Particles::motion @@ -1046,17 +1047,10 @@ QString QFxParticles::propertyInfo() const return d->url.toString(); } -void QFxParticlesPainter::updateSize(){ - setX(-500); - setY(-500); - setWidth(1000); - setHeight(1000); - return ; +void QFxParticlesPainter::updateSize() +{ const int parentX = parentItem()->x(); const int parentY = parentItem()->y(); - //Have to use statistical approach to needed size as arbitrary particle - //motions make it impossible to calculate. - //max/min vars stored to give a never shrinking rect for (int i = 0; i < d->particles.count(); ++i) { const QFxParticle &particle = d->particles.at(i); if(particle.x > maxX) @@ -1090,7 +1084,6 @@ void QFxParticlesPainter::paintContents(QPainter &p) if (d->image.isNull()) return; - updateSize(); const int myX = x() + parentItem()->x(); const int myY = y() + parentItem()->y(); @@ -1099,15 +1092,16 @@ void QFxParticlesPainter::paintContents(QPainter &p) p.setOpacity(particle.opacity); p.drawPixmap(particle.x - myX, particle.y - myY, d->image); } - update();//Should I need this? (GV does) } void QFxParticles::componentComplete() { Q_D(QFxParticles); QFxItem::componentComplete(); - if (d->count) - d->clock.start(); // infinity?? + if (d->count) { + d->paintItem->updateSize(); + d->clock.start(); + } if (d->lifeSpanDev > d->lifeSpan) d->lifeSpanDev = d->lifeSpan; } |