summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Alpert <alan.alpert@nokia.com>2009-11-25 15:04:00 (GMT)
committerAlan Alpert <alan.alpert@nokia.com>2009-11-25 15:04:00 (GMT)
commit59a0002b1eaedd1961136b364a595c376755e085 (patch)
treee72bd7181e5cab0b0cea14f0efaa65ba49a0a107
parentb74e226c09bc37043a06b24029e0e22e4f3cdd16 (diff)
downloadQt-59a0002b1eaedd1961136b364a595c376755e085.zip
Qt-59a0002b1eaedd1961136b364a595c376755e085.tar.gz
Qt-59a0002b1eaedd1961136b364a595c376755e085.tar.bz2
Treat emissionRate=0 like emitting=false
Including stopping the timer because we arenæt emitting anything. Because emissionRate=0 is exactly the same as emitting=false, the emitting property has been removed. Task-number: QTBUG-6209
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsparticles.cpp54
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsparticles_p.h4
-rw-r--r--tests/auto/declarative/qmlgraphicsparticles/tst_qmlgraphicsparticles.cpp3
-rw-r--r--tests/auto/declarative/visual/qmlgraphicsparticles/particles.qml7
4 files changed, 16 insertions, 52 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicsparticles.cpp b/src/declarative/graphicsitems/qmlgraphicsparticles.cpp
index a0b41e8..f15d9f6 100644
--- a/src/declarative/graphicsitems/qmlgraphicsparticles.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsparticles.cpp
@@ -372,7 +372,7 @@ public:
, lifeSpanDev(1000), fadeInDur(200), fadeOutDur(300)
, angle(0), angleDev(0), velocity(0), velocityDev(0), emissionCarry(0.)
, addParticleTime(0), addParticleCount(0), lastAdvTime(0)
- , emitting(true), motion(0), pendingPixmapCache(false), clock(this)
+ , motion(0), pendingPixmapCache(false), clock(this)
{
}
@@ -407,7 +407,6 @@ public:
int addParticleTime;
int addParticleCount;
int lastAdvTime;
- bool emitting;
QmlGraphicsParticleMotion *motion;
QmlGraphicsParticlesPainter *paintItem;
@@ -443,14 +442,14 @@ void QmlGraphicsParticlesPrivate::tick(int time)
}
if(emissionRate == -1)//Otherwise leave emission to the emission rate
- while(removed-- && ((count == -1) || particles.count() < count) && emitting)
+ while(removed-- && ((count == -1) || particles.count() < count))
createParticle(time);
if (!addParticleTime)
addParticleTime = time;
//Possibly emit new particles
- if (((count == -1) || particles.count() < count) && emitting
+ if (((count == -1) || particles.count() < count) && emissionRate
&& !(count==-1 && emissionRate==-1)) {
int emissionCount = -1;
if (emissionRate != -1){
@@ -497,7 +496,7 @@ void QmlGraphicsParticlesPrivate::tick(int time)
lastAdvTime = time;
paintItem->updateSize();
paintItem->update();
- if (!(oldCount || particles.count()) && (!count || !emitting) && bursts.isEmpty()) {
+ if (!(oldCount || particles.count()) && (!count || !emissionRate) && bursts.isEmpty()) {
lastAdvTime = 0;
clock.stop();
}
@@ -733,7 +732,7 @@ void QmlGraphicsParticles::setCount(int cnt)
d->count = cnt;
d->addParticleTime = 0;
d->addParticleCount = d->particles.count();
- if (!oldCount && d->clock.state() != QAbstractAnimation::Running && d->count && d->emitting) {
+ if (!oldCount && d->clock.state() != QAbstractAnimation::Running && d->count && d->emissionRate) {
d->clock.start();
}
d->paintItem->updateSize();
@@ -774,6 +773,9 @@ void QmlGraphicsParticles::setEmissionRate(int er)
if(er == d->emissionRate)
return;
d->emissionRate = er;
+ if (d->clock.state() != QAbstractAnimation::Running && d->count && d->emissionRate) {
+ d->clock.start();
+ }
emit emissionRateChanged();
}
@@ -1100,42 +1102,6 @@ void QmlGraphicsParticles::setVelocityDeviation(qreal velocity)
}
/*!
- \qmlproperty bool Particles::emitting
- This property determines whether new particles are created
-
- If emitting is set to false no new particles will be created. This means that
- when a particle reaches the end of its lifespan it is not replaced. This
- property can be used to turn particles on and off with a more natural look.
-
- The default setting is true. Note that if it initialized to false no particles
- will be produced until it is set to true.
-*/
-/*!
- \property QmlGraphicsParticles::emitting
- If emitting is set to false no new particles will be created. This means that
- when a particle reaches the end of its lifespan it is not replaced. This
- property can be used to turn particles on and off with a more natural look.
-
- The default setting is true. Note that if it initialized to false no particles
- will be produced until it is set to true.
-*/
-bool QmlGraphicsParticles::emitting() const
-{
- Q_D(const QmlGraphicsParticles);
- return d->emitting;
-}
-
-void QmlGraphicsParticles::setEmitting(bool r)
-{
- Q_D(QmlGraphicsParticles);
- if(d->emitting == r)
- return;
- d->emitting = r;
- if (d->count && r)
- d->clock.start();
- emit emittingChanged();
-}
-/*!
\qmlproperty ParticleMotion Particles::motion
This property sets the type of motion to apply to the particles.
@@ -1178,7 +1144,7 @@ void QmlGraphicsParticles::setMotion(QmlGraphicsParticleMotion *motion)
burst. If the second argument is omitted, it is treated as -1. The burst
of particles has a separate emissionRate and count to the normal emission of
particles. The burst uses the same values as normal emission for all other
- properties, including emissionVariance and emitting.
+ properties, including emissionVariance.
The normal emission of particles will continue during the burst, however
the particles created by the burst count towards the maximum number used by
@@ -1189,7 +1155,7 @@ void QmlGraphicsParticles::burst(int count, int emissionRate)
{
Q_D(QmlGraphicsParticles);
d->bursts << qMakePair(count, emissionRate);
- if (d->clock.state() != QAbstractAnimation::Running && d->emitting)
+ if (d->clock.state() != QAbstractAnimation::Running)
d->clock.start();
}
diff --git a/src/declarative/graphicsitems/qmlgraphicsparticles_p.h b/src/declarative/graphicsitems/qmlgraphicsparticles_p.h
index 02c4e6d..3cb3ff6 100644
--- a/src/declarative/graphicsitems/qmlgraphicsparticles_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicsparticles_p.h
@@ -157,7 +157,6 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsParticles : public QmlGraphicsItem
Q_PROPERTY(qreal angleDeviation READ angleDeviation WRITE setAngleDeviation NOTIFY angleDeviationChanged)
Q_PROPERTY(qreal velocity READ velocity WRITE setVelocity NOTIFY velocityChanged)
Q_PROPERTY(qreal velocityDeviation READ velocityDeviation WRITE setVelocityDeviation NOTIFY velocityDeviationChanged)
- Q_PROPERTY(bool emitting READ emitting WRITE setEmitting NOTIFY emittingChanged)
Q_PROPERTY(QmlGraphicsParticleMotion *motion READ motion WRITE setMotion)
Q_CLASSINFO("DefaultProperty", "motion")
@@ -201,9 +200,6 @@ public:
qreal velocityDeviation() const;
void setVelocityDeviation(qreal);
- bool emitting() const;
- void setEmitting(bool);
-
QmlGraphicsParticleMotion *motion() const;
void setMotion(QmlGraphicsParticleMotion *);
diff --git a/tests/auto/declarative/qmlgraphicsparticles/tst_qmlgraphicsparticles.cpp b/tests/auto/declarative/qmlgraphicsparticles/tst_qmlgraphicsparticles.cpp
index c8d181b..ed68eaf 100644
--- a/tests/auto/declarative/qmlgraphicsparticles/tst_qmlgraphicsparticles.cpp
+++ b/tests/auto/declarative/qmlgraphicsparticles/tst_qmlgraphicsparticles.cpp
@@ -96,9 +96,6 @@ void tst_QmlGraphicsParticles::properties()
particles->setEmissionRate(12);
QCOMPARE(particles->emissionRate(), 12);
-
- particles->setEmitting(false);
- QCOMPARE(particles->emitting(), false);
}
void tst_QmlGraphicsParticles::runs()
diff --git a/tests/auto/declarative/visual/qmlgraphicsparticles/particles.qml b/tests/auto/declarative/visual/qmlgraphicsparticles/particles.qml
index a7a8143..2d481c9 100644
--- a/tests/auto/declarative/visual/qmlgraphicsparticles/particles.qml
+++ b/tests/auto/declarative/visual/qmlgraphicsparticles/particles.qml
@@ -3,7 +3,12 @@ import Qt 4.6
Rectangle {
width: 640; height: 480; color: "black"
- Particles { emitting: false }
+ Particles { id:particlesAnotEmitting
+ y:60; width: 260; height:30; source: "star.png";
+ lifeSpan:1000; count: 50; angle:70; angleDeviation:36;
+ velocity:30; velocityDeviation:10; emissionRate: 0
+ ParticleMotionWander { yvariance:5; xvariance:30; pace:100 }
+ }
Particles { id:particlesA
y:0; width: 260; height:30; source: "star.png";
lifeSpan:1000; count: 50; angle:70; angleDeviation:36;