src/hbcore/image/hbiconanimation.cpp
changeset 5 627c4a0fd0e7
parent 0 16d8024aca5e
child 21 4633027730f5
child 34 ed14f46c0e55
equal deleted inserted replaced
3:11d3954df52a 5:627c4a0fd0e7
    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;
    96 
    96 
    97 QColor HbIconAnimation::color() const
    97 QColor HbIconAnimation::color() const
    98 {
    98 {
    99     return mColor;
    99     return mColor;
   100 }
   100 }
   101 	
   101 
   102 void HbIconAnimation::setColor(const QColor &color)
   102 void HbIconAnimation::setColor(const QColor &color)
   103 {
   103 {
   104     mColor = color;
   104     mColor = color;
   105 }
   105 }
   106 
   106 
   276         painter.end();
   276         painter.end();
   277 
   277 
   278         // Apply mirroring if required
   278         // Apply mirroring if required
   279         if (mMirrored) {
   279         if (mMirrored) {
   280             QTransform t;
   280             QTransform t;
   281             t.scale(-1,1);
   281             t.scale(-1, 1);
   282             canvasPixmap = canvasPixmap.transformed(t);
   282             canvasPixmap = canvasPixmap.transformed(t);
   283         }
   283         }
   284 
   284 
   285         // Apply mode
   285         // Apply mode
   286         if (mMode != QIcon::Normal) {
   286         if (mMode != QIcon::Normal) {
   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 }
   415         }
   415         }
   416     }
   416     }
   417 
   417 
   418     // Inform client to update display
   418     // Inform client to update display
   419     emit animationUpdated();
   419     emit animationUpdated();
   420     
   420 
   421     notifyAnimationStopped();
   421     notifyAnimationStopped();
   422 }
   422 }
   423 
   423 
   424 void HbIconAnimationImage::pause()
   424 void HbIconAnimationImage::pause()
   425 {
   425 {
   446         }
   446         }
   447 
   447 
   448         // Apply mirroring if required
   448         // Apply mirroring if required
   449         if (mMirrored) {
   449         if (mMirrored) {
   450             QTransform t;
   450             QTransform t;
   451             t.scale(-1,1);
   451             t.scale(-1, 1);
   452             canvasPixmap = canvasPixmap.transformed(t);
   452             canvasPixmap = canvasPixmap.transformed(t);
   453         }
   453         }
   454 
   454 
   455         // Apply mode
   455         // Apply mode
   456         if (mMode != QIcon::Normal) {
   456         if (mMode != QIcon::Normal) {
   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;