-
Notifications
You must be signed in to change notification settings - Fork 2
/
blinkink.cpp
134 lines (112 loc) · 2.72 KB
/
blinkink.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
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#include "blinkink.h"
Blinkink::Blinkink(QWidget *parent) :
QFrame(parent),
_layout(this),
_icon(this),
_top(this),
_bottom(this),
_animation(this,"step",this)
{
_icon.setSizePolicy(QSizePolicy::Maximum,QSizePolicy::Preferred);
_layout.addWidget(&_icon,0,0,2,1);
_layout.addWidget(&_top,0,1);
_layout.addWidget(&_bottom,1,1);
_layout.setSpacing(0);
_layout.setMargin(2);
_top.setStyleSheet("font-weight: bold;");
_bottom.setStyleSheet("font-style: italic;");
this->setLayout(&_layout);
_animation.setDuration(2000);
_animation.setStartValue(1);
_animation.setEndValue(0.2);
m_blinkDuration = 2000;
connect(&_animation,SIGNAL(finished()),this,SLOT(aniEnd()));
}
QString Blinkink::colorToString(QColor c)
{
return QString("rgba(%1, %2, %3, %4)").arg(c.red()).arg(c.green()).arg(c.blue()).arg(m_step);
}
QString Blinkink::backGroundString(QColor c)
{
return QString(" background-color: %1;").arg(colorToString(c));
}
bool Blinkink::blink() const {
return m_blink;
}
void Blinkink::setblink(bool arg) {
if (m_blink != arg) {
m_blink = arg;
if(arg)
_animation.start();
else
{
_animation.stop();
setStep(1);
}
emit blinkChanged(arg);
}
}
int Blinkink::blinkDuration() const {
return m_blinkDuration;
}
void Blinkink::setblinkDuration(int arg) {
if (m_blinkDuration != arg) {
m_blinkDuration = arg;
_animation.setDuration(arg);
emit blinkDurationChanged(arg);
}
}
void Blinkink::aniEnd()
{
_animation.setStartValue(1);
_animation.setEndValue(0);
_animation.start();
}
QPixmap Blinkink::icon() const {
return m_icon;
}
void Blinkink::seticon(QPixmap arg) {
m_icon = arg;
_icon.setPixmap(arg);
emit iconChanged(arg);
}
QString Blinkink::topTex() const {
return m_topTex;
}
QString Blinkink::bottomTex() const {
return m_bottomTex;
}
void Blinkink::settopTex(QString arg) {
if (m_topTex != arg) {
m_topTex = arg;
_top.setText(arg);
emit topTexChanged(arg);
}
}
void Blinkink::setbottomTex(QString arg) {
if (m_bottomTex != arg) {
m_bottomTex = arg;
_bottom.setText(arg);
emit bottomTexChanged(arg);
}
}
void Blinkink::setStep(double arg) {
if (m_step != arg) {
m_step = arg;
this->setStyleSheet(backGroundString(m_color));
emit stepChanged(arg);
}
}
void Blinkink::setcolor(QColor arg) {
if (m_color != arg) {
m_color = arg;
setStep(1);
emit colorChanged(arg);
}
}
double Blinkink::step() const {
return m_step;
}
QColor Blinkink::color() const {
return m_color;
}