From dd15c33c2bcc88e3b91dabdd9bac27d2be498804 Mon Sep 17 00:00:00 2001 From: Aaron Seigo Date: Fri, 2 Dec 2011 10:39:48 +0100 Subject: [PATCH] while properties are cool and all, let's not take the slow path just because we can. --- widgets/iconwidget.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/widgets/iconwidget.cpp b/widgets/iconwidget.cpp index 00b42cae0..1161cc4d2 100644 --- a/widgets/iconwidget.cpp +++ b/widgets/iconwidget.cpp @@ -751,20 +751,19 @@ void IconWidgetPrivate::animateMainIcon(bool show, const IconWidgetStates state) QPropertyAnimation *animation = hoverAnimation->animation(); if (!animation) { animation = new QPropertyAnimation(hoverAnimation, "value"); - animation->setProperty("duration", 150); - animation->setProperty("easingCurve", QEasingCurve::OutQuad); - animation->setProperty("startValue", 0.0); - animation->setProperty("endValue", 1.0); + animation->setDuration(150); + animation->setEasingCurve(QEasingCurve::OutQuad); + animation->setStartValue(0.0); + animation->setEndValue(1.0); hoverAnimation->setAnimation(animation); q->connect(animation, SIGNAL(finished()), q, SLOT(hoverAnimationFinished())); } else if (animation->state() == QAbstractAnimation::Running) { animation->pause(); } - animation->setProperty("direction", show ? - QAbstractAnimation::Forward : QAbstractAnimation::Backward); - animation->start(show ? - QAbstractAnimation::KeepWhenStopped : QAbstractAnimation::DeleteWhenStopped); + animation->setDirection(show ? QAbstractAnimation::Forward : QAbstractAnimation::Backward); + animation->start(show ? QAbstractAnimation::KeepWhenStopped : QAbstractAnimation::DeleteWhenStopped); + q->update(); } void IconWidgetPrivate::hoverAnimationFinished() @@ -1468,7 +1467,6 @@ void IconWidget::hoverEnterEvent(QGraphicsSceneHoverEvent *event) d->oldIcon = QIcon(); d->animateMainIcon(true, d->states|IconWidgetPrivate::HoverState); - update(); QGraphicsWidget::hoverEnterEvent(event); } @@ -1485,7 +1483,6 @@ void IconWidget::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) d->states &= ~IconWidgetPrivate::PressedState; d->animateMainIcon(false, d->states|IconWidgetPrivate::HoverState); - update(); QGraphicsWidget::hoverLeaveEvent(event); } @@ -1496,10 +1493,8 @@ bool IconWidget::sceneEventFilter(QGraphicsItem *watched, QEvent *event) if (event->type() == QEvent::GraphicsSceneDragEnter) { d->animateMainIcon(true, d->states|IconWidgetPrivate::HoverState); - update(); } else if (event->type() == QEvent::GraphicsSceneDragLeave) { d->animateMainIcon(false, d->states|IconWidgetPrivate::HoverState); - update(); } return false;