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