forked from mofr/QtProgressCircle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DemoWindow.h
94 lines (74 loc) · 2.32 KB
/
DemoWindow.h
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
#pragma once
#include "ui_DemoWindow.h"
#include "DemoItem.h"
#include <QMainWindow>
#include <QScopedPointer>
#include <QBoxLayout>
#include <QLabel>
#include <QTimer>
class DemoWindow : public QMainWindow
{
Q_OBJECT
public:
explicit DemoWindow(QWidget *parent = 0) :
QMainWindow(parent),
ui(new Ui::DemoWindow)
{
ui->setupUi(this);
ui->itemListLayout->addStretch();
connect(ui->indefiniteButton, &QPushButton::clicked, this, &DemoWindow::addIndefinite);
connect(ui->successfulButton, &QPushButton::clicked, this, &DemoWindow::addSuccessful);
connect(ui->abortedButton, &QPushButton::clicked, this, &DemoWindow::addAborted);
}
public slots:
void addIndefinite()
{
DemoItem * item = new DemoItem("Indefinite process");
ui->itemListLayout->insertWidget(0, item);
}
void addSuccessful()
{
DemoItem * item = new DemoItem("Working");
ui->itemListLayout->insertWidget(0, item);
item->progressCircle->setMaximum(100);
QTimer::singleShot(500, item, [=](){
item->progressCircle->setValue(10);
});
QTimer::singleShot(1000, item, [=](){
item->progressCircle->setValue(30);
});
QTimer::singleShot(2000, item, [=](){
item->progressCircle->setValue(60);
});
QTimer::singleShot(2500, item, [=](){
item->progressCircle->setValue(70);
});
QTimer::singleShot(3300, item, [=](){
item->progressCircle->setValue(85);
});
QTimer::singleShot(4000, item, [=](){
item->progressCircle->setValue(100);
item->finish(true);
});
}
void addAborted()
{
DemoItem * item = new DemoItem("Working");
ui->itemListLayout->insertWidget(0, item);
item->progressCircle->setMaximum(100);
QTimer::singleShot(500, item, [=](){
item->progressCircle->setValue(10);
});
QTimer::singleShot(1000, item, [=](){
item->progressCircle->setValue(30);
});
QTimer::singleShot(1500, item, [=](){
item->progressCircle->setValue(65);
});
QTimer::singleShot(2000, item, [=](){
item->finish(false);
});
}
private:
QScopedPointer<Ui::DemoWindow> ui;
};