1 | #!/usr/local/bin/csi -s |
---|
2 | ; vim:filetype=chicken expandtab tabstop=2 textwidth=76: |
---|
3 | |
---|
4 | (use posix qt-light utils) |
---|
5 | |
---|
6 | (define *app* (qt:init)) |
---|
7 | |
---|
8 | (define *window* (qt:widget #<<TIMER |
---|
9 | <?xml version="1.0" encoding="UTF-8"?> |
---|
10 | <ui version="4.0"> |
---|
11 | <class>Form</class> |
---|
12 | <widget class="QWidget" name="Form"> |
---|
13 | <property name="geometry"> |
---|
14 | <rect> |
---|
15 | <x>0</x> |
---|
16 | <y>0</y> |
---|
17 | <width>194</width> |
---|
18 | <height>149</height> |
---|
19 | </rect> |
---|
20 | </property> |
---|
21 | <property name="windowTitle"> |
---|
22 | <string>Form</string> |
---|
23 | </property> |
---|
24 | <widget class="QPushButton" name="startButton"> |
---|
25 | <property name="geometry"> |
---|
26 | <rect> |
---|
27 | <x>20</x> |
---|
28 | <y>80</y> |
---|
29 | <width>80</width> |
---|
30 | <height>24</height> |
---|
31 | </rect> |
---|
32 | </property> |
---|
33 | <property name="text"> |
---|
34 | <string>qt:start</string> |
---|
35 | </property> |
---|
36 | </widget> |
---|
37 | <widget class="QLCDNumber" name="lcdNumber"> |
---|
38 | <property name="geometry"> |
---|
39 | <rect> |
---|
40 | <x>120</x> |
---|
41 | <y>80</y> |
---|
42 | <width>61</width> |
---|
43 | <height>61</height> |
---|
44 | </rect> |
---|
45 | </property> |
---|
46 | <property name="font"> |
---|
47 | <font> |
---|
48 | <pointsize>9</pointsize> |
---|
49 | </font> |
---|
50 | </property> |
---|
51 | <property name="numDigits"> |
---|
52 | <number>2</number> |
---|
53 | </property> |
---|
54 | <property name="digitCount"> |
---|
55 | <number>2</number> |
---|
56 | </property> |
---|
57 | <property name="intValue" stdset="0"> |
---|
58 | <number>10</number> |
---|
59 | </property> |
---|
60 | </widget> |
---|
61 | <widget class="QLabel" name="label"> |
---|
62 | <property name="geometry"> |
---|
63 | <rect> |
---|
64 | <x>10</x> |
---|
65 | <y>10</y> |
---|
66 | <width>181</width> |
---|
67 | <height>51</height> |
---|
68 | </rect> |
---|
69 | </property> |
---|
70 | <property name="font"> |
---|
71 | <font> |
---|
72 | <pointsize>13</pointsize> |
---|
73 | </font> |
---|
74 | </property> |
---|
75 | <property name="text"> |
---|
76 | <string>Click stop or wait |
---|
77 | for the time to run out</string> |
---|
78 | </property> |
---|
79 | </widget> |
---|
80 | <widget class="QPushButton" name="stopButton"> |
---|
81 | <property name="geometry"> |
---|
82 | <rect> |
---|
83 | <x>20</x> |
---|
84 | <y>110</y> |
---|
85 | <width>80</width> |
---|
86 | <height>24</height> |
---|
87 | </rect> |
---|
88 | </property> |
---|
89 | <property name="text"> |
---|
90 | <string>qt:stop</string> |
---|
91 | </property> |
---|
92 | </widget> |
---|
93 | </widget> |
---|
94 | <resources/> |
---|
95 | <connections/> |
---|
96 | </ui> |
---|
97 | TIMER |
---|
98 | )) |
---|
99 | |
---|
100 | ;buttons |
---|
101 | (define *start* (qt:find *window* "startButton")) |
---|
102 | (define *stop* (qt:find *window* "stopButton")) |
---|
103 | |
---|
104 | ;lcd number display |
---|
105 | (define *lcd* (qt:find *window* "lcdNumber")) |
---|
106 | |
---|
107 | ;Qt timer object |
---|
108 | (define *ticker* (qt:timer 1)) |
---|
109 | |
---|
110 | ;signal to fire upon each timeout |
---|
111 | (qt:connect |
---|
112 | *ticker* "timeout()" |
---|
113 | (qt:receiver |
---|
114 | (lambda () |
---|
115 | (let ((seconds (qt:property *lcd* "intValue"))) |
---|
116 | (cond |
---|
117 | ((< seconds 1) |
---|
118 | (set! (qt:property *lcd* "intValue") 0) |
---|
119 | (qt:stop *ticker*)) |
---|
120 | (else |
---|
121 | (set! (qt:property *lcd* "intValue") (- seconds 1)))))))) |
---|
122 | |
---|
123 | (define (startButton) |
---|
124 | (qt:start *ticker*)) |
---|
125 | |
---|
126 | (define (stopButton) |
---|
127 | (qt:stop *ticker*)) |
---|
128 | |
---|
129 | (qt:connect *start* "clicked()" startButton) |
---|
130 | (qt:connect *stop* "clicked()" stopButton) |
---|
131 | |
---|
132 | (qt:show *window*) |
---|
133 | (qt:run) |
---|