while properties are cool and all, let's not take the slow path just because we can.
This commit is contained in:
parent
a97d486876
commit
dd15c33c2b
@ -751,20 +751,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()
|
||||||
@ -1468,7 +1467,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);
|
||||||
}
|
}
|
||||||
@ -1485,7 +1483,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);
|
||||||
}
|
}
|
||||||
@ -1496,10 +1493,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