-
Notifications
You must be signed in to change notification settings - Fork 0
/
progdilg.cpp
98 lines (84 loc) · 1.88 KB
/
progdilg.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
#include "progdilg.h"
#include "ui_progdilg.h"
#include <QThread>
#include <QtDebug>
#include <QTimer>
progdilg::progdilg(QWidget *parent) :
QDialog(parent),
ui(new Ui::progdilg)
{
ui->setupUi(this);
// this->setWindowModality(Qt::ApplicationModal);
this->setModal(true);
this->setAttribute(Qt::WA_DeleteOnClose);
forceTimer = new QTimer(this);
shownonce = false;
QObject::connect(forceTimer, SIGNAL(timeout()), this, SLOT(forceShow()));
forceTimer->start(showtime);
}
void progdilg::addText(QString text)
{
if(isModal()) {
QCoreApplication::processEvents();
ui->text_out->appendPlainText(text);
}
}
void progdilg::forceShow()
{
this->forceTimer->stop();
if(shownonce) {
return ;
}
this->show();
shownonce = true;
}
void progdilg::setValue(int value)
{
ui->prgbar_glo->setValue(value);
}
void progdilg::setRange(int a, int b)
{
ui->prgbar_glo->setRange(a, b);
maxValue = b;
}
progdilg::~progdilg()
{
delete ui;
}
void progdilg::on_btn_cancel_clicked()
{
wasCanceled_flag = true;
close();
}
bool progdilg::wasCanceled() const
{
return wasCanceled_flag;
}
bool progdilg::wasPaused() const
{
// QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
QCoreApplication::processEvents();
return wasPaused_flag;
}
void progdilg::on_btn_pause_clicked()
{
if(ui->btn_pause->text() == "OK") {
close();
} else {
if(wasPaused()) {
ui->btn_pause->setText(tr("pause"));
wasPaused_flag = false;
addText(tr("continue..."));
} else {
ui->btn_pause->setText(tr("continue"));
wasPaused_flag = true;
addText(tr("paused!!!"));
}
}
}
void progdilg::on_prgbar_glo_valueChanged(int value)
{
if (value == maxValue) {
ui->btn_pause->setText(tr("OK"));
}
}