Qt 6.x
The Qt SDK
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
qquicktransition.cpp
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
5
6#include "qquickstate_p.h"
7#include "qquickstate_p_p.h"
9#include "qquickanimation_p.h"
10#include "qquickanimation_p_p.h"
12
13#include <private/qquickanimatorjob_p.h>
14
15#include "private/qparallelanimationgroupjob_p.h"
16
18
71//ParallelAnimationWrapper allows us to do a "callback" when the animation finishes, rather than connecting
72//and disconnecting signals and slots frequently
74{
75public:
78
79protected:
81};
82
84{
85 Q_DECLARE_PUBLIC(QQuickTransition)
86public:
91 {
92 }
93
94 static QQuickTransitionPrivate *get(QQuickTransition *q) { return q->d_func(); }
96
104protected:
105
111};
112
114{
115 QQuickTransition *q = static_cast<QQuickTransition *>(list->object);
116 q->d_func()->animations.append(a);
117 a->setDisableUserControl();
118}
119
121{
122 QQuickTransition *q = static_cast<QQuickTransition *>(list->object);
123 return q->d_func()->animations.size();
124}
125
127{
128 QQuickTransition *q = static_cast<QQuickTransition *>(list->object);
129 return q->d_func()->animations.at(pos);
130}
131
133{
134 QQuickTransition *q = static_cast<QQuickTransition *>(list->object);
135 while (q->d_func()->animations.size()) {
136 QQuickAbstractAnimation *firstAnim = q->d_func()->animations.at(0);
137 q->d_func()->animations.removeAll(firstAnim);
138 }
139}
140
142{
143 if (!m_transition)
144 return;
145
146 QQuickTransitionPrivate *transition = QQuickTransitionPrivate::get(m_transition);
147 transition->animationStateChanged(newState);
148}
149
151{
152 Q_Q(QQuickTransition);
153
156 if (runningInstanceCount == 1)
157 emit q->runningChanged();
160 if (runningInstanceCount == 0)
161 emit q->runningChanged();
162 }
163}
164
166{
168 if (newState == Stopped && (duration() == -1
171 {
172 manager->complete();
173 }
174}
175
177 : m_transition(transition)
178 , m_anim(anim)
179{
181}
182
184{
186 delete m_anim;
187}
188
190{
191 if (m_anim)
192 m_anim->start();
193}
194
196{
197 if (m_anim)
198 m_anim->stop();
199}
200
202{
203 if (m_anim)
204 m_anim->complete();
205}
206
208{
209 return m_anim && m_anim->state() == QAbstractAnimationJob::Running;
210}
211
214{
215}
216
218{
219}
220
222{
223 Q_D(QQuickTransition);
224 d->reversed = r;
225}
226
228 QList<QQmlProperty> &after,
230 QObject *defaultTarget)
231{
232 Q_D(QQuickTransition);
233
234 qmlExecuteDeferred(this);
235
237 group->manager = manager;
238
240 int start = d->reversed ? d->animations.size() - 1 : 0;
241 int end = d->reversed ? -1 : d->animations.size();
242
243 QAbstractAnimationJob *anim = nullptr;
244 for (int i = start; i != end;) {
245 anim = d->animations.at(i)->transition(actions, after, direction, defaultTarget);
246 if (anim) {
247 if (d->animations.at(i)->threadingModel() == QQuickAbstractAnimation::RenderThread)
248 anim = new QQuickAnimatorProxyJob(anim, d->animations.at(i));
249 d->reversed ? group->prependAnimation(anim) : group->appendAnimation(anim);
250 }
251 d->reversed ? --i : ++i;
252 }
253
255
257 return wrapper;
258}
259
287{
288 Q_D(const QQuickTransition);
289 return d->fromState;
290}
291
293{
294 Q_D(QQuickTransition);
295 if (f == d->fromState)
296 return;
297
298 d->fromState = f;
300}
301
328{
329 Q_D(const QQuickTransition);
330 return d->reversible;
331}
332
334{
335 Q_D(QQuickTransition);
336 if (r == d->reversible)
337 return;
338
339 d->reversible = r;
341}
342
344{
345 Q_D(const QQuickTransition);
346 return d->toState;
347}
348
350{
351 Q_D(QQuickTransition);
352 if (t == d->toState)
353 return;
354
355 d->toState = t;
356 emit toChanged();
357}
358
391{
392 Q_D(const QQuickTransition);
393 return d->enabled;
394}
395
397{
398 Q_D(QQuickTransition);
399 if (d->enabled == enabled)
400 return;
401 d->enabled = enabled;
403}
404
415{
416 Q_D(const QQuickTransition);
417 return d->runningInstanceCount;
418}
419
420
435{
436 Q_D(QQuickTransition);
441}
442
444
445//#include <qquicktransition.moc>
446
447#include "moc_qquicktransition_p.cpp"
\qmltype Transition \instantiates QQuickTransition \inqmlmodule QtQuick
void updateState(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState) override
QQuickTransitionManager * manager
void addAnimationChangeListener(QAnimationJobChangeListener *listener, QAbstractAnimationJob::ChangeTypes)
QAbstractAnimationJob::State state() const
QAbstractAnimationJob::Direction direction() const
Definition qlist.h:74
\inmodule QtCore
Definition qobject.h:90
void updateState(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState) override
The QQmlListProperty class allows applications to expose list-like properties of QObject-derived clas...
Definition qqmllist.h:24
QQuickTransitionInstance(QQuickTransition *transition, QAbstractAnimationJob *anim)
void animationStateChanged(QAbstractAnimationJob *, QAbstractAnimationJob::State, QAbstractAnimationJob::State) override
QAbstractAnimationJob::State state
static qsizetype animation_count(QQmlListProperty< QQuickAbstractAnimation > *list)
static void clear_animations(QQmlListProperty< QQuickAbstractAnimation > *list)
static void append_animation(QQmlListProperty< QQuickAbstractAnimation > *list, QQuickAbstractAnimation *a)
static QQuickTransitionPrivate * get(QQuickTransition *q)
void animationStateChanged(QAbstractAnimationJob::State newState)
QList< QQuickAbstractAnimation * > animations
static QQuickAbstractAnimation * animation_at(QQmlListProperty< QQuickAbstractAnimation > *list, qsizetype pos)
QQmlListProperty< QQuickAbstractAnimation > animations
\qmlproperty list<Animation> QtQuick::Transition::animations \qmldefault
QQuickTransitionInstance * prepare(QQuickStateOperation::ActionList &actions, QList< QQmlProperty > &after, QQuickTransitionManager *end, QObject *defaultTarget)
void setEnabled(bool enabled)
QQuickTransition(QObject *parent=nullptr)
QString fromState() const
\qmlproperty string QtQuick::Transition::from \qmlproperty string QtQuick::Transition::to
void setFromState(const QString &)
void reversibleChanged()
QString toState() const
void setToState(const QString &)
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
direction
void newState(QList< State > &states, const char *token, const char *lexem, bool pre)
Combined button and popup list for selecting options.
GLboolean GLboolean GLboolean GLboolean a
[7]
GLboolean r
[2]
GLuint GLuint end
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLfloat GLfloat f
GLboolean GLuint group
GLuint start
GLdouble GLdouble t
Definition qopenglext.h:243
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
void qmlExecuteDeferred(QObject *object)
Definition qqml.cpp:48
#define emit
unsigned int quint32
Definition qtypes.h:45
ptrdiff_t qsizetype
Definition qtypes.h:70
QList< int > list
[14]
QNetworkAccessManager manager
void wrapper()
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent