-
Notifications
You must be signed in to change notification settings - Fork 0
/
powergrenadethrowing.cpp
42 lines (35 loc) · 1.01 KB
/
powergrenadethrowing.cpp
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
#include "powergrenadethrowing.h"
PowerGrenadeThrowing::PowerGrenadeThrowing(QWidget *parent)
: QProgressBar(parent)
{
setMinimum(0);
setMaximum(100);
setVisible(false);
animationValue = new QPropertyAnimation(this, "value");
animationValue->setDuration(1000);
animationValue->setStartValue(0);
animationValue->setEndValue(100);
setGraphicsEffect(effect);
animationOpacity = new QPropertyAnimation(effect, "opacity");
animationOpacity->setDuration(1000);
animationOpacity->setStartValue(1);
animationOpacity->setEndValue(0);
connect(animationOpacity, &QPropertyAnimation::finished, [this](){ setVisible(false); });
}
void PowerGrenadeThrowing::start()
{
animationOpacity->stop();
setVisible(true);
effect->setOpacity(1);
animationValue->start();
}
void PowerGrenadeThrowing::stop()
{
animationValue->stop();
animationOpacity->start();
}
PowerGrenadeThrowing::~PowerGrenadeThrowing()
{
delete animationValue;
delete animationOpacity;
}