summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2004-09-28 05:54:30 (UTC)
committer llornkcor <llornkcor>2004-09-28 05:54:30 (UTC)
commitc6daaf1849427191cb449e742681629bdaee4570 (patch) (unidiff)
tree4864b281a4de726de8eeaff9d13c84b1426fb5ba
parent9c8f2e26e05be9230ed960d4b4ed21dc658df33e (diff)
downloadopie-c6daaf1849427191cb449e742681629bdaee4570.zip
opie-c6daaf1849427191cb449e742681629bdaee4570.tar.gz
opie-c6daaf1849427191cb449e742681629bdaee4570.tar.bz2
treble and bass sliders not being hidden on system that dont have those devices
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/volumeapplet/volume.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/core/applets/volumeapplet/volume.cpp b/core/applets/volumeapplet/volume.cpp
index 276f47f..6a14d07 100644
--- a/core/applets/volumeapplet/volume.cpp
+++ b/core/applets/volumeapplet/volume.cpp
@@ -1,781 +1,780 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "volume.h" 21#include "volume.h"
22#include "oledbox.h" 22#include "oledbox.h"
23 23
24#include <opie2/odevice.h> 24#include <opie2/odevice.h>
25#include <opie2/otaskbarapplet.h> 25#include <opie2/otaskbarapplet.h>
26#include <qpe/resource.h> 26#include <qpe/resource.h>
27#include <qpe/applnk.h> 27#include <qpe/applnk.h>
28#include <qpe/config.h> 28#include <qpe/config.h>
29#include <qpe/qcopenvelope_qws.h> 29#include <qpe/qcopenvelope_qws.h>
30 30
31#include <qpainter.h> 31#include <qpainter.h>
32#include <qcheckbox.h> 32#include <qcheckbox.h>
33#include <qslider.h> 33#include <qslider.h>
34#include <qlayout.h> 34#include <qlayout.h>
35#include <qvbox.h> 35#include <qvbox.h>
36#include <qlabel.h> 36#include <qlabel.h>
37#include <qpushbutton.h> 37#include <qpushbutton.h>
38#include <qtimer.h> 38#include <qtimer.h>
39 39
40#include <stdio.h> 40#include <stdio.h>
41 41
42using namespace Opie::Core; 42using namespace Opie::Core;
43 43
44#define RATE_TIMER_INTERVAL 100 44#define RATE_TIMER_INTERVAL 100
45// Ten times per second is fine (RATE_TIMER_INTERVAL 100). A shorter time 45// Ten times per second is fine (RATE_TIMER_INTERVAL 100). A shorter time
46// results in "hanging" buttons on the iPAQ due to quite high CPU consumption. 46// results in "hanging" buttons on the iPAQ due to quite high CPU consumption.
47 47
48 48
49/* XPM */ 49/* XPM */
50using namespace Opie::Ui; 50using namespace Opie::Ui;
51static const char * vol_xpm[] = { 51static const char * vol_xpm[] = {
52"20 20 3 1", 52"20 20 3 1",
53" c None", 53" c None",
54". c #0000FF", 54". c #0000FF",
55"+ c #000000", 55"+ c #000000",
56" ", 56" ",
57" . ", 57" . ",
58" . . . . ", 58" . . . . ",
59" . . . . . . ", 59" . . . . . . ",
60" . . . . . . . ", 60" . . . . . . . ",
61" . . ..... . . ", 61" . . ..... . . ",
62" . ... ..... ... ", 62" . ... ..... ... ",
63" ........... .... ", 63" ........... .... ",
64" ................. ", 64" ................. ",
65"++++++++++++++++++++", 65"++++++++++++++++++++",
66" .................. ", 66" .................. ",
67" . ............. . ", 67" . ............. . ",
68" . ..... ....... ", 68" . ..... ....... ",
69" . ... ..... . ", 69" . ... ..... . ",
70" . ... ..... . ", 70" . ... ..... . ",
71" . ... ..... ", 71" . ... ..... ",
72" . . . . . ", 72" . . . . . ",
73" . . . ", 73" . . . ",
74" . . . ", 74" . . . ",
75" "}; 75" "};
76/* XPM */ 76/* XPM */
77static const char * mic_xpm[] = { 77static const char * mic_xpm[] = {
78"20 20 21 1", 78"20 20 21 1",
79" c None", 79" c None",
80". c #000000", 80". c #000000",
81"+ c #EEEEEE", 81"+ c #EEEEEE",
82"@ c #B4B6B4", 82"@ c #B4B6B4",
83"# c #8B8D8B", 83"# c #8B8D8B",
84"$ c #D5D6D5", 84"$ c #D5D6D5",
85"% c #E6E6E6", 85"% c #E6E6E6",
86"& c #9C9D9C", 86"& c #9C9D9C",
87"* c #6A696A", 87"* c #6A696A",
88"= c #E6E2E6", 88"= c #E6E2E6",
89"- c #F6F2F6", 89"- c #F6F2F6",
90"; c #CDC6CD", 90"; c #CDC6CD",
91"> c #737573", 91"> c #737573",
92", c #4A484A", 92", c #4A484A",
93"' c #DEDEDE", 93"' c #DEDEDE",
94") c #F6EEF6", 94") c #F6EEF6",
95"! c #414041", 95"! c #414041",
96"~ c #202020", 96"~ c #202020",
97"{ c #ACAEAC", 97"{ c #ACAEAC",
98"] c #838583", 98"] c #838583",
99"^ c #6A656A", 99"^ c #6A656A",
100" ", 100" ",
101" .... ", 101" .... ",
102" .+@+#. ", 102" .+@+#. ",
103" ..$%&%*. ", 103" ..$%&%*. ",
104" .=-.;=>=,. ", 104" .=-.;=>=,. ",
105" .'+).&+!+. ", 105" .'+).&+!+. ",
106" .+;+;.~+~. ", 106" .+;+;.~+~. ",
107" ..%{%,.... ", 107" ..%{%,.... ",
108" ..&=>=~.. ", 108" ..&=>=~.. ",
109" .+..]^,.. ", 109" .+..]^,.. ",
110" .+....... ", 110" .+....... ",
111" .%... ", 111" .%... ",
112" .=... ", 112" .=... ",
113" .+... ", 113" .+... ",
114" .+... ", 114" .+... ",
115" .... ", 115" .... ",
116" .... ", 116" .... ",
117" .. ", 117" .. ",
118" . ", 118" . ",
119". "}; 119". "};
120 120
121 121
122static const char * bass_xpm[] = { 122static const char * bass_xpm[] = {
123"20 20 3 1", 123"20 20 3 1",
124" c None", 124" c None",
125". c #000000", 125". c #000000",
126"+ c #0000FF", 126"+ c #0000FF",
127" ", 127" ",
128" ", 128" ",
129" ", 129" ",
130"..... +++ ......", 130"..... +++ ......",
131" +++++++ ", 131" +++++++ ",
132" ++ ++ ", 132" ++ ++ ",
133"... ++ ... ++ ++ .", 133"... ++ ... ++ ++ .",
134" +++ ++ ++ ", 134" +++ ++ ++ ",
135" ++++ ++ ", 135" ++++ ++ ",
136"... ++++ .. ++ .....", 136"... ++++ .. ++ .....",
137" ++ ++ ", 137" ++ ++ ",
138" ++ ++ ", 138" ++ ++ ",
139"..........++ ++ .", 139"..........++ ++ .",
140" ++ ", 140" ++ ",
141" ++ ", 141" ++ ",
142"...... ++ .........", 142"...... ++ .........",
143" + ", 143" + ",
144" ", 144" ",
145" ", 145" ",
146" "}; 146" "};
147 147
148 148
149static const char * treble_xpm[] = { 149static const char * treble_xpm[] = {
150"20 20 3 1", 150"20 20 3 1",
151" c None", 151" c None",
152". c #0000FF", 152". c #0000FF",
153"+ c #000000", 153"+ c #000000",
154" .. ", 154" .. ",
155" . .. ", 155" . .. ",
156" . .. ", 156" . .. ",
157"++++++++ . .. ++++++", 157"++++++++ . .. ++++++",
158" . . ", 158" . . ",
159" ... ", 159" ... ",
160"++++++++ . +++++++", 160"++++++++ . +++++++",
161" .. ", 161" .. ",
162" .. . ", 162" .. . ",
163"+++ .. ... +++++++", 163"+++ .. ... +++++++",
164" .. .. .. ", 164" .. .. .. ",
165" .. . . .. ", 165" .. . . .. ",
166"+++ .. . . + . +++++", 166"+++ .. . . + . +++++",
167" .. . .. ", 167" .. . .. ",
168" .. . .. ", 168" .. . .. ",
169"++++ ...... +++++++", 169"++++ ...... +++++++",
170" . ", 170" . ",
171" .. . ", 171" .. . ",
172" .. . ", 172" .. . ",
173" .. "}; 173" .. "};
174 174
175 175
176 176
177 177
178/* XPM */ 178/* XPM */
179static const char * alarm_xpm[] = { 179static const char * alarm_xpm[] = {
180"20 20 33 1", 180"20 20 33 1",
181" c None", 181" c None",
182". c #080602", 182". c #080602",
183"+ c #AAA602", 183"+ c #AAA602",
184"@ c #252002", 184"@ c #252002",
185"# c #434202", 185"# c #434202",
186"$ c #795602", 186"$ c #795602",
187"% c #C3C20D", 187"% c #C3C20D",
188"& c #DADAC2", 188"& c #DADAC2",
189"* c #826002", 189"* c #826002",
190"= c #740502", 190"= c #740502",
191"- c #D6D602", 191"- c #D6D602",
192"; c #322E02", 192"; c #322E02",
193"> c #826A02", 193"> c #826A02",
194", c #F1F195", 194", c #F1F195",
195"' c #959215", 195"' c #959215",
196") c #423602", 196") c #423602",
197"! c #4B0302", 197"! c #4B0302",
198"~ c #844315", 198"~ c #844315",
199"{ c #AAAA2A", 199"{ c #AAAA2A",
200"] c #E2DE42", 200"] c #E2DE42",
201"^ c #BA7E04", 201"^ c #BA7E04",
202"/ c #7F7502", 202"/ c #7F7502",
203"( c #828276", 203"( c #828276",
204"_ c #FEFE4E", 204"_ c #FEFE4E",
205": c #7D1902", 205": c #7D1902",
206"< c #989656", 206"< c #989656",
207"[ c #260B02", 207"[ c #260B02",
208"} c #F7F7D8", 208"} c #F7F7D8",
209"| c #DCDA5A", 209"| c #DCDA5A",
210"1 c #823102", 210"1 c #823102",
211"2 c #B1AC6B", 211"2 c #B1AC6B",
212"3 c #F7F710", 212"3 c #F7F710",
213"4 c #838204", 213"4 c #838204",
214" ", 214" ",
215" ", 215" ",
216" 4'4/ ", 216" 4'4/ ",
217" /-^= ", 217" /-^= ",
218" 42{4>4 ", 218" 42{4>4 ",
219" '2|+*$44 ", 219" '2|+*$44 ",
220" +2&3+$1*44 ", 220" +2&3+$1*44 ",
221" (%_}_+/$:>/4 ", 221" (%_}_+/$:>/4 ",
222" 4%_}3+#;>:*4 ", 222" 4%_}3+#;>:*4 ",
223" 4%_}&+#[1$/4 ", 223" 4%_}&+#[1$/4 ",
224" 4%_,2')[~~>4 ", 224" 4%_,2')[~~>4 ",
225" 4%33'4#@~1>4 ", 225" 4%33'4#@~1>4 ",
226" 4%3344#[:>/4 ", 226" 4%3344#[:>/4 ",
227" 42&_3'4#@>:*44 ", 227" 42&_3'4#@>:*44 ",
228" 42|}}3'4#[;$)$44 ", 228" 42|}}3'4#[;$)$44 ",
229"444{]]2^~~:!!#.@##/ ", 229"444{]]2^~~:!!#.@##/ ",
230"4444-%*:==!!=...../ ", 230"4444-%*:==!!=...../ ",
231" /:[.. ", 231" /:[.. ",
232" /@. ", 232" /@. ",
233" "}; 233" "};
234 234
235VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *parent, const char *name ) 235VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *parent, const char *name )
236 : QFrame ( parent, name, WStyle_StaysOnTop | WType_Popup ) 236 : QFrame ( parent, name, WStyle_StaysOnTop | WType_Popup )
237{ 237{
238 m_icon = icon; 238 m_icon = icon;
239 239
240 bool has_wav_alarm = true; 240 bool has_wav_alarm = true;
241 bool has_bass = true; 241 bool has_bass = true;
242 bool has_treble = true; 242 bool has_treble = true;
243 243
244 switch ( ODevice::inst ( )-> model ( )) { // we need to add other devices eventually 244 switch ( ODevice::inst ( )-> model ( )) { // we need to add other devices eventually
245 case Model_Zaurus_SL5000: 245 case Model_Zaurus_SL5000:
246 has_wav_alarm = false; //poor guys probably feeling left out... 246 has_wav_alarm = false; //poor guys probably feeling left out...
247 break; 247 break;
248 default: 248 default:
249 break; 249 break;
250 } 250 }
251 251
252 if ( !ODevice::inst ( )-> series ( ) == Model_iPAQ ) { 252 if ( !ODevice::inst()->modelString().contains( "Model_iPAQ" )) {
253 has_bass = false; 253 has_bass = false;
254 has_treble = false; 254 has_treble = false;
255 } 255 }
256 256
257
258 setFrameStyle ( QFrame::PopupPanel | QFrame::Raised ); 257 setFrameStyle ( QFrame::PopupPanel | QFrame::Raised );
259 258
260 QGridLayout *grid = new QGridLayout ( this, 1, 1, 6, 4 ); 259 QGridLayout *grid = new QGridLayout ( this, 1, 1, 6, 4 );
261 grid-> setSpacing ( 4 ); 260 grid-> setSpacing ( 4 );
262 grid-> setMargin ( 6 ); 261 grid-> setMargin ( 6 );
263 262
264 QVBoxLayout *vbox; 263 QVBoxLayout *vbox;
265 QLabel *l; 264 QLabel *l;
266 265
267 vbox = new QVBoxLayout ( ); 266 vbox = new QVBoxLayout ( );
268 vbox-> setSpacing ( 4 ); 267 vbox-> setSpacing ( 4 );
269 grid-> addLayout ( vbox, 1, 0 ); 268 grid-> addLayout ( vbox, 1, 0 );
270 269
271 upButton = new QPushButton ( this ); 270 upButton = new QPushButton ( this );
272 upButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); 271 upButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding ));
273 upButton-> setPixmap ( Resource::loadPixmap ( "up" )); 272 upButton-> setPixmap ( Resource::loadPixmap ( "up" ));
274 upButton-> setFocusPolicy ( QWidget::NoFocus ); 273 upButton-> setFocusPolicy ( QWidget::NoFocus );
275 274
276 vbox-> addWidget ( upButton ); 275 vbox-> addWidget ( upButton );
277 276
278 downButton = new QPushButton ( this ); 277 downButton = new QPushButton ( this );
279 downButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); 278 downButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding ));
280 downButton-> setPixmap ( Resource::loadPixmap ( "down" )); 279 downButton-> setPixmap ( Resource::loadPixmap ( "down" ));
281 downButton-> setFocusPolicy ( QWidget::NoFocus ); 280 downButton-> setFocusPolicy ( QWidget::NoFocus );
282 281
283 vbox-> addWidget ( downButton ); 282 vbox-> addWidget ( downButton );
284 283
285 volSlider = new QSlider ( this ); 284 volSlider = new QSlider ( this );
286 volSlider-> setRange ( 0, 100 ); 285 volSlider-> setRange ( 0, 100 );
287 volSlider-> setTickmarks ( QSlider::Both ); 286 volSlider-> setTickmarks ( QSlider::Both );
288 volSlider-> setTickInterval ( 20 ); 287 volSlider-> setTickInterval ( 20 );
289 volSlider-> setFocusPolicy ( QWidget::NoFocus ); 288 volSlider-> setFocusPolicy ( QWidget::NoFocus );
290 289
291 l = new QLabel ( this ); 290 l = new QLabel ( this );
292 l-> setPixmap ( QPixmap ( vol_xpm )); 291 l-> setPixmap ( QPixmap ( vol_xpm ));
293 292
294 grid-> addWidget ( l, 0, 1, AlignCenter ); 293 grid-> addWidget ( l, 0, 1, AlignCenter );
295 grid-> addWidget ( volSlider, 1, 1, AlignCenter ); 294 grid-> addWidget ( volSlider, 1, 1, AlignCenter );
296 295
297 volLed = new OLedBox ( green, this ); 296 volLed = new OLedBox ( green, this );
298 volLed-> setFocusPolicy ( QWidget::NoFocus ); 297 volLed-> setFocusPolicy ( QWidget::NoFocus );
299 volLed-> setFixedSize ( 16, 16 ); 298 volLed-> setFixedSize ( 16, 16 );
300 299
301 grid-> addWidget ( volLed, 2, 1, AlignCenter ); 300 grid-> addWidget ( volLed, 2, 1, AlignCenter );
302 301
303 QVBox *basstrebleBox = new QVBox( this ); 302 QVBox *basstrebleBox = new QVBox( this );
304 303
305 trebleSlider = new QSlider ( basstrebleBox ); 304 trebleSlider = new QSlider ( basstrebleBox );
306 trebleSlider-> setRange ( 0, 100 ); 305 trebleSlider-> setRange ( 0, 100 );
307 trebleSlider-> setTickmarks ( QSlider::Both ); 306 trebleSlider-> setTickmarks ( QSlider::Both );
308 trebleSlider-> setTickInterval ( 20 ); 307 trebleSlider-> setTickInterval ( 20 );
309 trebleSlider->setMaximumHeight( 40 ); 308 trebleSlider->setMaximumHeight( 40 );
310 trebleSlider-> setFocusPolicy ( QWidget::NoFocus ); 309 trebleSlider-> setFocusPolicy ( QWidget::NoFocus );
311 310
312 bassSlider = new QSlider ( basstrebleBox ); 311 bassSlider = new QSlider ( basstrebleBox );
313 bassSlider-> setRange ( 0, 100 ); 312 bassSlider-> setRange ( 0, 100 );
314 bassSlider-> setTickmarks ( QSlider::Both ); 313 bassSlider-> setTickmarks ( QSlider::Both );
315 bassSlider-> setTickInterval ( 20 ); 314 bassSlider-> setTickInterval ( 20 );
316 bassSlider->setMaximumHeight( 40 ); 315 bassSlider->setMaximumHeight( 40 );
317 bassSlider-> setFocusPolicy ( QWidget::NoFocus ); 316 bassSlider-> setFocusPolicy ( QWidget::NoFocus );
318 317
319 QLabel *bassLabel = new QLabel ( this ); 318 QLabel *bassLabel = new QLabel ( this );
320 bassLabel-> setPixmap ( QPixmap ( bass_xpm )); 319 bassLabel-> setPixmap ( QPixmap ( bass_xpm ));
321 320
322 QLabel *trebleLabel = new QLabel( this ); 321 QLabel *trebleLabel = new QLabel( this );
323 trebleLabel->setPixmap( QPixmap ( treble_xpm ) ); 322 trebleLabel->setPixmap( QPixmap ( treble_xpm ) );
324 323
325 grid->addWidget( trebleLabel, 0, 4, AlignCenter ); 324 grid->addWidget( trebleLabel, 0, 4, AlignCenter );
326 grid->addWidget( basstrebleBox, 1, 4, AlignCenter ); 325 grid->addWidget( basstrebleBox, 1, 4, AlignCenter );
327 grid-> addWidget ( bassLabel, 2, 4, AlignCenter ); 326 grid-> addWidget ( bassLabel, 2, 4, AlignCenter );
328 327
329 if ( !has_bass ) { 328 if ( !has_bass ) {
330 bassSlider->hide(); 329 bassSlider->hide();
331 bassLabel->hide(); 330 bassLabel->hide();
332 } 331 }
333 332
334 if ( !has_treble ) { 333 if ( !has_treble ) {
335 trebleSlider->hide(); 334 trebleSlider->hide();
336 trebleLabel->hide(); 335 trebleLabel->hide();
337 } 336 }
338 337
339 micSlider = new QSlider ( this ); 338 micSlider = new QSlider ( this );
340 micSlider-> setRange ( 0, 100 ); 339 micSlider-> setRange ( 0, 100 );
341 micSlider-> setTickmarks ( QSlider::Both ); 340 micSlider-> setTickmarks ( QSlider::Both );
342 micSlider-> setTickInterval ( 20 ); 341 micSlider-> setTickInterval ( 20 );
343 micSlider-> setFocusPolicy ( QWidget::NoFocus ); 342 micSlider-> setFocusPolicy ( QWidget::NoFocus );
344 343
345 l = new QLabel ( this ); 344 l = new QLabel ( this );
346 l-> setPixmap ( QPixmap ( mic_xpm )); 345 l-> setPixmap ( QPixmap ( mic_xpm ));
347 346
348 grid-> addWidget ( l, 0, 2, AlignCenter ); 347 grid-> addWidget ( l, 0, 2, AlignCenter );
349 grid-> addWidget ( micSlider, 1, 2, AlignCenter ); 348 grid-> addWidget ( micSlider, 1, 2, AlignCenter );
350 349
351 micLed = new OLedBox ( red, this ); 350 micLed = new OLedBox ( red, this );
352 micLed-> setFocusPolicy ( QWidget::NoFocus ); 351 micLed-> setFocusPolicy ( QWidget::NoFocus );
353 micLed-> setFixedSize ( 16, 16 ); 352 micLed-> setFixedSize ( 16, 16 );
354 353
355 grid-> addWidget ( micLed, 2, 2, AlignCenter ); 354 grid-> addWidget ( micLed, 2, 2, AlignCenter );
356 355
357 alarmSlider = new QSlider ( this ); 356 alarmSlider = new QSlider ( this );
358 alarmSlider-> setRange ( 0, 100 ); 357 alarmSlider-> setRange ( 0, 100 );
359 alarmSlider-> setTickmarks ( QSlider::Both ); 358 alarmSlider-> setTickmarks ( QSlider::Both );
360 alarmSlider-> setTickInterval ( 20 ); 359 alarmSlider-> setTickInterval ( 20 );
361 alarmSlider-> setFocusPolicy ( QWidget::NoFocus ); 360 alarmSlider-> setFocusPolicy ( QWidget::NoFocus );
362 361
363 QLabel *alarmLabel = new QLabel ( this ); 362 QLabel *alarmLabel = new QLabel ( this );
364 alarmLabel-> setPixmap ( QPixmap ( alarm_xpm )); 363 alarmLabel-> setPixmap ( QPixmap ( alarm_xpm ));
365 364
366 grid-> addWidget ( alarmLabel, 0, 3, AlignCenter ); 365 grid-> addWidget ( alarmLabel, 0, 3, AlignCenter );
367 grid-> addWidget ( alarmSlider, 1, 3, AlignCenter ); 366 grid-> addWidget ( alarmSlider, 1, 3, AlignCenter );
368 367
369 alarmLed = new OLedBox ( yellow, this ); 368 alarmLed = new OLedBox ( yellow, this );
370 alarmLed-> setFocusPolicy ( QWidget::NoFocus ); 369 alarmLed-> setFocusPolicy ( QWidget::NoFocus );
371 alarmLed-> setFixedSize ( 16, 16 ); 370 alarmLed-> setFixedSize ( 16, 16 );
372 371
373 grid-> addWidget ( alarmLed, 2, 3, AlignCenter ); 372 grid-> addWidget ( alarmLed, 2, 3, AlignCenter );
374 373
375 if ( !has_wav_alarm ) { 374 if ( !has_wav_alarm ) {
376 alarmSlider-> hide ( ); 375 alarmSlider-> hide ( );
377 alarmLabel-> hide ( ); 376 alarmLabel-> hide ( );
378 alarmLed-> hide ( ); 377 alarmLed-> hide ( );
379 } 378 }
380 379
381 grid-> addWidget ( new QLabel ( tr( "Enable Sounds for:" ), this ), 0, 6, AlignVCenter | AlignLeft ); 380 grid-> addWidget ( new QLabel ( tr( "Enable Sounds for:" ), this ), 0, 6, AlignVCenter | AlignLeft );
382 381
383 vbox = new QVBoxLayout ( ); 382 vbox = new QVBoxLayout ( );
384 vbox-> setSpacing ( 4 ); 383 vbox-> setSpacing ( 4 );
385 grid-> addMultiCellLayout ( vbox, 1, 2, 6, 6 ); 384 grid-> addMultiCellLayout ( vbox, 1, 2, 6, 6 );
386 385
387 tapBox = new QCheckBox ( tr( "Screen Taps" ), this ); 386 tapBox = new QCheckBox ( tr( "Screen Taps" ), this );
388 tapBox-> setFocusPolicy ( QWidget::NoFocus ); 387 tapBox-> setFocusPolicy ( QWidget::NoFocus );
389 388
390 vbox-> addWidget ( tapBox, AlignVCenter | AlignLeft ); 389 vbox-> addWidget ( tapBox, AlignVCenter | AlignLeft );
391 390
392 keyBox = new QCheckBox ( tr( "Key Clicks" ), this ); 391 keyBox = new QCheckBox ( tr( "Key Clicks" ), this );
393 keyBox-> setFocusPolicy ( QWidget::NoFocus ); 392 keyBox-> setFocusPolicy ( QWidget::NoFocus );
394 393
395 vbox-> addWidget ( keyBox, AlignVCenter | AlignLeft ); 394 vbox-> addWidget ( keyBox, AlignVCenter | AlignLeft );
396 395
397 alarmBox = new QCheckBox ( tr( "Alarm Sound" ), this ); 396 alarmBox = new QCheckBox ( tr( "Alarm Sound" ), this );
398 alarmBox-> setFocusPolicy ( QWidget::NoFocus ); 397 alarmBox-> setFocusPolicy ( QWidget::NoFocus );
399 398
400 vbox-> addWidget ( alarmBox, AlignVCenter | AlignLeft ); 399 vbox-> addWidget ( alarmBox, AlignVCenter | AlignLeft );
401 400
402 if ( has_wav_alarm ) { 401 if ( has_wav_alarm ) {
403 alarmBox-> hide ( ); 402 alarmBox-> hide ( );
404 } 403 }
405 404
406 vbox-> addStretch ( 100 ); 405 vbox-> addStretch ( 100 );
407 406
408 setFixedSize ( sizeHint ( )); 407 setFixedSize ( sizeHint ( ));
409 setFocusPolicy ( QWidget::NoFocus ); 408 setFocusPolicy ( QWidget::NoFocus );
410 409
411 rateTimer = new QTimer( this ); 410 rateTimer = new QTimer( this );
412 connect ( rateTimer, SIGNAL( timeout()), this, SLOT( rateTimerDone())); 411 connect ( rateTimer, SIGNAL( timeout()), this, SLOT( rateTimerDone()));
413 412
414 connect ( upButton, SIGNAL( pressed()), this, SLOT( buttonChanged())); 413 connect ( upButton, SIGNAL( pressed()), this, SLOT( buttonChanged()));
415 connect ( upButton, SIGNAL( released()), this, SLOT( buttonChanged())); 414 connect ( upButton, SIGNAL( released()), this, SLOT( buttonChanged()));
416 connect ( downButton, SIGNAL( pressed()), this, SLOT( buttonChanged())); 415 connect ( downButton, SIGNAL( pressed()), this, SLOT( buttonChanged()));
417 connect ( downButton, SIGNAL( released()), this, SLOT( buttonChanged())); 416 connect ( downButton, SIGNAL( released()), this, SLOT( buttonChanged()));
418 417
419 connect ( micSlider, SIGNAL( valueChanged(int)), this, SLOT( micMoved(int))); 418 connect ( micSlider, SIGNAL( valueChanged(int)), this, SLOT( micMoved(int)));
420 connect ( volSlider, SIGNAL( valueChanged(int)), this, SLOT( volMoved(int))); 419 connect ( volSlider, SIGNAL( valueChanged(int)), this, SLOT( volMoved(int)));
421 connect ( alarmSlider, SIGNAL( valueChanged(int)), this, SLOT( alarmMoved(int))); 420 connect ( alarmSlider, SIGNAL( valueChanged(int)), this, SLOT( alarmMoved(int)));
422 connect ( bassSlider, SIGNAL( valueChanged(int)), this, SLOT( bassMoved(int))); 421 connect ( bassSlider, SIGNAL( valueChanged(int)), this, SLOT( bassMoved(int)));
423 connect ( trebleSlider, SIGNAL( valueChanged(int)), this, SLOT( trebleMoved(int))); 422 connect ( trebleSlider, SIGNAL( valueChanged(int)), this, SLOT( trebleMoved(int)));
424 423
425 424
426 connect ( volLed, SIGNAL( toggled(bool)), this, SLOT( volMuteToggled(bool))); 425 connect ( volLed, SIGNAL( toggled(bool)), this, SLOT( volMuteToggled(bool)));
427 connect ( micLed, SIGNAL( toggled(bool)), this, SLOT( micMuteToggled(bool))); 426 connect ( micLed, SIGNAL( toggled(bool)), this, SLOT( micMuteToggled(bool)));
428 connect ( alarmLed, SIGNAL( toggled(bool)), this, SLOT( alarmSoundToggled(bool))); 427 connect ( alarmLed, SIGNAL( toggled(bool)), this, SLOT( alarmSoundToggled(bool)));
429 428
430 connect ( alarmBox, SIGNAL( toggled(bool)), this, SLOT( alarmSoundToggled(bool))); 429 connect ( alarmBox, SIGNAL( toggled(bool)), this, SLOT( alarmSoundToggled(bool)));
431 connect ( keyBox, SIGNAL( toggled(bool)), this, SLOT( keyClickToggled(bool))); 430 connect ( keyBox, SIGNAL( toggled(bool)), this, SLOT( keyClickToggled(bool)));
432 connect ( tapBox, SIGNAL( toggled(bool)), this, SLOT( screenTapToggled(bool))); 431 connect ( tapBox, SIGNAL( toggled(bool)), this, SLOT( screenTapToggled(bool)));
433 432
434 // initialize variables 433 // initialize variables
435 434
436 readConfig ( true ); 435 readConfig ( true );
437 436
438 // initialize the config file, in case some entries are missing 437 // initialize the config file, in case some entries are missing
439 438
440 writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_None ); 439 writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_None );
441 writeConfigEntry ( "BassPercent", m_vol_percent, UPD_None ); 440 writeConfigEntry ( "BassPercent", m_vol_percent, UPD_None );
442 writeConfigEntry ( "TreblePercent", m_vol_percent, UPD_None ); 441 writeConfigEntry ( "TreblePercent", m_vol_percent, UPD_None );
443 writeConfigEntry ( "Mute", m_vol_muted, UPD_None ); 442 writeConfigEntry ( "Mute", m_vol_muted, UPD_None );
444 writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); 443 writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None );
445 writeConfigEntry ( "TouchSound", m_snd_touch, UPD_None ); 444 writeConfigEntry ( "TouchSound", m_snd_touch, UPD_None );
446 writeConfigEntry ( "KeySound", m_snd_key, UPD_None ); 445 writeConfigEntry ( "KeySound", m_snd_key, UPD_None );
447 writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); 446 writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol );
448 447
449 writeConfigEntry ( "Mic", m_mic_percent, UPD_None ); 448 writeConfigEntry ( "Mic", m_mic_percent, UPD_None );
450 writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); 449 writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic );
451} 450}
452 451
453bool VolumeControl::volMuted ( ) const 452bool VolumeControl::volMuted ( ) const
454{ 453{
455 return m_vol_muted; 454 return m_vol_muted;
456} 455}
457 456
458int VolumeControl::volPercent ( ) const 457int VolumeControl::volPercent ( ) const
459{ 458{
460 return m_vol_percent; 459 return m_vol_percent;
461} 460}
462 461
463void VolumeControl::keyPressEvent ( QKeyEvent *e ) 462void VolumeControl::keyPressEvent ( QKeyEvent *e )
464{ 463{
465 switch ( e-> key ( )) { 464 switch ( e-> key ( )) {
466 case Key_Up: 465 case Key_Up:
467 volSlider-> subtractStep ( ); 466 volSlider-> subtractStep ( );
468 break; 467 break;
469 case Key_Down: 468 case Key_Down:
470 volSlider-> addStep ( ); 469 volSlider-> addStep ( );
471 break; 470 break;
472 case Key_Space: 471 case Key_Space:
473 volLed-> toggle ( ); 472 volLed-> toggle ( );
474 break; 473 break;
475 case Key_Escape: 474 case Key_Escape:
476 hide ( ); 475 hide ( );
477 break; 476 break;
478 } 477 }
479} 478}
480 479
481void VolumeControl::buttonChanged ( ) 480void VolumeControl::buttonChanged ( )
482{ 481{
483 if ( upButton-> isDown ( ) || downButton->isDown ( )) { 482 if ( upButton-> isDown ( ) || downButton->isDown ( )) {
484 rateTimerDone ( ); // Call it one time manually, otherwise it wont get 483 rateTimerDone ( ); // Call it one time manually, otherwise it wont get
485 // called at all when a button is pressed for a time 484 // called at all when a button is pressed for a time
486 // shorter than RATE_TIMER_INTERVAL. 485 // shorter than RATE_TIMER_INTERVAL.
487 rateTimer-> start ( RATE_TIMER_INTERVAL, false ); 486 rateTimer-> start ( RATE_TIMER_INTERVAL, false );
488 } 487 }
489 else 488 else
490 rateTimer-> stop ( ); 489 rateTimer-> stop ( );
491} 490}
492 491
493void VolumeControl::rateTimerDone ( ) 492void VolumeControl::rateTimerDone ( )
494{ 493{
495 if ( upButton-> isDown ( )) 494 if ( upButton-> isDown ( ))
496 volSlider-> setValue ( volSlider-> value ( ) - 2 ); 495 volSlider-> setValue ( volSlider-> value ( ) - 2 );
497 else // if ( downButton-> isDown ( )) 496 else // if ( downButton-> isDown ( ))
498 volSlider-> setValue ( volSlider-> value ( ) + 2 ); 497 volSlider-> setValue ( volSlider-> value ( ) + 2 );
499} 498}
500 499
501void VolumeControl::show ( bool /*showMic*/ ) 500void VolumeControl::show ( bool /*showMic*/ )
502{ 501{
503 readConfig ( ); 502 readConfig ( );
504 503
505 QPoint curPos = m_icon-> mapToGlobal ( QPoint ( 0, 0 )); 504 QPoint curPos = m_icon-> mapToGlobal ( QPoint ( 0, 0 ));
506 505
507 int w = sizeHint ( ). width ( ); 506 int w = sizeHint ( ). width ( );
508 int x = curPos.x ( ) - ( w / 2 ); 507 int x = curPos.x ( ) - ( w / 2 );
509 508
510 if (( x + w ) > QPEApplication::desktop ( )-> width ( )) 509 if (( x + w ) > QPEApplication::desktop ( )-> width ( ))
511 x = QPEApplication::desktop ( )-> width ( ) - w; 510 x = QPEApplication::desktop ( )-> width ( ) - w;
512 511
513 move ( x, curPos. y ( ) - sizeHint ( ). height ( )); 512 move ( x, curPos. y ( ) - sizeHint ( ). height ( ));
514 QFrame::show ( ); 513 QFrame::show ( );
515 514
516} 515}
517 516
518void VolumeControl::readConfig ( bool force ) 517void VolumeControl::readConfig ( bool force )
519{ 518{
520 Config cfg ( "qpe" ); 519 Config cfg ( "qpe" );
521 cfg. setGroup ( "Volume" ); 520 cfg. setGroup ( "Volume" );
522 521
523 int old_vp = m_vol_percent; 522 int old_vp = m_vol_percent;
524 int old_mp = m_mic_percent; 523 int old_mp = m_mic_percent;
525 int old_bass = m_bass_percent; 524 int old_bass = m_bass_percent;
526 int old_treble = m_treble_percent; 525 int old_treble = m_treble_percent;
527 bool old_vm = m_vol_muted; 526 bool old_vm = m_vol_muted;
528 bool old_mm = m_mic_muted; 527 bool old_mm = m_mic_muted;
529 bool old_sk = m_snd_key; 528 bool old_sk = m_snd_key;
530 bool old_st = m_snd_touch; 529 bool old_st = m_snd_touch;
531 bool old_sa = m_snd_alarm; 530 bool old_sa = m_snd_alarm;
532 int old_ap = m_alarm_percent; 531 int old_ap = m_alarm_percent;
533 532
534 m_vol_percent = cfg. readNumEntry ( "VolumePercent", 50 ); 533 m_vol_percent = cfg. readNumEntry ( "VolumePercent", 50 );
535 m_mic_percent = cfg. readNumEntry ( "Mic", 50 ); 534 m_mic_percent = cfg. readNumEntry ( "Mic", 50 );
536 m_bass_percent = cfg. readNumEntry ( "BassPercent", 50 ); 535 m_bass_percent = cfg. readNumEntry ( "BassPercent", 50 );
537 m_treble_percent = cfg. readNumEntry ( "TreblePercent", 50 ); 536 m_treble_percent = cfg. readNumEntry ( "TreblePercent", 50 );
538 m_vol_muted = cfg. readBoolEntry ( "Mute", 0 ); 537 m_vol_muted = cfg. readBoolEntry ( "Mute", 0 );
539 m_mic_muted = cfg. readBoolEntry ( "MicMute", 0 ); 538 m_mic_muted = cfg. readBoolEntry ( "MicMute", 0 );
540 m_snd_key = cfg. readBoolEntry ( "KeySound", 0 ); 539 m_snd_key = cfg. readBoolEntry ( "KeySound", 0 );
541 m_snd_touch = cfg. readBoolEntry ( "TouchSound", 0 ); 540 m_snd_touch = cfg. readBoolEntry ( "TouchSound", 0 );
542 m_snd_alarm = cfg. readBoolEntry ( "AlarmSound", 1 ); 541 m_snd_alarm = cfg. readBoolEntry ( "AlarmSound", 1 );
543 m_alarm_percent = cfg. readNumEntry ( "AlarmPercent", 65 ); 542 m_alarm_percent = cfg. readNumEntry ( "AlarmPercent", 65 );
544 543
545 if ( force || ( m_vol_percent != old_vp )) 544 if ( force || ( m_vol_percent != old_vp ))
546 volSlider-> setValue ( 100 - m_vol_percent ); 545 volSlider-> setValue ( 100 - m_vol_percent );
547 if ( force || ( m_mic_percent != old_mp )) 546 if ( force || ( m_mic_percent != old_mp ))
548 micSlider-> setValue ( 100 - m_mic_percent ); 547 micSlider-> setValue ( 100 - m_mic_percent );
549 if ( force || ( m_alarm_percent != old_ap )) 548 if ( force || ( m_alarm_percent != old_ap ))
550 alarmSlider-> setValue ( 100 - m_alarm_percent ); 549 alarmSlider-> setValue ( 100 - m_alarm_percent );
551 if ( force || ( m_bass_percent != old_bass )) 550 if ( force || ( m_bass_percent != old_bass ))
552 bassSlider-> setValue ( 100 - m_bass_percent ); 551 bassSlider-> setValue ( 100 - m_bass_percent );
553 if ( force || ( m_treble_percent != old_treble )) 552 if ( force || ( m_treble_percent != old_treble ))
554 trebleSlider-> setValue ( 100 - m_treble_percent ); 553 trebleSlider-> setValue ( 100 - m_treble_percent );
555 554
556 555
557 if ( force || ( m_vol_muted != old_vm )) 556 if ( force || ( m_vol_muted != old_vm ))
558 volLed-> setOn ( !m_vol_muted ); 557 volLed-> setOn ( !m_vol_muted );
559 if ( force || ( m_mic_muted != old_mm )) 558 if ( force || ( m_mic_muted != old_mm ))
560 micLed-> setOn ( !m_mic_muted ); 559 micLed-> setOn ( !m_mic_muted );
561 if ( force || ( m_snd_alarm != old_sa )) 560 if ( force || ( m_snd_alarm != old_sa ))
562 alarmLed-> setOn ( m_snd_alarm ); 561 alarmLed-> setOn ( m_snd_alarm );
563 562
564 if ( force || ( m_snd_key != old_sk )) 563 if ( force || ( m_snd_key != old_sk ))
565 keyBox-> setChecked ( m_snd_key ); 564 keyBox-> setChecked ( m_snd_key );
566 if ( force || ( m_snd_touch != old_st )) 565 if ( force || ( m_snd_touch != old_st ))
567 tapBox-> setChecked ( m_snd_touch ); 566 tapBox-> setChecked ( m_snd_touch );
568 if ( force || ( m_snd_alarm != old_sa )) 567 if ( force || ( m_snd_alarm != old_sa ))
569 alarmBox-> setChecked ( m_snd_alarm ); 568 alarmBox-> setChecked ( m_snd_alarm );
570} 569}
571 570
572 571
573void VolumeControl::volumeChanged ( bool /*nowMuted*/ ) 572void VolumeControl::volumeChanged ( bool /*nowMuted*/ )
574{ 573{
575 int prevVol = m_vol_percent; 574 int prevVol = m_vol_percent;
576 bool prevMute = m_vol_muted; 575 bool prevMute = m_vol_muted;
577 576
578 readConfig ( ); 577 readConfig ( );
579 578
580 // Handle case where muting it toggled 579 // Handle case where muting it toggled
581 if ( m_vol_muted != prevMute ) 580 if ( m_vol_muted != prevMute )
582 m_icon-> redraw ( true ); 581 m_icon-> redraw ( true );
583 else if ( prevVol != m_vol_percent ) // Avoid over repainting 582 else if ( prevVol != m_vol_percent ) // Avoid over repainting
584 m_icon-> redraw ( false ); 583 m_icon-> redraw ( false );
585} 584}
586 585
587void VolumeControl::micChanged ( bool nowMuted ) 586void VolumeControl::micChanged ( bool nowMuted )
588{ 587{
589 if ( !nowMuted ) 588 if ( !nowMuted )
590 readConfig ( ); 589 readConfig ( );
591 m_mic_muted = nowMuted; 590 m_mic_muted = nowMuted;
592} 591}
593 592
594void VolumeControl::screenTapToggled ( bool b ) 593void VolumeControl::screenTapToggled ( bool b )
595{ 594{
596 m_snd_touch = b; 595 m_snd_touch = b;
597 writeConfigEntry ( "TouchSound", m_snd_touch, UPD_Vol ); 596 writeConfigEntry ( "TouchSound", m_snd_touch, UPD_Vol );
598} 597}
599 598
600void VolumeControl::keyClickToggled ( bool b ) 599void VolumeControl::keyClickToggled ( bool b )
601{ 600{
602 m_snd_key = b; 601 m_snd_key = b;
603 writeConfigEntry ( "KeySound", m_snd_key, UPD_Vol ); 602 writeConfigEntry ( "KeySound", m_snd_key, UPD_Vol );
604} 603}
605 604
606void VolumeControl::alarmSoundToggled ( bool b ) 605void VolumeControl::alarmSoundToggled ( bool b )
607{ 606{
608 m_snd_alarm = b; 607 m_snd_alarm = b;
609 writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); 608 writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol );
610} 609}
611 610
612void VolumeControl::volMuteToggled ( bool b ) 611void VolumeControl::volMuteToggled ( bool b )
613{ 612{
614 m_vol_muted = !b; 613 m_vol_muted = !b;
615 614
616 m_icon-> redraw ( true ); 615 m_icon-> redraw ( true );
617 616
618 writeConfigEntry ( "Mute", m_vol_muted, UPD_Vol ); 617 writeConfigEntry ( "Mute", m_vol_muted, UPD_Vol );
619} 618}
620 619
621void VolumeControl::micMuteToggled ( bool b ) 620void VolumeControl::micMuteToggled ( bool b )
622{ 621{
623 m_mic_muted = !b; 622 m_mic_muted = !b;
624 writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); 623 writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic );
625} 624}
626 625
627 626
628void VolumeControl::volMoved ( int percent ) 627void VolumeControl::volMoved ( int percent )
629{ 628{
630 m_vol_percent = 100 - percent; 629 m_vol_percent = 100 - percent;
631 630
632 // clamp volume percent to be between 0 and 100 631 // clamp volume percent to be between 0 and 100
633 m_vol_percent = ( m_vol_percent < 0 ) ? 0 : (( m_vol_percent > 100 ) ? 100 : m_vol_percent ); 632 m_vol_percent = ( m_vol_percent < 0 ) ? 0 : (( m_vol_percent > 100 ) ? 100 : m_vol_percent );
634 // repaint just the little volume rectangle 633 // repaint just the little volume rectangle
635 m_icon-> redraw ( false ); 634 m_icon-> redraw ( false );
636 635
637 writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_Vol ); 636 writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_Vol );
638} 637}
639 638
640void VolumeControl::micMoved ( int percent ) 639void VolumeControl::micMoved ( int percent )
641{ 640{
642 m_mic_percent = 100 - percent; 641 m_mic_percent = 100 - percent;
643 642
644 // clamp volume percent to be between 0 and 100 643 // clamp volume percent to be between 0 and 100
645 m_mic_percent = ( m_mic_percent < 0 ) ? 0 : (( m_mic_percent > 100 ) ? 100 : m_mic_percent ); 644 m_mic_percent = ( m_mic_percent < 0 ) ? 0 : (( m_mic_percent > 100 ) ? 100 : m_mic_percent );
646 645
647 writeConfigEntry ( "Mic", m_mic_percent, UPD_Mic ); 646 writeConfigEntry ( "Mic", m_mic_percent, UPD_Mic );
648} 647}
649 648
650void VolumeControl::alarmMoved ( int percent ) 649void VolumeControl::alarmMoved ( int percent )
651{ 650{
652 m_alarm_percent = 100 - percent; 651 m_alarm_percent = 100 - percent;
653 652
654 // clamp volume percent to be between 0 and 100 653 // clamp volume percent to be between 0 and 100
655 m_alarm_percent = ( m_alarm_percent < 0 ) ? 0 : (( m_alarm_percent > 100 ) ? 100 : m_alarm_percent ); 654 m_alarm_percent = ( m_alarm_percent < 0 ) ? 0 : (( m_alarm_percent > 100 ) ? 100 : m_alarm_percent );
656 655
657 writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); 656 writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None );
658} 657}
659 658
660 659
661void VolumeControl::bassMoved ( int percent ) 660void VolumeControl::bassMoved ( int percent )
662{ 661{
663 m_bass_percent = 100 - percent; 662 m_bass_percent = 100 - percent;
664 663
665 // clamp bass percent to be between 0 and 100 664 // clamp bass percent to be between 0 and 100
666 m_bass_percent = ( m_bass_percent < 0 ) ? 0 : (( m_bass_percent > 100 ) ? 100 : m_bass_percent ); 665 m_bass_percent = ( m_bass_percent < 0 ) ? 0 : (( m_bass_percent > 100 ) ? 100 : m_bass_percent );
667 666
668 writeConfigEntry ( "BassPercent", m_bass_percent, UPD_Bass ); 667 writeConfigEntry ( "BassPercent", m_bass_percent, UPD_Bass );
669} 668}
670 669
671 670
672 671
673void VolumeControl::trebleMoved ( int percent ) 672void VolumeControl::trebleMoved ( int percent )
674{ 673{
675 m_treble_percent = 100 - percent; 674 m_treble_percent = 100 - percent;
676 675
677 // clamp treble percent to be between 0 and 100 676 // clamp treble percent to be between 0 and 100
678 m_treble_percent = ( m_treble_percent < 0 ) ? 0 : (( m_treble_percent > 100 ) ? 100 : m_treble_percent ); 677 m_treble_percent = ( m_treble_percent < 0 ) ? 0 : (( m_treble_percent > 100 ) ? 100 : m_treble_percent );
679 678
680 writeConfigEntry ( "TreblePercent", m_treble_percent, UPD_Treble ); 679 writeConfigEntry ( "TreblePercent", m_treble_percent, UPD_Treble );
681} 680}
682 681
683 682
684 683
685void VolumeControl::writeConfigEntry ( const char *entry, int val, eUpdate upd ) 684void VolumeControl::writeConfigEntry ( const char *entry, int val, eUpdate upd )
686{ 685{
687 Config cfg ( "qpe" ); 686 Config cfg ( "qpe" );
688 cfg. setGroup ( "Volume" ); 687 cfg. setGroup ( "Volume" );
689 cfg. writeEntry ( entry, val ); 688 cfg. writeEntry ( entry, val );
690// cfg. write ( ); 689// cfg. write ( );
691 690
692#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) 691#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
693 switch ( upd ) { 692 switch ( upd ) {
694 case UPD_Vol: { 693 case UPD_Vol: {
695 QCopEnvelope ( "QPE/System", "volumeChange(bool)" ) << m_vol_muted; 694 QCopEnvelope ( "QPE/System", "volumeChange(bool)" ) << m_vol_muted;
696 break; 695 break;
697 } 696 }
698 case UPD_Mic: { 697 case UPD_Mic: {
699 QCopEnvelope ( "QPE/System", "micChange(bool)" ) << m_mic_muted; 698 QCopEnvelope ( "QPE/System", "micChange(bool)" ) << m_mic_muted;
700 break; 699 break;
701 } 700 }
702 case UPD_Bass: { 701 case UPD_Bass: {
703 QCopEnvelope ( "QPE/System", "bassChange(bool)" ) << true; 702 QCopEnvelope ( "QPE/System", "bassChange(bool)" ) << true;
704 break; 703 break;
705 } 704 }
706 case UPD_Treble: { 705 case UPD_Treble: {
707 QCopEnvelope ( "QPE/System", "trebleChange(bool)" ) << true; 706 QCopEnvelope ( "QPE/System", "trebleChange(bool)" ) << true;
708 break; 707 break;
709 } 708 }
710 709
711 case UPD_None: 710 case UPD_None:
712 break; 711 break;
713 } 712 }
714#endif 713#endif
715} 714}
716 715
717//=========================================================================== 716//===========================================================================
718 717
719VolumeApplet::VolumeApplet( QWidget *parent, const char *name ) 718VolumeApplet::VolumeApplet( QWidget *parent, const char *name )
720 : QWidget( parent, name ) 719 : QWidget( parent, name )
721{ 720{
722 setFixedWidth ( AppLnk::smallIconSize() ); 721 setFixedWidth ( AppLnk::smallIconSize() );
723 setFixedHeight ( AppLnk::smallIconSize()+4 ); 722 setFixedHeight ( AppLnk::smallIconSize()+4 );
724 723
725 m_pixmap = new QPixmap ( Resource::loadPixmap ( "volume" )); 724 m_pixmap = new QPixmap ( Resource::loadPixmap ( "volume" ));
726 m_dialog = new VolumeControl ( this, true, this, "volumecontrol" ); 725 m_dialog = new VolumeControl ( this, true, this, "volumecontrol" );
727 726
728 connect ( qApp, SIGNAL( volumeChanged(bool)), m_dialog, SLOT( volumeChanged(bool))); 727 connect ( qApp, SIGNAL( volumeChanged(bool)), m_dialog, SLOT( volumeChanged(bool)));
729 connect ( qApp, SIGNAL( micChanged(bool)), m_dialog, SLOT ( micChanged(bool))); 728 connect ( qApp, SIGNAL( micChanged(bool)), m_dialog, SLOT ( micChanged(bool)));
730} 729}
731 730
732VolumeApplet::~VolumeApplet() 731VolumeApplet::~VolumeApplet()
733{ 732{
734 delete m_pixmap; 733 delete m_pixmap;
735} 734}
736 735
737int VolumeApplet::position() 736int VolumeApplet::position()
738{ 737{
739 return 6; 738 return 6;
740} 739}
741 740
742void VolumeApplet::mousePressEvent ( QMouseEvent * ) 741void VolumeApplet::mousePressEvent ( QMouseEvent * )
743{ 742{
744 if ( m_dialog-> isVisible ( )) 743 if ( m_dialog-> isVisible ( ))
745 m_dialog-> hide ( ); 744 m_dialog-> hide ( );
746 else 745 else
747 m_dialog-> show ( true ); 746 m_dialog-> show ( true );
748} 747}
749 748
750void VolumeApplet::redraw ( bool all ) 749void VolumeApplet::redraw ( bool all )
751{ 750{
752 if ( all ) 751 if ( all )
753 repaint ( true ); 752 repaint ( true );
754 else 753 else
755 repaint ( 2, height ( ) - 3, width ( ) - 4, 2, false ); 754 repaint ( 2, height ( ) - 3, width ( ) - 4, 2, false );
756} 755}
757 756
758 757
759void VolumeApplet::paintEvent ( QPaintEvent * ) 758void VolumeApplet::paintEvent ( QPaintEvent * )
760{ 759{
761 QPainter p ( this ); 760 QPainter p ( this );
762 761
763 p. drawPixmap ( (width()- m_pixmap->width())/2, QMAX( (height()-4-m_pixmap->height() )/2, 1), *m_pixmap ); 762 p. drawPixmap ( (width()- m_pixmap->width())/2, QMAX( (height()-4-m_pixmap->height() )/2, 1), *m_pixmap );
764 p. setPen ( darkGray ); 763 p. setPen ( darkGray );
765 p. drawRect ( 1, height() - 4, width() - 2, 4 ); 764 p. drawRect ( 1, height() - 4, width() - 2, 4 );
766 765
767 int pixelsWide = m_dialog-> volPercent ( ) * ( width() - 4 ) / 100; 766 int pixelsWide = m_dialog-> volPercent ( ) * ( width() - 4 ) / 100;
768 p. fillRect ( 2, height() - 3, pixelsWide, 2, red ); 767 p. fillRect ( 2, height() - 3, pixelsWide, 2, red );
769 p. fillRect ( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray ); 768 p. fillRect ( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray );
770 769
771 if ( m_dialog-> volMuted ( )) { 770 if ( m_dialog-> volMuted ( )) {
772 p. setPen ( red ); 771 p. setPen ( red );
773 p. drawLine ( 1, 2, width() - 2, height() - 5 ); 772 p. drawLine ( 1, 2, width() - 2, height() - 5 );
774 p. drawLine ( 1, 3, width() - 2, height() - 4 ); 773 p. drawLine ( 1, 3, width() - 2, height() - 4 );
775 p. drawLine ( width() - 2, 2, 1, height() - 5 ); 774 p. drawLine ( width() - 2, 2, 1, height() - 5 );
776 p. drawLine ( width() - 2, 3, 1, height() - 4 ); 775 p. drawLine ( width() - 2, 3, 1, height() - 4 );
777 } 776 }
778} 777}
779 778
780 779
781EXPORT_OPIE_APPLET_v1( VolumeApplet ) 780EXPORT_OPIE_APPLET_v1( VolumeApplet )