-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbtform.cpp
More file actions
100 lines (90 loc) · 2.44 KB
/
Copy pathbtform.cpp
File metadata and controls
100 lines (90 loc) · 2.44 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#include "btform.h"
#include "ui_btform.h"
BtForm::BtForm(QWidget *parent)
: QWidget(parent)
, ui(new Ui::BtForm)
{
ui->setupUi(this);
//设置line1动画
_line1=new QPropertyAnimation(ui->line1,"geometry",this);
_line1->setDuration(1500);
_line1->setKeyValueAt(0,QRect(3,31,6,0));
_line1->setKeyValueAt(0.5,QRect(3,3,6,28));
_line1->setKeyValueAt(1,QRect(3,31,6,0));
_line1->setLoopCount(-1);
//设置line2动画
_line2=new QPropertyAnimation(ui->line2,"geometry",this);
_line2->setDuration(1800);
_line2->setKeyValueAt(0,QRect(12,31,6,0));
_line2->setKeyValueAt(0.5,QRect(12,3,6,28));
_line2->setKeyValueAt(1,QRect(12,31,6,0));
_line2->setLoopCount(-1);
//设置line3动画
_line3=new QPropertyAnimation(ui->line3,"geometry",this);
_line3->setDuration(2100);
_line3->setKeyValueAt(0,QRect(21,31,6,0));
_line3->setKeyValueAt(0.5,QRect(21,3,6,28));
_line3->setKeyValueAt(1,QRect(21,31,6,0));
_line3->setLoopCount(-1);
//设置line4动画
_line4=new QPropertyAnimation(ui->line4,"geometry",this);
_line4->setDuration(2400);
_line4->setKeyValueAt(0,QRect(30,31,6,0));
_line4->setKeyValueAt(0.5,QRect(30,3,6,28));
_line4->setKeyValueAt(1,QRect(30,31,6,0));
_line4->setLoopCount(-1);
//隐藏所有动画
HideAll();
}
BtForm::~BtForm()
{
delete ui;
}
void BtForm::SetIconAndContent(QString Icon, QString content, int id)
{
ui->BtIcon->setPixmap(QPixmap(Icon));
ui->BtText->setText(content);
this->_id=id;
}
void BtForm::CleanBackground()
{
ui->BtStyle->setStyleSheet("#BtStyle:hover{background-color:#D8D8D8}");
}
int BtForm::getId()
{
return _id;
}
void BtForm::ShowAnimation()
{
//启动默认页面的动画
StartAnimation();
ui->LineBox->show();
ui->BtStyle->setStyleSheet("#BtStyle{ background:rgb(30,206,154);}*{color:#F6F6F6;}");
}
void BtForm::StopAnimation()
{
_line1->stop();
_line2->stop();
_line3->stop();
_line4->stop();
}
void BtForm::HideAll()
{
ui->LineBox->hide();
}
void BtForm::StartAnimation()
{
_line1->start();
_line2->start();
_line3->start();
_line4->start();
}
void BtForm::mousePressEvent(QMouseEvent *event)
{
(void)event;
ui->BtStyle->setStyleSheet("#BtStyle{ background:rgb(30,206,154);}*{color:#F6F6F6;}");
//点击后启动对应页面的动画并让它显示出来
StartAnimation();
ui->LineBox->show();
emit click(this->_id);
}