dotprogressbarwidget.cpp 1.47 KB
#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);
    }
}