blob: 2064eacebcca47053701d0801de4a8c4a54e1e15 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
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
51
|
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//Own
#include "animationmanager.h"
#include <QAbstractAnimation>
AnimationManager *AnimationManager::self()
{
// the universe's only animation manager
static AnimationManager s_instance;
return &s_instance;
}
void AnimationManager::registerAnimation(QAbstractAnimation *anim)
{
QObject::connect(anim, &QObject::destroyed, this, &AnimationManager::unregisterAnimation_helper);
animations.append(anim);
}
void AnimationManager::unregisterAnimation_helper(QObject *obj)
{
unregisterAnimation(static_cast<QAbstractAnimation*>(obj));
}
void AnimationManager::unregisterAnimation(QAbstractAnimation *anim)
{
QObject::disconnect(anim, &QObject::destroyed, this, &AnimationManager::unregisterAnimation_helper);
animations.removeAll(anim);
}
void AnimationManager::unregisterAllAnimations()
{
animations.clear();
}
void AnimationManager::pauseAll()
{
for (QAbstractAnimation *animation : std::as_const(animations)) {
if (animation->state() == QAbstractAnimation::Running)
animation->pause();
}
}
void AnimationManager::resumeAll()
{
for (QAbstractAnimation *animation : std::as_const(animations)) {
if (animation->state() == QAbstractAnimation::Paused)
animation->resume();
}
}
|