Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquickanimation_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QQUICKANIMATION_H
5#define QQUICKANIMATION_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include "qquickstate_p.h"
19#include <QtGui/qvector3d.h>
20
22#include <qqml.h>
23#include <qqmlscriptstring.h>
24
25#include <QtCore/qvariant.h>
26#include <QtCore/qeasingcurve.h>
27#include "private/qabstractanimationjob_p.h"
28#include <QtGui/qcolor.h>
29
31
34class Q_QUICK_EXPORT QQuickAbstractAnimation : public QObject, public QQmlPropertyValueSource, public QQmlParserStatus
35{
37 Q_DECLARE_PRIVATE(QQuickAbstractAnimation)
38
41 Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY runningChanged)
42 Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged)
43 Q_PROPERTY(bool alwaysRunToEnd READ alwaysRunToEnd WRITE setAlwaysRunToEnd NOTIFY alwaysRunToEndChanged)
44 Q_PROPERTY(int loops READ loops WRITE setLoops NOTIFY loopCountChanged)
45 Q_CLASSINFO("DefaultMethod", "start()")
46
47 QML_NAMED_ELEMENT(Animation)
49 QML_UNCREATABLE("Animation is an abstract class")
50
51public:
57
58 QQuickAbstractAnimation(QObject *parent=nullptr);
59 ~QQuickAbstractAnimation() override;
60
61 enum Loops { Infinite = -2 };
62 Q_ENUM(Loops)
63
64 bool isRunning() const;
65 void setRunning(bool);
66 bool isPaused() const;
67 void setPaused(bool);
68 bool alwaysRunToEnd() const;
69 void setAlwaysRunToEnd(bool);
70
71 int loops() const;
72 void setLoops(int);
73 int duration() const;
74
75 int currentTime();
76 void setCurrentTime(int);
77
79 void setGroup(QQuickAnimationGroup *, int index = -1);
80
81 void setDefaultTarget(const QQmlProperty &);
82 void setDisableUserControl();
83 void setEnableUserControl();
84 bool userControlDisabled() const;
85 void classBegin() override;
86 void componentComplete() override;
87
88 virtual ThreadingModel threadingModel() const;
89
91 void started();
92 void stopped();
93 void runningChanged(bool);
94 void pausedChanged(bool);
97 Q_REVISION(2, 12) void finished();
98
99public Q_SLOTS:
100 void restart();
101 void start();
102 void pause();
103 void resume();
104 void stop();
105 void complete();
106
107protected:
110
111public:
112 enum TransitionDirection { Forward, Backward };
113 virtual QAbstractAnimationJob* transition(QQuickStateActions &actions,
114 QQmlProperties &modified,
115 TransitionDirection direction,
116 QObject *defaultTarget = nullptr);
117 QAbstractAnimationJob* qtAnimation();
118
119private:
120 void setTarget(const QQmlProperty &) override;
121 void notifyRunningChanged(bool running);
122 friend class QQuickBehavior;
125};
126
129{
131 Q_DECLARE_PRIVATE(QQuickPauseAnimation)
132
133 Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged)
134 QML_NAMED_ELEMENT(PauseAnimation)
136
137public:
138 QQuickPauseAnimation(QObject *parent=nullptr);
139 ~QQuickPauseAnimation() override;
140
141 int duration() const;
142 void setDuration(int);
143
145 void durationChanged(int);
146
147protected:
148 QAbstractAnimationJob* transition(QQuickStateActions &actions,
149 QQmlProperties &modified,
151 QObject *defaultTarget = nullptr) override;
152};
153
155class Q_QUICK_EXPORT QQuickScriptAction : public QQuickAbstractAnimation
156{
158 Q_DECLARE_PRIVATE(QQuickScriptAction)
159
160 Q_PROPERTY(QQmlScriptString script READ script WRITE setScript)
161 Q_PROPERTY(QString scriptName READ stateChangeScriptName WRITE setStateChangeScriptName)
162 QML_NAMED_ELEMENT(ScriptAction)
164
165public:
166 QQuickScriptAction(QObject *parent=nullptr);
167 ~QQuickScriptAction() override;
168
169 QQmlScriptString script() const;
170 void setScript(const QQmlScriptString &);
171
172 QString stateChangeScriptName() const;
173 void setStateChangeScriptName(const QString &);
174
175protected:
176 QAbstractAnimationJob* transition(QQuickStateActions &actions,
177 QQmlProperties &modified,
179 QObject *defaultTarget = nullptr) override;
180};
181
184{
186 Q_DECLARE_PRIVATE(QQuickPropertyAction)
187
188 Q_PROPERTY(QObject *target READ target WRITE setTargetObject NOTIFY targetChanged)
189 Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY propertyChanged)
190 Q_PROPERTY(QString properties READ properties WRITE setProperties NOTIFY propertiesChanged)
191 Q_PROPERTY(QQmlListProperty<QObject> targets READ targets)
192 Q_PROPERTY(QQmlListProperty<QObject> exclude READ exclude)
193 Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged)
194 QML_NAMED_ELEMENT(PropertyAction)
196
197public:
198 QQuickPropertyAction(QObject *parent=nullptr);
199 ~QQuickPropertyAction() override;
200
201 QObject *target() const;
202 void setTargetObject(QObject *);
203
204 QString property() const;
205 void setProperty(const QString &);
206
207 QString properties() const;
208 void setProperties(const QString &);
209
212
213 QVariant value() const;
214 void setValue(const QVariant &);
215
217 void valueChanged(const QVariant &);
218 void propertiesChanged(const QString &);
219 void targetChanged();
220 void propertyChanged();
221
222protected:
223 QAbstractAnimationJob* transition(QQuickStateActions &actions,
224 QQmlProperties &modified,
226 QObject *defaultTarget = nullptr) override;
227};
228
231{
233 Q_DECLARE_PRIVATE(QQuickPropertyAnimation)
234
235 Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged)
236 Q_PROPERTY(QVariant from READ from WRITE setFrom NOTIFY fromChanged)
237 Q_PROPERTY(QVariant to READ to WRITE setTo NOTIFY toChanged)
238 Q_PROPERTY(QEasingCurve easing READ easing WRITE setEasing NOTIFY easingChanged)
239 Q_PROPERTY(QObject *target READ target WRITE setTargetObject NOTIFY targetChanged)
240 Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY propertyChanged)
241 Q_PROPERTY(QString properties READ properties WRITE setProperties NOTIFY propertiesChanged)
242 Q_PROPERTY(QQmlListProperty<QObject> targets READ targets)
243 Q_PROPERTY(QQmlListProperty<QObject> exclude READ exclude)
244 QML_NAMED_ELEMENT(PropertyAnimation)
246
247public:
248 QQuickPropertyAnimation(QObject *parent=nullptr);
249 ~QQuickPropertyAnimation() override;
250
251 virtual int duration() const;
252 virtual void setDuration(int);
253
254 QVariant from() const;
255 void setFrom(const QVariant &);
256
257 QVariant to() const;
258 void setTo(const QVariant &);
259
260 QEasingCurve easing() const;
261 void setEasing(const QEasingCurve &);
262
263 QObject *target() const;
264 void setTargetObject(QObject *);
265
266 QString property() const;
267 void setProperty(const QString &);
268
269 QString properties() const;
270 void setProperties(const QString &);
271
274
275protected:
276 QQuickStateActions createTransitionActions(QQuickStateActions &actions,
277 QQmlProperties &modified,
278 QObject *defaultTarget = nullptr);
279
281 QAbstractAnimationJob* transition(QQuickStateActions &actions,
282 QQmlProperties &modified,
284 QObject *defaultTarget = nullptr) override;
286 void durationChanged(int);
287 void fromChanged();
288 void toChanged();
289 void easingChanged(const QEasingCurve &);
290 void propertiesChanged(const QString &);
291 void targetChanged();
292 void propertyChanged();
293};
294
296{
298 Q_DECLARE_PRIVATE(QQuickPropertyAnimation)
299 Q_PROPERTY(QColor from READ from WRITE setFrom)
300 Q_PROPERTY(QColor to READ to WRITE setTo)
301 QML_NAMED_ELEMENT(ColorAnimation)
303
304public:
305 QQuickColorAnimation(QObject *parent=nullptr);
306 ~QQuickColorAnimation() override;
307
308 QColor from() const;
309 void setFrom(const QColor &);
310
311 QColor to() const;
312 void setTo(const QColor &);
313};
314
316{
318 Q_DECLARE_PRIVATE(QQuickPropertyAnimation)
319
320 Q_PROPERTY(qreal from READ from WRITE setFrom NOTIFY fromChanged)
321 Q_PROPERTY(qreal to READ to WRITE setTo NOTIFY toChanged)
322 QML_NAMED_ELEMENT(NumberAnimation)
324
325public:
326 QQuickNumberAnimation(QObject *parent=nullptr);
327 ~QQuickNumberAnimation() override;
328
329 qreal from() const;
330 void setFrom(qreal);
331
332 qreal to() const;
333 void setTo(qreal);
334
335protected:
337
338private:
339 void init();
340};
341
343{
345 Q_DECLARE_PRIVATE(QQuickPropertyAnimation)
346
347 Q_PROPERTY(QVector3D from READ from WRITE setFrom NOTIFY fromChanged)
348 Q_PROPERTY(QVector3D to READ to WRITE setTo NOTIFY toChanged)
349 QML_NAMED_ELEMENT(Vector3dAnimation)
351
352public:
353 QQuickVector3dAnimation(QObject *parent=nullptr);
354 ~QQuickVector3dAnimation() override;
355
356 QVector3D from() const;
357 void setFrom(QVector3D);
358
359 QVector3D to() const;
360 void setTo(QVector3D);
361};
362
365{
367 Q_DECLARE_PRIVATE(QQuickRotationAnimation)
368
369 Q_PROPERTY(qreal from READ from WRITE setFrom NOTIFY fromChanged)
370 Q_PROPERTY(qreal to READ to WRITE setTo NOTIFY toChanged)
371 Q_PROPERTY(RotationDirection direction READ direction WRITE setDirection NOTIFY directionChanged)
372 QML_NAMED_ELEMENT(RotationAnimation)
374
375public:
376 QQuickRotationAnimation(QObject *parent=nullptr);
377 ~QQuickRotationAnimation() override;
378
379 qreal from() const;
380 void setFrom(qreal);
381
382 qreal to() const;
383 void setTo(qreal);
384
385 enum RotationDirection { Numerical, Shortest, Clockwise, Counterclockwise };
386 Q_ENUM(RotationDirection)
387 RotationDirection direction() const;
388 void setDirection(RotationDirection direction);
389
392};
393
396{
398 Q_DECLARE_PRIVATE(QQuickAnimationGroup)
399
400 Q_CLASSINFO("DefaultProperty", "animations")
402
403public:
405 ~QQuickAnimationGroup() override;
406
409
410protected:
412};
413
415{
417 Q_DECLARE_PRIVATE(QQuickAnimationGroup)
418 QML_NAMED_ELEMENT(SequentialAnimation)
420
421public:
422 QQuickSequentialAnimation(QObject *parent=nullptr);
424
425protected:
426 ThreadingModel threadingModel() const override;
427 QAbstractAnimationJob* transition(QQuickStateActions &actions,
428 QQmlProperties &modified,
430 QObject *defaultTarget = nullptr) override;
431};
432
434{
436 Q_DECLARE_PRIVATE(QQuickAnimationGroup)
437 QML_NAMED_ELEMENT(ParallelAnimation)
439
440public:
441 QQuickParallelAnimation(QObject *parent=nullptr);
442 ~QQuickParallelAnimation() override;
443
444protected:
445 ThreadingModel threadingModel() const override;
446 QAbstractAnimationJob* transition(QQuickStateActions &actions,
447 QQmlProperties &modified,
449 QObject *defaultTarget = nullptr) override;
450};
451
452
454
455#endif // QQUICKANIMATION_H
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
\inmodule QtCore
\inmodule QtCore
Definition qobject.h:103
The QQmlListProperty class allows applications to expose list-like properties of QObject-derived clas...
Definition qqmllist.h:24
The QQmlParserStatus class provides updates on the QML parser state.
The QQmlPropertyValueSource class is an interface for property value sources such as animations and b...
The QQmlProperty class abstracts accessing properties on objects created from QML.
The QQmlScriptString class encapsulates a script and its context.
void alwaysRunToEndChanged(bool)
Q_REVISION(2, 12) void finished()
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
Definition qvariant.h:65
The QVector3D class represents a vector or vertex in 3D space.
Definition qvectornd.h:171
direction
Combined button and popup list for selecting options.
static const QCssKnownValue properties[NumProperties - 1]
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
static Q_CONSTINIT QBasicAtomicInt running
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLuint index
[2]
GLboolean GLuint group
GLenum target
GLuint start
#define QML_UNCREATABLE(REASON)
#define QML_NAMED_ELEMENT(NAME)
#define QML_ADDED_IN_VERSION(MAJOR, MINOR)
static void setProperties(QQuick3DObject &obj, const QSSGSceneDesc::Node &node, const QString &workingDir={})
static bool isRunning()
Definition main.cpp:452
static QT_BEGIN_NAMESPACE void init(QTextBoundaryFinder::BoundaryType type, QStringView str, QCharAttributes *attributes)
#define Q_ENUM(x)
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_CLASSINFO(name, value)
#define Q_INTERFACES(x)
#define Q_SLOTS
#define Q_SIGNALS
double qreal
Definition qtypes.h:187
static double currentTime()
const char property[13]
Definition qwizard.cpp:101
future resume()
settings setValue("DataPump/bgcolor", color)
QEasingCurve easing(QEasingCurve::InOutQuad)
[typedef]
QPropertyAnimation animation
[0]
animation setDuration(1000)
args<< 1<< 2;QJSValue threeAgain=fun.call(args);QString fileName="helloworld.qs";QFile scriptFile(fileName);if(!scriptFile.open(QIODevice::ReadOnly)) QTextStream stream(&scriptFile);QString contents=stream.readAll();scriptFile.close();myEngine.evaluate(contents, fileName);myEngine.globalObject().setProperty("myNumber", 123);...QJSValue myNumberPlusOne=myEngine.evaluate("myNumber + 1");QJSValue result=myEngine.evaluate(...);if(result.isError()) qDebug()<< "Uncaught exception at line"<< result.property("lineNumber").toInt()<< ":"<< result.toString();QPushButton *button=new QPushButton;QJSValue scriptButton=myEngine.newQObject(button);myEngine.globalObject().setProperty("button", scriptButton);myEngine.evaluate("button.checkable = true");qDebug()<< scriptButton.property("checkable").toBool();scriptButton.property("show").call();QJSEngine engine;QObject *myQObject=new QObject();myQObject- setProperty)("dynamicProperty", 3)