-
Notifications
You must be signed in to change notification settings - Fork 1
/
washmode.cpp
65 lines (57 loc) · 1.62 KB
/
washmode.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "normalmode.h"
#include "movemode.h"
#include "washmode.h"
washmode::washmode(QWidget* parent)
:widget(parent)
, roleLabel(new QLabel(this))
, curFrame(0)
{
setAttribute(Qt::WA_DeleteOnClose);
widget::WidgetsParameter();
widget::ShadowEffect();
washmode::updateRoleAnimation();
}
void washmode::updateRoleAnimation()
{
WashModeRoleAnimation();
updateAnimationTimer();
returnNormalModeTimer();
}
void washmode::updateAnimationTimer()
{
//定时器更新动画(循环一次背景图片更新一次)
QTimer* updateTimer = new QTimer(this);
updateTimer->setTimerType(Qt::PreciseTimer);
updateTimer->setInterval(100);
connect(updateTimer, &QTimer::timeout, this, &washmode::WashModeRoleAnimation);
updateTimer->start();
}
void washmode::WashModeRoleAnimation()
{
QString qcut("background-repeat:no-repeat;"); //裁剪背景图片
roleLabel->resize(200, 200); //设置窗口大小
roleLabel->setStyleSheet(qcut + QString("background-image:url(:/wash/dogs/wash/%1.png);").arg(curFrame)); //窗口贴上背景图片
curFrame = curFrame + 1; //循环展示背景图片
}
void washmode::returnNormalModeTimer()
{
QTimer* returnTimer = new QTimer(this);
returnTimer->setTimerType(Qt::PreciseTimer);
returnTimer->setSingleShot(true);
returnTimer->setInterval(3000);
connect(returnTimer, &QTimer::timeout, this, &washmode::returnNormalMode);
returnTimer->start();
}
void washmode::returnNormalMode()
{
static int clickAreaX, clickAreaY;
normalmode* n = new normalmode();
clickAreaX = this->x();
clickAreaY = this->y();
n->move(clickAreaX - 35, clickAreaY + 75);
n->show();
this->close();
}
washmode::~washmode()
{
}