8#include <private/qquickitem_p.h>
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
52QQuickAnimator::QQuickAnimator(QQuickAnimatorPrivate &dd, QObject *parent)
53 : QQuickAbstractAnimation(dd, parent)
57QQuickAnimator::QQuickAnimator(QObject *parent)
58 : QQuickAbstractAnimation(*
new QQuickAnimatorPrivate, parent)
63
64
65
66
67
68
70void QQuickAnimator::setTargetItem(QQuickItem *target)
73 if (target == d->target)
76 Q_EMIT targetItemChanged(d->target);
79QQuickItem *QQuickAnimator::targetItem()
const
81 Q_D(
const QQuickAnimator);
86
87
88
89
90
91void QQuickAnimator::setDuration(
int duration)
94 if (duration == d->duration)
96 d->duration = duration;
97 Q_EMIT durationChanged(duration);
100int QQuickAnimator::duration()
const
102 Q_D(
const QQuickAnimator);
107
108
109
110
111
112
113
114
116void QQuickAnimator::setEasing(
const QEasingCurve &easing)
119 if (easing == d->easing)
122 Q_EMIT easingChanged(d->easing);
125QEasingCurve QQuickAnimator::easing()
const
127 Q_D(
const QQuickAnimator);
132
133
134
135
136
137
138
139
141void QQuickAnimator::setTo(qreal to)
146 d->toIsDefined =
true;
148 Q_EMIT toChanged(d->to);
151qreal QQuickAnimator::to()
const
153 Q_D(
const QQuickAnimator);
158
159
160
161
162
163
164
165
166
167
169void QQuickAnimator::setFrom(qreal from)
172 d->fromIsDefined =
true;
176 Q_EMIT fromChanged(d->from);
179qreal QQuickAnimator::from()
const
181 Q_D(
const QQuickAnimator);
186 const QString &propertyName,
189 QObject *defaultTarget)
192 if (actions.size()) {
193 for (
int i=0; i<actions.size(); ++i) {
194 QQuickStateAction &action = actions[i];
195 if (action.property.name() != propertyName)
197 modified << action.property;
199 job->setTarget(qobject_cast<QQuickItem *>(action.property.object()));
203 else if (action.fromValue.isValid())
204 job->setFrom(action.fromValue.toReal());
206 job->setFrom(action.property.read().toReal());
210 else if (action.toValue.isValid())
211 job->setTo(action.toValue.toReal());
213 job->setTo(action.property.read().toReal());
219 action.fromValue = action.toValue;
223 if (modified.isEmpty()) {
224 job->setTarget(target);
230 if (!job->target()) {
231 if (defaultProperty.object())
232 job->setTarget(qobject_cast<QQuickItem *>(defaultProperty.object()));
234 job->setTarget(qobject_cast<QQuickItem *>(defaultTarget));
237 if (modified.isEmpty() && !fromIsDefined && job->target())
238 job->setFrom(job->target()->property(propertyName.toLatin1()).toReal());
241 job->setLoopCount(loopCount);
242 job->setEasingCurve(easing);
245QAbstractAnimationJob *QQuickAnimator::transition(QQuickStateActions &actions,
246 QQmlProperties &modified,
247 TransitionDirection direction,
248 QObject *defaultTarget)
252 if (d->defaultProperty.isValid() && propertyName() != d->defaultProperty.name()) {
253 qmlWarning(
this) <<
"property name conflict: \""
254 << propertyName() <<
"\" != \"" << d->defaultProperty.name() <<
"\"";
259 if (direction == Backward)
262 QQuickAnimatorJob *job = createJob();
266 d->apply(job, propertyName(), actions, modified, defaultTarget);
268 if (!job->target()) {
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
305QQuickXAnimator::QQuickXAnimator(QObject *parent) : QQuickAnimator(parent) {}
307QQuickAnimatorJob *QQuickXAnimator::createJob()
const {
return new QQuickXAnimatorJob(); }
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
338QQuickYAnimator::QQuickYAnimator(QObject *parent) : QQuickAnimator(parent) {}
340QQuickAnimatorJob *QQuickYAnimator::createJob()
const {
return new QQuickYAnimatorJob(); }
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
373QQuickScaleAnimator::QQuickScaleAnimator(QObject *parent) : QQuickAnimator(parent) {}
375QQuickAnimatorJob *QQuickScaleAnimator::createJob()
const {
return new QQuickScaleAnimatorJob(); }
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
406QQuickOpacityAnimator::QQuickOpacityAnimator(QObject *parent) : QQuickAnimator(parent) {}
408QQuickAnimatorJob *QQuickOpacityAnimator::createJob()
const {
return new QQuickOpacityAnimatorJob(); }
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
442QQuickRotationAnimator::QQuickRotationAnimator(QObject *parent)
443 : QQuickAnimator(*
new QQuickRotationAnimatorPrivate, parent)
447QQuickAnimatorJob *QQuickRotationAnimator::createJob()
const {
448 Q_D(
const QQuickRotationAnimator);
449 QQuickRotationAnimatorJob *job =
new QQuickRotationAnimatorJob();
450 job->setDirection(d->direction);
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471void QQuickRotationAnimator::setDirection(RotationDirection dir)
473 Q_D(QQuickRotationAnimator);
474 if (d->direction == dir)
477 Q_EMIT directionChanged(d->direction);
480QQuickRotationAnimator::RotationDirection QQuickRotationAnimator::direction()
const
482 Q_D(
const QQuickRotationAnimator);
486#if QT_CONFIG(quick_shadereffect)
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
520QQuickUniformAnimator::QQuickUniformAnimator(QObject *parent)
521 : QQuickAnimator(*
new QQuickUniformAnimatorPrivate, parent)
526
527
528
529
530
531
532
533void QQuickUniformAnimator::setUniform(
const QString &uniform)
535 Q_D(QQuickUniformAnimator);
536 if (d->uniform == uniform)
538 d->uniform = uniform;
539 Q_EMIT uniformChanged(d->uniform);
542QString QQuickUniformAnimator::uniform()
const
544 Q_D(
const QQuickUniformAnimator);
548QString QQuickUniformAnimator::propertyName()
const
550 Q_D(
const QQuickUniformAnimator);
551 if (!d->uniform.isEmpty())
553 return d->defaultProperty.name();
556QQuickAnimatorJob *QQuickUniformAnimator::createJob()
const
558 QString u = propertyName();
562 QQuickUniformAnimatorJob *job =
new QQuickUniformAnimatorJob();
563 job->setUniform(u.toLatin1());
570#include "moc_qquickanimator_p.cpp"
void apply(QQuickAnimatorJob *job, const QString &propertyName, QQuickStateActions &actions, QQmlProperties &modified, QObject *defaultTarget)
Combined button and popup list for selecting options.
QList< QQmlProperty > QQmlProperties
QQuickStateOperation::ActionList QQuickStateActions