dotprogressbarwidget.cpp
1.47 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
#include "dotprogressbarwidget.h"
#include "ui_dotprogressbarwidget.h"
DotProgressBarWidget::DotProgressBarWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::DotProgressBarWidget)
{
ui->setupUi(this);
m_nCurProgress = 0;
m_nMaximumProgress = 0;
basePixmap.load(":/images/symbol/step_bullet.png");
coverPixmap.load(":/images/symbol/selected_step_bullet.png");
}
DotProgressBarWidget::~DotProgressBarWidget()
{
delete ui;
}
void DotProgressBarWidget::setCurrentProgress(int progress){
m_nCurProgress = progress;
reloadUi();
}
void DotProgressBarWidget::reloadUi(){
for(int i = 0;i<m_nMaximumProgress;i++){
if(m_nCurProgress >= (i+1)){
m_ctrLabelList[i]->setPixmap(coverPixmap);
}
else m_ctrLabelList[i]->setPixmap(basePixmap);
}
}
void DotProgressBarWidget::setMaxProgress(int curProgress, int maxProgress){
QRect defaultGeometry;
m_nCurProgress = curProgress;
m_nMaximumProgress = maxProgress;
defaultGeometry.setSize(basePixmap.size());
QLabel *label;
for(int i=0;i<m_nMaximumProgress;i++){
label = new QLabel(this);
m_ctrLabelList.append(label);
if(m_nCurProgress >=(i+1)){
label->setPixmap(coverPixmap);
}
else label->setPixmap(basePixmap);
label->setGeometry(defaultGeometry);
label->setAlignment(Qt::AlignCenter);
ui->horizontalLayout_2->addWidget(label);
}
}