summaryrefslogtreecommitdiffstats
path: root/kdeui/tests/kprogresstest.cpp
blob: d748fcb0f3accdd5a528b87e5d3fb5e794ada5a2 (plain)
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
#include <kapplication.h>
#include <qwidget.h>
#include "kprogress.h"


class MyWidget : public QWidget {
public:
	MyWidget() : QWidget()
	{
		setFixedSize(440, 80);
		Progress = new KProgress(this);
		Progress->resize(400, 40);
		Progress->move(20, 20);
		startTimer(50);
	}
	
private:
	KProgress *Progress;
	
	void timerEvent(QTimerEvent *);
};

void MyWidget::timerEvent(QTimerEvent *)
{
  static enum { fwd, back } direction = fwd;
  //static KProgress::BarStyle style = KProgress::Solid;
  if (direction == fwd) 
	{
	  if (Progress->value() == Progress->maxValue())
		direction = back;
	  else
		Progress->advance(1);
	} 
  else 
	{
	  if (Progress->value() == 0 /*Progress->minValue()*/) 
		{
				direction = fwd;
				//style = (style == KProgress::Solid)? KProgress::Blocked : KProgress::Solid;
				//Progress->setBarStyle(style);
		} 
	  else
		Progress->advance(-1);
	}
}

int main(int argc, char *argv[])
{
	KApplication app(argc, argv, "KProgressTest");
	MyWidget w;
	
	app.setMainWidget(&w);

	w.show();
	
	int ret = app.exec();
	return ret;
}