Line | Source | Count |
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | QWidgetAnimator::QWidgetAnimator(QMainWindowLayout *layout) : m_mainWindowLayout(layout) | - |
6 | { | - |
7 | } | - |
8 | | - |
9 | void QWidgetAnimator::abort(QWidget *w) | - |
10 | { | - |
11 | | - |
12 | AnimationMap::iteratorconst auto it = m_animation_map.findconstFind(w); | - |
13 | if (it == m_animation_map.endcend()TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
14 | return; never executed: return; | 0 |
15 | QPropertyAnimation *anim = *it; | - |
16 | m_animation_map.erase(it); | - |
17 | if (animTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
18 | anim->stop(); | - |
19 | } never executed: end of block | 0 |
20 | | - |
21 | m_mainWindowLayout->animationFinished(w); | - |
22 | | - |
23 | | - |
24 | | - |
25 | | - |
26 | } never executed: end of block | 0 |
27 | | - |
28 | | - |
29 | void QWidgetAnimator::animationFinished() | - |
30 | { | - |
31 | QPropertyAnimation *anim = qobject_cast<QPropertyAnimation*>(sender()); | - |
32 | abort(static_cast<QWidget*>(anim->targetObject())); | - |
33 | } | - |
34 | | - |
35 | | - |
36 | void QWidgetAnimator::animate(QWidget *widget, const QRect &_final_geometry, bool animate) | - |
37 | { | - |
38 | QRect r = widget->geometry(); | - |
39 | if (r.right() < 0 || r.bottom() < 0) | - |
40 | r = QRect(); | - |
41 | | - |
42 | animate = animate && !r.isNull() && !_final_geometry.isNull(); | - |
43 | | - |
44 | | - |
45 | const QRect final_geometry = _final_geometry.isValid() || widget->isWindow() ? _final_geometry : | - |
46 | QRect(QPoint(-500 - widget->width(), -500 - widget->height()), widget->size()); | - |
47 | | - |
48 | | - |
49 | | - |
50 | if (widget->style()->styleHint(QStyle::SH_Widget_Animate, 0, widget)) { | - |
51 | AnimationMap::const_iterator it = m_animation_map.constFind(widget); | - |
52 | if (it != m_animation_map.constEnd() && (*it)->endValue().toRect() == final_geometry) | - |
53 | return; | - |
54 | | - |
55 | QPropertyAnimation *anim = new QPropertyAnimation(widget, "geometry", widget); | - |
56 | anim->setDuration(animate ? 200 : 0); | - |
57 | anim->setEasingCurve(QEasingCurve::InOutQuad); | - |
58 | anim->setEndValue(final_geometry); | - |
59 | m_animation_map[widget] = anim; | - |
60 | connect(anim, qFlagLocation("2""finished()" "\0" __FILE__ ":" "98""104"), qFlagLocation("1""animationFinished()" "\0" __FILE__ ":" "98""104")); | - |
61 | anim->start(QPropertyAnimation::DeleteWhenStopped); | - |
62 | } else | - |
63 | | - |
64 | { | - |
65 | | - |
66 | widget->setGeometry(final_geometry); | - |
67 | | - |
68 | m_mainWindowLayout->animationFinished(widget); | - |
69 | | - |
70 | } | - |
71 | } | - |
72 | | - |
73 | bool QWidgetAnimator::animating() const | - |
74 | { | - |
75 | return !m_animation_map.isEmpty(); | - |
76 | } | - |
77 | | - |
78 | | - |
79 | | - |
| | |