forked from GLDsuh-a/qt-1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmedalwallwidget.cpp
171 lines (139 loc) · 5.01 KB
/
medalwallwidget.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#include "medalwallwidget.h"
#include <QPainter>
MedalWallWidget::MedalWallWidget(QWidget *parent)
: QWidget(parent)
{
setWindowFlags(Qt::FramelessWindowHint);
setAttribute(Qt::WA_TranslucentBackground);
this->setFixedSize(700, 475);
ismousePress = false;
closeButton = new QPushButton();
// closeButton->setPicName(QString(":/sysButton/close"));
getLabel = new QLabel();
topSafeLabel = new QLabel();
topSdLabel = new QLabel();
ungetLabel = new QLabel();
infoLabel = new QLabel();
onekeyGetButton = new QPushButton();
clickGetLabel = new QLabel();
tipIconLabel = new QLabel();
browserButton = new QPushButton();
QPixmap topSafe(":/MedalWall/top_safe");
topSafeLabel->setPixmap(topSafe);
topSafeLabel->setScaledContents(true);
topSafeLabel->setFixedSize(topSafe.size());
QPixmap topSd(":/MedalWall/top_sd");
topSdLabel->setPixmap(topSd);
topSdLabel->setScaledContents(true);
topSdLabel->setFixedSize(topSd.size());
infoLabel->setObjectName("infoLabel");
QFont infoFont = infoLabel->font();
infoFont.setBold(true);
infoFont.setPointSize(12);
infoLabel->setFont(infoFont);
QPixmap getPixmap(":/MedalWall/tag_get");
getLabel->setPixmap(getPixmap);
getLabel->setScaledContents(true);
getLabel->setFixedSize(getPixmap.size());
QPixmap ungetPixmap(":/MedalWall/tag_unget");
ungetLabel->setPixmap(ungetPixmap);
ungetLabel->setScaledContents(true);
ungetLabel->setFixedSize(ungetPixmap.size());
QPixmap clickGetPixmap(":/MedalWall/tag_tips");
clickGetLabel->setPixmap(clickGetPixmap);
clickGetLabel->setScaledContents(true);
clickGetLabel->setFixedSize(clickGetPixmap.size());
QPixmap tipIconPixmap(":/MedalWall/tag_rock");
tipIconLabel->setPixmap(tipIconPixmap);
tipIconLabel->setScaledContents(true);
tipIconLabel->setFixedSize(tipIconPixmap.size());
QPixmap browserIcon(":/MedalWall/btm_se");
browserButton->setIcon(browserIcon);
browserButton->setIconSize(browserIcon.size());
browserButton->setFixedSize(browserIcon.size());
browserButton->setObjectName("transparentButton");
onekeyGetButton->setObjectName("loginGreenButton");
onekeyGetButton->setFixedSize(120, 40);
QFont onekeyGetFont = onekeyGetButton->font();
onekeyGetFont.setPointSize(14);
onekeyGetFont.setBold(true);
onekeyGetButton->setFont(onekeyGetFont);
QHBoxLayout *titleLayout = new QHBoxLayout();
titleLayout->addStretch();
titleLayout->addWidget(closeButton, 0, Qt::AlignTop);
titleLayout->setSpacing(0);
titleLayout->setContentsMargins(0, 5, 12, 0);
QHBoxLayout *getLayout = new QHBoxLayout();
getLayout->addWidget(topSafeLabel);
getLayout->addWidget(topSdLabel);
getLayout->addStretch();
getLayout->setSpacing(350);
getLayout->setContentsMargins(70, 0, 0, 0);
QHBoxLayout *infoLayout = new QHBoxLayout();
infoLayout->addWidget(ungetLabel);
infoLayout->addWidget(infoLabel);
infoLayout->setSpacing(50);
infoLayout->setContentsMargins(0, 0, 0, 0);
QHBoxLayout *ungetLayout = new QHBoxLayout();
ungetLayout->addStretch();
ungetLayout->addWidget(clickGetLabel);
ungetLayout->addWidget(tipIconLabel);
ungetLayout->addWidget(browserButton);
ungetLayout->addStretch();
ungetLayout->setSpacing(0);
ungetLayout->setContentsMargins(0, 0, 0, 0);
QHBoxLayout *bottomLayout = new QHBoxLayout();
bottomLayout->addStretch();
bottomLayout->addWidget(onekeyGetButton);
bottomLayout->setSpacing(0);
bottomLayout->setContentsMargins(0, 0, 30, 30);
QVBoxLayout *mainLayout = new QVBoxLayout();
mainLayout->addLayout(titleLayout);
mainLayout->addWidget(getLabel);
mainLayout->addLayout(getLayout);
mainLayout->addLayout(infoLayout);
mainLayout->addLayout(ungetLayout);
mainLayout->addStretch();
mainLayout->addLayout(bottomLayout);
mainLayout->setSpacing(15);
mainLayout->setContentsMargins(7, 0, 0, 0);
this->setLayout(mainLayout);
this->translateLanguage();
connect(closeButton, SIGNAL(clicked()), this, SLOT(hide()));
}
MedalWallWidget::~MedalWallWidget()
{
}
void MedalWallWidget::translateLanguage()
{
closeButton->setToolTip(tr("close"));
infoLabel->setText(tr("you have got") + QString::number(2, 10) + tr("medal,will become superuser"));
onekeyGetButton->setText(tr("onekey get"));
}
void MedalWallWidget::mousePressEvent(QMouseEvent *event)
{
if(event->button() == Qt::LeftButton)
{
ismousePress = true;
}
movePoint = event->globalPos() - pos();
}
void MedalWallWidget::mouseReleaseEvent(QMouseEvent *)
{
ismousePress = false;
}
void MedalWallWidget::mouseMoveEvent(QMouseEvent *event)
{
if(ismousePress)
{
QPoint movePos = event->globalPos();
move(movePos - movePoint);
}
}
void MedalWallWidget::paintEvent(QPaintEvent *event)
{
QPainter painter(this);
painter.setPen(Qt::NoPen);
painter.setBrush(Qt::NoBrush);
painter.drawPixmap(this->rect(), QPixmap(":/MedalWall/bj"));
}