-
Notifications
You must be signed in to change notification settings - Fork 4
/
progressdialog.cpp
49 lines (42 loc) · 936 Bytes
/
progressdialog.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
#include "progressdialog.h"
#include "ui_progressdialog.h"
ProgressDialog::ProgressDialog(QWidget *parent) :
QWidget(parent),
ui(new Ui::ProgressDialog)
{
ui->setupUi(this);
usePercents = false;
setWindowModality(Qt::ApplicationModal);
}
ProgressDialog::~ProgressDialog()
{
delete ui;
}
void ProgressDialog::setMax(int n)
{
ui->progressBar->setMaximum(n);
}
void ProgressDialog::setProgress(int p)
{
ui->progressBar->setValue(p);
if(usePercents)
{
ui->percent->setText( QString::number(int(float(p)/float(ui->progressBar->maximum())*100)) +"%" );
}
else
{
ui->percent->setText(QString("%1 / %2").arg(p).arg(ui->progressBar->maximum()));
}
}
void ProgressDialog::setText(QString text)
{
ui->label->setText(text);
}
void ProgressDialog::advance(int n)
{
setProgress(ui->progressBar->value()+n);
}
void ProgressDialog::advanceOne()
{
advance(1);
}