diff --git a/private/tooltip.cpp b/private/tooltip.cpp index 707e4f791..fdeda2f0c 100644 --- a/private/tooltip.cpp +++ b/private/tooltip.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include #ifdef Q_WS_X11 #include #include @@ -135,7 +135,6 @@ class ToolTipPrivate : text(0), imageLabel(0), preview(0), - timeline(0), direction(Plasma::Up), autohide(true) { } @@ -145,9 +144,7 @@ class ToolTipPrivate WindowPreview *preview; FrameSvg *background; QWeakPointer source; - QTimeLine *timeline; - QPoint to; - QPoint from; + QPropertyAnimation *animation; Plasma::Direction direction; bool autohide; }; @@ -163,6 +160,10 @@ ToolTip::ToolTip(QWidget *parent) d->imageLabel = new QLabel(this); d->imageLabel->setAlignment(Qt::AlignTop | Qt::AlignLeft); + d->animation = new QPropertyAnimation(this, "pos", this); + d->animation->setEasingCurve(QEasingCurve::InOutQuad); + d->animation->setDuration(250); + d->background = new FrameSvg(this); d->background->setImagePath("widgets/tooltip"); d->background->setEnabledBorders(FrameSvg::AllBorders); @@ -319,33 +320,11 @@ void ToolTip::moveTo(const QPoint &to) return; } - d->from = QPoint(); - d->to = to; - - if (!d->timeline) { - d->timeline = new QTimeLine(250, this); - d->timeline->setFrameRange(0, 10); - d->timeline->setCurveShape(QTimeLine::EaseInCurve); - connect(d->timeline, SIGNAL(valueChanged(qreal)), this, SLOT(animateMove(qreal))); + if (d->animation->state() == QAbstractAnimation::Running) { + d->animation->stop(); } - - d->timeline->stop(); - d->timeline->start(); -} - -void ToolTip::animateMove(qreal progress) -{ - if (d->from.isNull()) { - d->from = pos(); - } - - if (qFuzzyCompare(progress, qreal(1.0))) { - move(d->to); - return; - } - - move(d->from.x() + ((d->to.x() - d->from.x()) * progress), - d->from.y() + ((d->to.y() - d->from.y()) * progress)); + d->animation->setEndValue(to); + d->animation->start(); } void ToolTip::resizeEvent(QResizeEvent *e) diff --git a/private/tooltip_p.h b/private/tooltip_p.h index 98a6a8c6d..94cd2fb05 100644 --- a/private/tooltip_p.h +++ b/private/tooltip_p.h @@ -67,7 +67,6 @@ protected: private Q_SLOTS: void updateTheme(); - void animateMove(qreal); private: ToolTipPrivate * const d;