while properties are cool and all, let's not take the slow path just because we can.
This commit is contained in:
parent
34376c31b1
commit
109453976a
@ -757,20 +757,19 @@ void IconWidgetPrivate::animateMainIcon(bool show, const IconWidgetStates state)
|
|||||||
QPropertyAnimation *animation = hoverAnimation->animation();
|
QPropertyAnimation *animation = hoverAnimation->animation();
|
||||||
if (!animation) {
|
if (!animation) {
|
||||||
animation = new QPropertyAnimation(hoverAnimation, "value");
|
animation = new QPropertyAnimation(hoverAnimation, "value");
|
||||||
animation->setProperty("duration", 150);
|
animation->setDuration(150);
|
||||||
animation->setProperty("easingCurve", QEasingCurve::OutQuad);
|
animation->setEasingCurve(QEasingCurve::OutQuad);
|
||||||
animation->setProperty("startValue", 0.0);
|
animation->setStartValue(0.0);
|
||||||
animation->setProperty("endValue", 1.0);
|
animation->setEndValue(1.0);
|
||||||
hoverAnimation->setAnimation(animation);
|
hoverAnimation->setAnimation(animation);
|
||||||
q->connect(animation, SIGNAL(finished()), q, SLOT(hoverAnimationFinished()));
|
q->connect(animation, SIGNAL(finished()), q, SLOT(hoverAnimationFinished()));
|
||||||
} else if (animation->state() == QAbstractAnimation::Running) {
|
} else if (animation->state() == QAbstractAnimation::Running) {
|
||||||
animation->pause();
|
animation->pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
animation->setProperty("direction", show ?
|
animation->setDirection(show ? QAbstractAnimation::Forward : QAbstractAnimation::Backward);
|
||||||
QAbstractAnimation::Forward : QAbstractAnimation::Backward);
|
animation->start(show ? QAbstractAnimation::KeepWhenStopped : QAbstractAnimation::DeleteWhenStopped);
|
||||||
animation->start(show ?
|
q->update();
|
||||||
QAbstractAnimation::KeepWhenStopped : QAbstractAnimation::DeleteWhenStopped);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IconWidgetPrivate::hoverAnimationFinished()
|
void IconWidgetPrivate::hoverAnimationFinished()
|
||||||
@ -1474,7 +1473,6 @@ void IconWidget::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
|||||||
|
|
||||||
d->oldIcon = QIcon();
|
d->oldIcon = QIcon();
|
||||||
d->animateMainIcon(true, d->states|IconWidgetPrivate::HoverState);
|
d->animateMainIcon(true, d->states|IconWidgetPrivate::HoverState);
|
||||||
update();
|
|
||||||
|
|
||||||
QGraphicsWidget::hoverEnterEvent(event);
|
QGraphicsWidget::hoverEnterEvent(event);
|
||||||
}
|
}
|
||||||
@ -1491,7 +1489,6 @@ void IconWidget::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
|||||||
d->states &= ~IconWidgetPrivate::PressedState;
|
d->states &= ~IconWidgetPrivate::PressedState;
|
||||||
|
|
||||||
d->animateMainIcon(false, d->states|IconWidgetPrivate::HoverState);
|
d->animateMainIcon(false, d->states|IconWidgetPrivate::HoverState);
|
||||||
update();
|
|
||||||
|
|
||||||
QGraphicsWidget::hoverLeaveEvent(event);
|
QGraphicsWidget::hoverLeaveEvent(event);
|
||||||
}
|
}
|
||||||
@ -1502,10 +1499,8 @@ bool IconWidget::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
|
|||||||
|
|
||||||
if (event->type() == QEvent::GraphicsSceneDragEnter) {
|
if (event->type() == QEvent::GraphicsSceneDragEnter) {
|
||||||
d->animateMainIcon(true, d->states|IconWidgetPrivate::HoverState);
|
d->animateMainIcon(true, d->states|IconWidgetPrivate::HoverState);
|
||||||
update();
|
|
||||||
} else if (event->type() == QEvent::GraphicsSceneDragLeave) {
|
} else if (event->type() == QEvent::GraphicsSceneDragLeave) {
|
||||||
d->animateMainIcon(false, d->states|IconWidgetPrivate::HoverState);
|
d->animateMainIcon(false, d->states|IconWidgetPrivate::HoverState);
|
||||||
update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user