summaryrefslogtreecommitdiffstats
path: root/kdeui/tests/kprogresstest.cpp
blob: 7b7024135eee6df7759f72463385b154bfcb4a0f (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 <tqwidget.h>
#include "kprogress.h"


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

void MyWidget::timerEvent(TQTimerEvent *)
{
  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;
}