diff options
Diffstat (limited to 'examples/demos/robotarm/Backend/animatedparam.cpp')
-rw-r--r-- | examples/demos/robotarm/Backend/animatedparam.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/examples/demos/robotarm/Backend/animatedparam.cpp b/examples/demos/robotarm/Backend/animatedparam.cpp new file mode 100644 index 00000000..e72678e3 --- /dev/null +++ b/examples/demos/robotarm/Backend/animatedparam.cpp @@ -0,0 +1,35 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +#include "animatedparam.h" + +#include <QVariantAnimation> + +AnimatedParam::AnimatedParam(QObject *parent) : QVariantAnimation(parent) +{ + setDuration(1500); + setEasingCurve(QEasingCurve::InOutCubic); + + connect(this, &QVariantAnimation::valueChanged, this, &AnimatedParam::valueChanged); + connect(this, &QAbstractAnimation::stateChanged, this, [this](QAbstractAnimation::State newState, QAbstractAnimation::State) { + m_isRunning = (newState == QAbstractAnimation::Running); + }); +} + +int AnimatedParam::value() const +{ + return currentValue().toInt(); +} + +void AnimatedParam::setValue(int newValue) +{ + stop(); + setStartValue(value()); + setEndValue(newValue); + start(); +} + +bool AnimatedParam::isRunning() const +{ + return m_isRunning; +} |