void TaskEditor::startAnimation(QSizeF endSize, bool show) {
    appearing = show;
    if (appearing)
      foreach(QGraphicsItem* child, childItems())
        child->show();

    this->show();

    fullSize = endSize;
    resize(fullSize);

    Plasma::Animation *animation = m_fadeAnimation.data();
    if (!animation) {
      animation = Plasma::Animator::create(Plasma::Animator::FadeAnimation);
      animation->setTargetWidget(this);
      animation->setProperty("startValue", 0.0);
      animation->setProperty("endValue", 1.0);
      animation->setProperty("duration", 100);
      m_fadeAnimation = animation;
      connect(animation, SIGNAL(finished()), this, SLOT(animationFinished()));
    } else if (animation->state() == QAbstractAnimation::Running) {
      animation->pause();
    }

    if (show) {
      animation->setProperty("easingCurve", QEasingCurve::InQuad);
      animation->setProperty("direction", QAbstractAnimation::Forward);
      animation->start(QAbstractAnimation::KeepWhenStopped);
    } else {
      animation->setProperty("easingCurve", QEasingCurve::OutQuad);
      animation->setProperty("direction", QAbstractAnimation::Backward);
      animation->start(QAbstractAnimation::DeleteWhenStopped);
    }
}
Esempio n. 2
0
void FlashingLabel::fadeIn()
{
    //kDebug();
    if (d->autohide) {
        show();
    }

    d->state = FlashingLabelPrivate::Visible;
    if (!d->anim.data()) {
        d->anim = Plasma::Animator::create(Plasma::Animator::PixmapTransitionAnimation);
        Plasma::Animation *animation = d->anim.data();
        animation->setProperty("startPixmap", d->renderedPixmap);
        animation->setTargetWidget(this);
        animation->start();
    } else {
        Plasma::Animation *animation = d->anim.data();
        if (animation->state() == QAbstractAnimation::Running) {
            animation->stop();
            animation->start();
        }
    }
}