-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatusindicator.cpp
executable file
·68 lines (56 loc) · 1.3 KB
/
statusindicator.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
#include "statusindicator.h"
StatusIndicator::StatusIndicator(QWidget *parent) :
QWidget(parent)
{
progress = new QProgressBar();
working = new QLabel();
title = new QLabel();
progress->hide();
working->hide();
title->setText(tr("change me"));
QMovie *mov = new QMovie(this);
mov->setCacheMode(QMovie::CacheAll);
working->setMovie(mov);
mov->setFileName(":loading.gif");
mov->start();
stackLayout = new QStackedLayout();
stackLayout->addWidget(title);
stackLayout->addWidget(progress);
QHBoxLayout *layout = new QHBoxLayout();
layout->setMargin(0);
layout->addLayout(stackLayout);
layout->addWidget(working);
setLayout(layout);
}
void StatusIndicator::toggleIndicator()
{
if(working->isVisible()) {
working->hide();
} else {
working->show();
}
}
void StatusIndicator::showIndicator()
{
working->show();
}
void StatusIndicator::hideIndicator()
{
working->hide();
}
void StatusIndicator::setTitle(const QString _title)
{
QString text(_title);
text.prepend("<b>").append("</b>");
title->setText(text);
stackLayout->setCurrentWidget(title);
}
void StatusIndicator::updateProgress(const int _val, const int _max)
{
stackLayout->setCurrentWidget(progress);
progress->setMaximum(_max);
progress->setValue(_val);
if(_val == _max) {
stackLayout->setCurrentWidget(title);
}
}