-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoken.cpp
More file actions
executable file
·93 lines (58 loc) · 1.86 KB
/
token.cpp
File metadata and controls
executable file
·93 lines (58 loc) · 1.86 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
#include "token.h"
#include "dialog.h"
#include <QPropertyAnimation>
Token::Token(int _width, int _height, int _x, int _y, bool enter, bool leave ,bool Pressed, QWidget *parent) : QWidget(parent), width(_width), height(_height), x(_x), y(_y), _enter(enter),_leave(leave),m_Pressed(Pressed)
{ /* connect(ui->radioserver,&QPushButton::clicked, [this](){
auto animation = new QPropertyAnimation(ui->Server, "pos");
animation->setDuration(800);
animation->setStartValue(QPoint(0, 0));
animation->setEndValue(QPoint(0, 6));
animation->start();*/
}
void Token::paintEvent(QPaintEvent *e)
{
//qDebug() << "in myRect::paintEvent1"<<x++<<y++;
QPainter painter(this);
QRect rec(0,0,width+45,height+10);
// QPen framepen(Qt::red);
painter.setBrush(Qt::black);
painter.drawRect(rec);
if(m_Pressed){
painter.setBrush(Qt::red);
painter.drawRect(rec);
}
if(!m_Pressed){
painter.setBrush(Qt::black);
painter.drawRect(rec);
}
if(_enter){
painter.setBrush(Qt::green);
painter.drawRect(rec);
}
if (_leave){
painter.setBrush(Qt::black);
painter.drawRect(rec);
}
painter.setBrush(color);
painter.drawEllipse(rec);
}
void Token::mouseReleaseEvent(QMouseEvent *event) {
if(event->button() == Qt::LeftButton) {
emit clicked();
}
}
void Token::enterEvent(QEvent *event){
emit enter();
}
void Token::leaveEvent(QEvent *event){
emit leave();
}
/*connect(ui->tester,&QPushButton::clicked, [this](){
Stone *stone = new Stone;
ui->gridLayout->addWidget(stone,0,0);
animation = new QPropertyAnimation(Stone, "geometry");
animation->setDuration(1000);
animation->setStartValue(QRect (0,0,200,200));
animation->setEndValue(QRect(0,7,200,200));
animation->start();
*/