| 1 | // Copyright (C) 2024 The Qt Company Ltd. |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #include "qgraphanimation_p.h" |
| 5 | #include <private/qgraphanimation_p.h> |
| 6 | |
| 7 | QT_BEGIN_NAMESPACE |
| 8 | |
| 9 | /*! |
| 10 | \qmltype GraphAnimation |
| 11 | \qmlabstract |
| 12 | \inqmlmodule QtGraphs |
| 13 | \ingroup graphs_qml_2D |
| 14 | \brief The GraphAnimation type is the base type for all animations for 2D Qt Graphs series. |
| 15 | |
| 16 | GraphAnimation is based on VariantAnimation and provides an interface for interpolation for child animations. |
| 17 | This type is an abstract type and doesn't have any default implementation for interpolation. Its derived types |
| 18 | should be used for the respective animations, such as GraphPointAnimation, SplineControlAnimation. |
| 19 | */ |
| 20 | |
| 21 | /*! |
| 22 | \qmlproperty GraphAnimation::AnimationState GraphAnimation::animating |
| 23 | |
| 24 | Holds the animation state. One of \l {GraphAnimation::AnimationState}. |
| 25 | */ |
| 26 | |
| 27 | /*! |
| 28 | \qmlproperty enumeration GraphAnimation::AnimationState |
| 29 | |
| 30 | Animation states. |
| 31 | |
| 32 | \value Playing |
| 33 | Animation is playing. |
| 34 | \value Stopped |
| 35 | Animation is stopped. |
| 36 | */ |
| 37 | |
| 38 | /*! |
| 39 | \qmlproperty enumeration GraphAnimation::GraphAnimationType |
| 40 | |
| 41 | Animation type. |
| 42 | |
| 43 | \value GraphPoint |
| 44 | A GraphPointAnimation animation. |
| 45 | \value ControlPoint |
| 46 | A ControlPointAnimation animation. |
| 47 | */ |
| 48 | |
| 49 | Q_LOGGING_CATEGORY(lcAnimation, "qt.graphs2d.animation") |
| 50 | |
| 51 | QGraphAnimation::QGraphAnimation(QObject *parent) |
| 52 | : QVariantAnimation(parent) |
| 53 | { |
| 54 | connect(sender: this, signal: &QVariantAnimation::valueChanged, context: this, slot: &QGraphAnimation::valueUpdated); |
| 55 | connect(sender: this, signal: &QVariantAnimation::finished, context: this, slot: &QGraphAnimation::end); |
| 56 | } |
| 57 | |
| 58 | QGraphAnimation::~QGraphAnimation() |
| 59 | { |
| 60 | stop(); |
| 61 | } |
| 62 | |
| 63 | QGraphAnimation::AnimationState QGraphAnimation::animating() const |
| 64 | { |
| 65 | return m_animating; |
| 66 | } |
| 67 | |
| 68 | void QGraphAnimation::setAnimating(AnimationState newAnimating) |
| 69 | { |
| 70 | if (m_animating == newAnimating) { |
| 71 | qCDebug(lcAnimation) << "QGraphAnimation::setAnimating. AnimationState is already set to: "<< newAnimating; |
| 72 | return; |
| 73 | } |
| 74 | m_animating = newAnimating; |
| 75 | |
| 76 | qCDebug(lcAnimation) << "animation state:"<< m_animating; |
| 77 | emit animatingChanged(); |
| 78 | } |
| 79 | |
| 80 | QT_END_NAMESPACE |
| 81 |
