More Symbian fixes.
[dorian] / widgets / progress.cpp
1 #include <QtGui>
2
3 #include "progress.h"
4 #include "trace.h"
5
6 Progress::Progress(QWidget *parent): QLabel(parent), progress(0), timer(-1)
7 {
8     hide();
9 }
10
11 void Progress::setProgress(qreal p)
12 {
13     if (progress != p) {
14         progress = p;
15         flash();
16         update();
17     }
18 }
19
20 void Progress::paintEvent(QPaintEvent *e)
21 {
22     Q_UNUSED(e);
23     QPainter painter(this);
24     painter.setBrush(QBrush(QColor(100, 100, 100, 177)));
25     painter.setPen(Qt::NoPen);
26     int w = int(width() * progress);
27     int h = height();
28     painter.drawRect(0, 0, w, h);
29     painter.setBrush(QBrush(QColor(100, 100, 100, 50)));
30     painter.drawRect(w, 0, width(), h);
31 }
32
33 void Progress::flash()
34 {
35     killTimer(timer);
36     show();
37     timer = startTimer(700);
38 }
39
40 void Progress::timerEvent(QTimerEvent *e)
41 {
42     if (e->timerId() == timer) {
43         killTimer(timer);
44         hide();
45     }
46 }