18 #include "widgetsnapshot_p.h"
22 #include <QGraphicsWidget>
23 #include <QParallelAnimationGroup>
24 #include <QPropertyAnimation>
25 #include <QWeakPointer>
32 PulseAnimation::PulseAnimation(
QObject *parent)
33 : EasingAnimation(parent),
41 PulseAnimation::~PulseAnimation()
43 delete m_under.data();
46 void PulseAnimation::setTargetScale(qreal scale)
51 qreal PulseAnimation::targetScale()
const
56 void PulseAnimation::setCopy()
65 if (!m_under.data()) {
66 m_under =
new WidgetSnapShot;
69 m_under.data()->setTarget(target);
71 m_zvalue = target->
zValue() - 1;
72 m_scale = target->
scale();
74 m_under.data()->setOpacity(m_opacity);
75 m_under.data()->setScale(m_scale);
76 m_under.data()->setZValue(m_zvalue);
79 void PulseAnimation::resetPulser()
82 m_under.data()->setOpacity(m_opacity);
83 m_under.data()->setScale(m_scale);
84 m_under.data()->setZValue(m_zvalue);
85 m_under.data()->hide();
89 void PulseAnimation::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState)
91 if (!targetWidget()) {
95 if (oldState == Stopped && newState == Running) {
96 if (!m_under.data() || m_under.data()->target() != targetWidget() || m_under.data()->size() != targetWidget()->size()) {
100 if (m_under.data()->isIconBigger()) {
101 m_under.data()->setScale(0);
109 if (m_under.data()->isVisible() ==
false) {
110 m_under.data()->setVisible(
true);
113 m_under.data()->setOpacity(direction() == Forward ? 1 : 0);
114 m_under.data()->setScale(direction() == Forward ? m_scale : m_endScale);
115 }
else if (newState == Stopped) {
120 void PulseAnimation::updateEffectiveTime(
int currentTime)
122 if (m_under.data()) {
123 qreal delta = currentTime / qreal(duration());
125 if (m_under.data()->isIconBigger()) {
126 m_under.data()->setScale(delta);
128 m_under.data()->setScale(delta);
129 delta = (1 - m_endScale) * delta;
130 m_under.data()->setScale(1 - delta);
133 delta = currentTime / qreal(duration());
134 if (direction() == Forward) {
135 m_under.data()->setOpacity(1.0 - delta);
136 }
else if (direction() == Backward) {
137 m_under.data()->setOpacity(delta);
144 #include "pulser_p.moc"