Repository navigation
Expand file tree
/
Copy pathStatusDialog.cpp
More file actions
134 lines (107 loc) · 2.77 KB
/
Copy pathStatusDialog.cpp
File metadata and controls
134 lines (107 loc) · 2.77 KB
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#include "StatusDialog.h"
StatusDialog::StatusDialog(QWidget *parent) : QDialog(parent, 0)
{
QVBoxLayout *vlayout = new QVBoxLayout();
QHBoxLayout *hlayout = new QHBoxLayout();
for(int j = 0; j < 5; j++) {
QLabel *r = new QLabel();
r->setPixmap(QPixmap(":/images//status.png"));
//r->setBackgroundRole(QPalette::Base);
r->setEnabled(false);
bump.append(r);
hlayout->addWidget(r);
}
messageLabel = new QLabel(this);
QFont mfont = this->font();
mfont.setPixelSize(14);
messageLabel->setFont(mfont);
vlayout->addWidget(messageLabel);
vlayout->addLayout(hlayout);
//connect(&thread, SIGNAL(nextBump()), this, SLOT(nextBump()));
//connect(&thread, SIGNAL(hideit()), this, SLOT(hide()));
displayTimer = new QTimer(this);
connect(displayTimer, SIGNAL(timeout()), this, SLOT(animate()));
this->setWindowTitle("Status Message Dialog");
this->setStyleSheet("QDialog { background-color: white; }");
this->setLayout(vlayout);
}
StatusDialog::~StatusDialog()
{
}
void StatusDialog::init(const QString title, const QString message)
{
QApplication::processEvents();
this->setWindowTitle(title);
QWidget *win = this->parentWidget();
int w = 200;
int h = 60;
QRect rect(win->x()+win->width()/2-w/2, win->y()+win->height()/2-h/2, w, h);
this->setGeometry(rect);
this->setMaximumWidth(w);
messageLabel->setText(message);
this->setWindowFlags(Qt::Tool);
this->show();
QApplication::processEvents();
index = -1;
//thread.startit();
displayTimer->start(200);
this->show();
QApplication::processEvents();
}
void StatusDialog::addMessage(const QString message)
{
messageLabel->setText(messageLabel->text() + message);
}
void StatusDialog::setMessage(const QString message)
{
messageLabel->setText(message);
}
QString StatusDialog::getMessage()
{
return messageLabel->text();
}
void StatusDialog::stop(int count)
{
//thread.stop(count);
displayTimer->stop();
hide();
}
void StatusDialog::nextBump()
{
for(int n = 0; n < bump.count(); n++) {
bump[n]->setEnabled(false);
}
index = (index+1) % bump.count();
bump[index]->setEnabled(true);
}
void StatusDialog::animate()
{
nextBump();
QApplication::processEvents();
}
StatusDialogThread::StatusDialogThread(QObject *parent) : QThread(parent)
{
nextDelay = 300;
}
void StatusDialogThread::startit()
{
running = -1;
start();
}
void StatusDialogThread::stop(int count)
{
running = count;
}
void StatusDialogThread::run()
{
while(--running > -1) {
emit nextBump();
QApplication::processEvents();
msleep(nextDelay);
}
emit hideit();
}
bool StatusDialog::isRunning()
{
return thread.isRunning();
}