54 mColor(QColor()), |
54 mColor(QColor()), |
55 mAnimator(animator), |
55 mAnimator(animator), |
56 mView(0), |
56 mView(0), |
57 mPaused(false), |
57 mPaused(false), |
58 mPausedDueToBackground(false) |
58 mPausedDueToBackground(false) |
59 { |
59 { |
60 Q_ASSERT(!(animator->d->animation)); |
60 Q_ASSERT(!(animator->d->animation)); |
61 // Set the animation in the animator, it takes ownership of this object. |
61 // Set the animation in the animator, it takes ownership of this object. |
62 animator->d->animation = this; |
62 animator->d->animation = this; |
63 |
63 |
64 #ifdef HB_ICON_TRACES |
64 #ifdef HB_ICON_TRACES |
65 qDebug() << "HbIconAnimation created: " << mIconName; |
65 qDebug() << "HbIconAnimation created: " << mIconName; |
66 #endif |
66 #endif |
67 } |
67 } |
68 |
68 |
69 HbIconAnimation::~HbIconAnimation() |
69 HbIconAnimation::~HbIconAnimation() |
70 { |
70 { |
71 #ifdef HB_ICON_TRACES |
71 #ifdef HB_ICON_TRACES |
72 qDebug() << "HbIconAnimation destroyed: " << mIconName; |
72 qDebug() << "HbIconAnimation destroyed: " << mIconName; |
379 |
379 |
380 // Recreate the image reader. It's slow but QImageReader::jumpToImage does not work. |
380 // Recreate the image reader. It's slow but QImageReader::jumpToImage does not work. |
381 delete mImageRenderer; |
381 delete mImageRenderer; |
382 mImageRenderer = 0; |
382 mImageRenderer = 0; |
383 mImageRenderer = new QImageReader(mIconFileName, mType == MNG ? "MNG" : "GIF"); |
383 mImageRenderer = new QImageReader(mIconFileName, mType == MNG ? "MNG" : "GIF"); |
384 |
384 |
385 // New image reader starts from the first frame. Handle animation update. |
385 // New image reader starts from the first frame. Handle animation update. |
386 notifyAnimationStarted(); |
386 notifyAnimationStarted(); |
387 handleAnimationUpdated(); |
387 handleAnimationUpdated(); |
388 } |
388 } |
389 } |
389 } |
505 notifyAnimationFinished(); |
505 notifyAnimationFinished(); |
506 } |
506 } |
507 } |
507 } |
508 |
508 |
509 HbIconAnimationFrameSet::HbIconAnimationFrameSet( |
509 HbIconAnimationFrameSet::HbIconAnimationFrameSet( |
510 HbIconAnimator *animator, const QString &iconName,const QList<FrameData> &frames) : |
510 HbIconAnimator *animator, const QString &iconName, const QList<FrameData> &frames) : |
511 HbIconAnimation(animator, iconName), |
511 HbIconAnimation(animator, iconName), |
512 mFrames(frames), |
512 mFrames(frames), |
513 mCurrentFrameIndex(0), |
513 mCurrentFrameIndex(0), |
514 mTimerEntry(0) |
514 mTimerEntry(0) |
515 { |
515 { |
516 // Do not start the timer or initiate any signal emission here. |
516 // Do not start the timer or initiate any signal emission here. |
517 // Do it in start() instead, since mFresh is true by default. |
517 // Do it in start() instead, since mFresh is true by default. |
518 } |
518 } |
519 |
519 |
621 for (int i = 0, ie = mFrames[mCurrentFrameIndex].jumps.count(); i != ie; ++i) { |
621 for (int i = 0, ie = mFrames[mCurrentFrameIndex].jumps.count(); i != ie; ++i) { |
622 JumpData &jumpData(mFrames[mCurrentFrameIndex].jumps[i]); |
622 JumpData &jumpData(mFrames[mCurrentFrameIndex].jumps[i]); |
623 if (jumpData.execCount < jumpData.repeatCount) { |
623 if (jumpData.execCount < jumpData.repeatCount) { |
624 ++jumpData.execCount; |
624 ++jumpData.execCount; |
625 // Before returning, the exec counts of all previous jumps in |
625 // Before returning, the exec counts of all previous jumps in |
626 // this frame must be resetted, because they were caused by |
626 // this frame must be reset, because they were caused by |
627 // <loop> elements that were embedded into the <loop> that |
627 // <loop> elements that were embedded into the <loop> that |
628 // generated this jump. |
628 // generated this jump. |
629 for (int j = 0; j < i; ++j) { |
629 for (int j = 0; j < i; ++j) { |
630 mFrames[mCurrentFrameIndex].jumps[j].execCount = 0; |
630 mFrames[mCurrentFrameIndex].jumps[j].execCount = 0; |
631 } |
631 } |
632 // And similarly, all jumps in frames that fall between the |
632 // And similarly, all jumps in frames that fall between the |
633 // target (incl.) and the current frame (excl.) must be |
633 // target (incl.) and the current frame (excl.) must be |
634 // resetted. Note that jumping forward is not supported and such |
634 // reset. Note that jumping forward is not supported and such |
635 // jumps are never generated by the animation xml parser. |
635 // jumps are never generated by the animation xml parser. |
636 for (int j = jumpData.targetFrameIndex; j < mCurrentFrameIndex; ++j) { |
636 for (int j = jumpData.targetFrameIndex; j < mCurrentFrameIndex; ++j) { |
637 resetJumpCount(mFrames[j]); |
637 resetJumpCount(mFrames[j]); |
638 } |
638 } |
639 mCurrentFrameIndex = jumpData.targetFrameIndex; |
639 mCurrentFrameIndex = jumpData.targetFrameIndex; |