summaryrefslogtreecommitdiff
authorsandman <sandman>2002-10-31 02:06:44 (UTC)
committer sandman <sandman>2002-10-31 02:06:44 (UTC)
commitddd5f680b3dbd5e169d43f5216fbf24b04e4cb33 (patch) (unidiff)
tree4c2f1dbf746db2d9d38223f3a63f39eb3efd2c33
parent5a08fd92ac139820e1a1202d0b4b67190f24ccdb (diff)
downloadopie-ddd5f680b3dbd5e169d43f5216fbf24b04e4cb33.zip
opie-ddd5f680b3dbd5e169d43f5216fbf24b04e4cb33.tar.gz
opie-ddd5f680b3dbd5e169d43f5216fbf24b04e4cb33.tar.bz2
I have finally found the "launcher-settings sometimes crashes Opie bug"
it's the volume applet popup, that has no parent widget (that should really be no problem, but it works perfectly if you give it a parent)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/volumeapplet/volume.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/core/applets/volumeapplet/volume.cpp b/core/applets/volumeapplet/volume.cpp
index aec346b..06eec58 100644
--- a/core/applets/volumeapplet/volume.cpp
+++ b/core/applets/volumeapplet/volume.cpp
@@ -200,435 +200,435 @@ VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *pa
200 200
201 QGridLayout *grid = new QGridLayout ( this, 1, 1, 6, 4 ); 201 QGridLayout *grid = new QGridLayout ( this, 1, 1, 6, 4 );
202 grid-> setSpacing ( 4 ); 202 grid-> setSpacing ( 4 );
203 grid-> setMargin ( 6 ); 203 grid-> setMargin ( 6 );
204 204
205 QVBoxLayout *vbox; 205 QVBoxLayout *vbox;
206 QLabel *l; 206 QLabel *l;
207 207
208 vbox = new QVBoxLayout ( ); 208 vbox = new QVBoxLayout ( );
209 vbox-> setSpacing ( 4 ); 209 vbox-> setSpacing ( 4 );
210 grid-> addLayout ( vbox, 1, 0 ); 210 grid-> addLayout ( vbox, 1, 0 );
211 211
212 upButton = new QPushButton ( this ); 212 upButton = new QPushButton ( this );
213 upButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); 213 upButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding ));
214 upButton-> setPixmap ( Resource::loadPixmap ( "up" )); 214 upButton-> setPixmap ( Resource::loadPixmap ( "up" ));
215 upButton-> setFocusPolicy ( QWidget::NoFocus ); 215 upButton-> setFocusPolicy ( QWidget::NoFocus );
216 216
217 vbox-> addWidget ( upButton ); 217 vbox-> addWidget ( upButton );
218 218
219 downButton = new QPushButton ( this ); 219 downButton = new QPushButton ( this );
220 downButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); 220 downButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding ));
221 downButton-> setPixmap ( Resource::loadPixmap ( "down" )); 221 downButton-> setPixmap ( Resource::loadPixmap ( "down" ));
222 downButton-> setFocusPolicy ( QWidget::NoFocus ); 222 downButton-> setFocusPolicy ( QWidget::NoFocus );
223 223
224 vbox-> addWidget ( downButton ); 224 vbox-> addWidget ( downButton );
225 225
226 volSlider = new QSlider ( this ); 226 volSlider = new QSlider ( this );
227 volSlider-> setRange ( 0, 100 ); 227 volSlider-> setRange ( 0, 100 );
228 volSlider-> setTickmarks ( QSlider::Both ); 228 volSlider-> setTickmarks ( QSlider::Both );
229 volSlider-> setTickInterval ( 20 ); 229 volSlider-> setTickInterval ( 20 );
230 volSlider-> setFocusPolicy ( QWidget::NoFocus ); 230 volSlider-> setFocusPolicy ( QWidget::NoFocus );
231 231
232 l = new QLabel ( this ); 232 l = new QLabel ( this );
233 l-> setPixmap ( QPixmap ( vol_xpm )); 233 l-> setPixmap ( QPixmap ( vol_xpm ));
234 234
235 grid-> addWidget ( l, 0, 1, AlignCenter ); 235 grid-> addWidget ( l, 0, 1, AlignCenter );
236 grid-> addWidget ( volSlider, 1, 1, AlignCenter ); 236 grid-> addWidget ( volSlider, 1, 1, AlignCenter );
237 237
238 volLed = new OLedBox ( green, this ); 238 volLed = new OLedBox ( green, this );
239 volLed-> setFocusPolicy ( QWidget::NoFocus ); 239 volLed-> setFocusPolicy ( QWidget::NoFocus );
240 volLed-> setFixedSize ( 16, 16 ); 240 volLed-> setFixedSize ( 16, 16 );
241 241
242 grid-> addWidget ( volLed, 2, 1, AlignCenter ); 242 grid-> addWidget ( volLed, 2, 1, AlignCenter );
243 243
244 micSlider = new QSlider ( this ); 244 micSlider = new QSlider ( this );
245 micSlider-> setRange ( 0, 100 ); 245 micSlider-> setRange ( 0, 100 );
246 micSlider-> setTickmarks ( QSlider::Both ); 246 micSlider-> setTickmarks ( QSlider::Both );
247 micSlider-> setTickInterval ( 20 ); 247 micSlider-> setTickInterval ( 20 );
248 micSlider-> setFocusPolicy ( QWidget::NoFocus ); 248 micSlider-> setFocusPolicy ( QWidget::NoFocus );
249 249
250 l = new QLabel ( this ); 250 l = new QLabel ( this );
251 l-> setPixmap ( QPixmap ( mic_xpm )); 251 l-> setPixmap ( QPixmap ( mic_xpm ));
252 252
253 grid-> addWidget ( l, 0, 2, AlignCenter ); 253 grid-> addWidget ( l, 0, 2, AlignCenter );
254 grid-> addWidget ( micSlider, 1, 2, AlignCenter ); 254 grid-> addWidget ( micSlider, 1, 2, AlignCenter );
255 255
256 micLed = new OLedBox ( red, this ); 256 micLed = new OLedBox ( red, this );
257 micLed-> setFocusPolicy ( QWidget::NoFocus ); 257 micLed-> setFocusPolicy ( QWidget::NoFocus );
258 micLed-> setFixedSize ( 16, 16 ); 258 micLed-> setFixedSize ( 16, 16 );
259 259
260 grid-> addWidget ( micLed, 2, 2, AlignCenter ); 260 grid-> addWidget ( micLed, 2, 2, AlignCenter );
261 261
262 alarmSlider = new QSlider ( this ); 262 alarmSlider = new QSlider ( this );
263 alarmSlider-> setRange ( 0, 100 ); 263 alarmSlider-> setRange ( 0, 100 );
264 alarmSlider-> setTickmarks ( QSlider::Both ); 264 alarmSlider-> setTickmarks ( QSlider::Both );
265 alarmSlider-> setTickInterval ( 20 ); 265 alarmSlider-> setTickInterval ( 20 );
266 alarmSlider-> setFocusPolicy ( QWidget::NoFocus ); 266 alarmSlider-> setFocusPolicy ( QWidget::NoFocus );
267 267
268 QLabel *alarmLabel = new QLabel ( this ); 268 QLabel *alarmLabel = new QLabel ( this );
269 alarmLabel-> setPixmap ( QPixmap ( alarm_xpm )); 269 alarmLabel-> setPixmap ( QPixmap ( alarm_xpm ));
270 270
271 grid-> addWidget ( alarmLabel, 0, 3, AlignCenter ); 271 grid-> addWidget ( alarmLabel, 0, 3, AlignCenter );
272 grid-> addWidget ( alarmSlider, 1, 3, AlignCenter ); 272 grid-> addWidget ( alarmSlider, 1, 3, AlignCenter );
273 273
274 alarmLed = new OLedBox ( yellow, this ); 274 alarmLed = new OLedBox ( yellow, this );
275 alarmLed-> setFocusPolicy ( QWidget::NoFocus ); 275 alarmLed-> setFocusPolicy ( QWidget::NoFocus );
276 alarmLed-> setFixedSize ( 16, 16 ); 276 alarmLed-> setFixedSize ( 16, 16 );
277 277
278 grid-> addWidget ( alarmLed, 2, 3, AlignCenter ); 278 grid-> addWidget ( alarmLed, 2, 3, AlignCenter );
279 279
280 if ( !has_wav_alarm ) { 280 if ( !has_wav_alarm ) {
281 alarmSlider-> hide ( ); 281 alarmSlider-> hide ( );
282 alarmLabel-> hide ( ); 282 alarmLabel-> hide ( );
283 alarmLed-> hide ( ); 283 alarmLed-> hide ( );
284 } 284 }
285 285
286 grid-> addWidget ( new QLabel ( tr( "Enable Sounds for:" ), this ), 0, 4, AlignVCenter | AlignLeft ); 286 grid-> addWidget ( new QLabel ( tr( "Enable Sounds for:" ), this ), 0, 4, AlignVCenter | AlignLeft );
287 287
288 vbox = new QVBoxLayout ( ); 288 vbox = new QVBoxLayout ( );
289 vbox-> setSpacing ( 4 ); 289 vbox-> setSpacing ( 4 );
290 grid-> addMultiCellLayout ( vbox, 1, 2, 4, 4 ); 290 grid-> addMultiCellLayout ( vbox, 1, 2, 4, 4 );
291 291
292 tapBox = new QCheckBox ( tr( "Screen Taps" ), this ); 292 tapBox = new QCheckBox ( tr( "Screen Taps" ), this );
293 tapBox-> setFocusPolicy ( QWidget::NoFocus ); 293 tapBox-> setFocusPolicy ( QWidget::NoFocus );
294 294
295 vbox-> addWidget ( tapBox, AlignVCenter | AlignLeft ); 295 vbox-> addWidget ( tapBox, AlignVCenter | AlignLeft );
296 296
297 keyBox = new QCheckBox ( tr( "Key Clicks" ), this ); 297 keyBox = new QCheckBox ( tr( "Key Clicks" ), this );
298 keyBox-> setFocusPolicy ( QWidget::NoFocus ); 298 keyBox-> setFocusPolicy ( QWidget::NoFocus );
299 299
300 vbox-> addWidget ( keyBox, AlignVCenter | AlignLeft ); 300 vbox-> addWidget ( keyBox, AlignVCenter | AlignLeft );
301 301
302 alarmBox = new QCheckBox ( tr( "Alarm Sound" ), this ); 302 alarmBox = new QCheckBox ( tr( "Alarm Sound" ), this );
303 alarmBox-> setFocusPolicy ( QWidget::NoFocus ); 303 alarmBox-> setFocusPolicy ( QWidget::NoFocus );
304 304
305 vbox-> addWidget ( alarmBox, AlignVCenter | AlignLeft ); 305 vbox-> addWidget ( alarmBox, AlignVCenter | AlignLeft );
306 306
307 if ( has_wav_alarm ) { 307 if ( has_wav_alarm ) {
308 alarmBox-> hide ( ); 308 alarmBox-> hide ( );
309 } 309 }
310 310
311 vbox-> addStretch ( 100 ); 311 vbox-> addStretch ( 100 );
312 312
313 setFixedSize ( sizeHint ( )); 313 setFixedSize ( sizeHint ( ));
314 setFocusPolicy ( QWidget::NoFocus ); 314 setFocusPolicy ( QWidget::NoFocus );
315 315
316 rateTimer = new QTimer( this ); 316 rateTimer = new QTimer( this );
317 connect ( rateTimer, SIGNAL( timeout ( )), this, SLOT( rateTimerDone ( ))); 317 connect ( rateTimer, SIGNAL( timeout ( )), this, SLOT( rateTimerDone ( )));
318 318
319 connect ( upButton, SIGNAL( pressed ( )), this, SLOT( buttonChanged ( ))); 319 connect ( upButton, SIGNAL( pressed ( )), this, SLOT( buttonChanged ( )));
320 connect ( upButton, SIGNAL( released ( )), this, SLOT( buttonChanged ( ))); 320 connect ( upButton, SIGNAL( released ( )), this, SLOT( buttonChanged ( )));
321 connect ( downButton, SIGNAL( pressed ( )), this, SLOT( buttonChanged ( ))); 321 connect ( downButton, SIGNAL( pressed ( )), this, SLOT( buttonChanged ( )));
322 connect ( downButton, SIGNAL( released ( )), this, SLOT( buttonChanged ( ))); 322 connect ( downButton, SIGNAL( released ( )), this, SLOT( buttonChanged ( )));
323 323
324 connect ( micSlider, SIGNAL( valueChanged ( int )), this, SLOT( micMoved( int ))); 324 connect ( micSlider, SIGNAL( valueChanged ( int )), this, SLOT( micMoved( int )));
325 connect ( volSlider, SIGNAL( valueChanged ( int )), this, SLOT( volMoved( int ))); 325 connect ( volSlider, SIGNAL( valueChanged ( int )), this, SLOT( volMoved( int )));
326 connect ( alarmSlider, SIGNAL( valueChanged ( int )), this, SLOT( alarmMoved( int ))); 326 connect ( alarmSlider, SIGNAL( valueChanged ( int )), this, SLOT( alarmMoved( int )));
327 327
328 connect ( volLed, SIGNAL( toggled ( bool )), this, SLOT( volMuteToggled ( bool ))); 328 connect ( volLed, SIGNAL( toggled ( bool )), this, SLOT( volMuteToggled ( bool )));
329 connect ( micLed, SIGNAL( toggled ( bool )), this, SLOT( micMuteToggled ( bool ))); 329 connect ( micLed, SIGNAL( toggled ( bool )), this, SLOT( micMuteToggled ( bool )));
330 connect ( alarmLed, SIGNAL( toggled ( bool )), this, SLOT( alarmSoundToggled ( bool ))); 330 connect ( alarmLed, SIGNAL( toggled ( bool )), this, SLOT( alarmSoundToggled ( bool )));
331 331
332 connect ( alarmBox, SIGNAL( toggled ( bool )), this, SLOT( alarmSoundToggled ( bool ))); 332 connect ( alarmBox, SIGNAL( toggled ( bool )), this, SLOT( alarmSoundToggled ( bool )));
333 connect ( keyBox, SIGNAL( toggled ( bool )), this, SLOT( keyClickToggled ( bool ))); 333 connect ( keyBox, SIGNAL( toggled ( bool )), this, SLOT( keyClickToggled ( bool )));
334 connect ( tapBox, SIGNAL( toggled ( bool )), this, SLOT( screenTapToggled ( bool ))); 334 connect ( tapBox, SIGNAL( toggled ( bool )), this, SLOT( screenTapToggled ( bool )));
335 335
336 // initialize variables 336 // initialize variables
337 337
338 readConfig ( true ); 338 readConfig ( true );
339 339
340 // initialize the config file, in case some entries are missing 340 // initialize the config file, in case some entries are missing
341 341
342 writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_None ); 342 writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_None );
343 writeConfigEntry ( "Mute", m_vol_muted, UPD_None ); 343 writeConfigEntry ( "Mute", m_vol_muted, UPD_None );
344 writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); 344 writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None );
345 writeConfigEntry ( "TouchSound", m_snd_touch, UPD_None ); 345 writeConfigEntry ( "TouchSound", m_snd_touch, UPD_None );
346 writeConfigEntry ( "KeySound", m_snd_key, UPD_None ); 346 writeConfigEntry ( "KeySound", m_snd_key, UPD_None );
347 writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); 347 writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol );
348 348
349 writeConfigEntry ( "Mic", m_mic_percent, UPD_None ); 349 writeConfigEntry ( "Mic", m_mic_percent, UPD_None );
350 writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); 350 writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic );
351} 351}
352 352
353bool VolumeControl::volMuted ( ) const 353bool VolumeControl::volMuted ( ) const
354{ 354{
355 return m_vol_muted; 355 return m_vol_muted;
356} 356}
357 357
358int VolumeControl::volPercent ( ) const 358int VolumeControl::volPercent ( ) const
359{ 359{
360 return m_vol_percent; 360 return m_vol_percent;
361} 361}
362 362
363void VolumeControl::keyPressEvent ( QKeyEvent *e ) 363void VolumeControl::keyPressEvent ( QKeyEvent *e )
364{ 364{
365 switch ( e-> key ( )) { 365 switch ( e-> key ( )) {
366 case Key_Up: 366 case Key_Up:
367 volSlider-> subtractStep ( ); 367 volSlider-> subtractStep ( );
368 break; 368 break;
369 case Key_Down: 369 case Key_Down:
370 volSlider-> addStep ( ); 370 volSlider-> addStep ( );
371 break; 371 break;
372 case Key_Space: 372 case Key_Space:
373 volLed-> toggle ( ); 373 volLed-> toggle ( );
374 break; 374 break;
375 case Key_Escape: 375 case Key_Escape:
376 hide ( ); 376 hide ( );
377 break; 377 break;
378 } 378 }
379} 379}
380 380
381void VolumeControl::buttonChanged ( ) 381void VolumeControl::buttonChanged ( )
382{ 382{
383 if ( upButton-> isDown ( ) || downButton->isDown ( )) { 383 if ( upButton-> isDown ( ) || downButton->isDown ( )) {
384 rateTimerDone ( ); // Call it one time manually, otherwise it wont get 384 rateTimerDone ( ); // Call it one time manually, otherwise it wont get
385 // called at all when a button is pressed for a time 385 // called at all when a button is pressed for a time
386 // shorter than RATE_TIMER_INTERVAL. 386 // shorter than RATE_TIMER_INTERVAL.
387 rateTimer-> start ( RATE_TIMER_INTERVAL, false ); 387 rateTimer-> start ( RATE_TIMER_INTERVAL, false );
388 } 388 }
389 else 389 else
390 rateTimer-> stop ( ); 390 rateTimer-> stop ( );
391} 391}
392 392
393void VolumeControl::rateTimerDone ( ) 393void VolumeControl::rateTimerDone ( )
394{ 394{
395 if ( upButton-> isDown ( )) 395 if ( upButton-> isDown ( ))
396 volSlider-> setValue ( volSlider-> value ( ) - 2 ); 396 volSlider-> setValue ( volSlider-> value ( ) - 2 );
397 else // if ( downButton-> isDown ( )) 397 else // if ( downButton-> isDown ( ))
398 volSlider-> setValue ( volSlider-> value ( ) + 2 ); 398 volSlider-> setValue ( volSlider-> value ( ) + 2 );
399} 399}
400 400
401void VolumeControl::show ( bool /*showMic*/ ) 401void VolumeControl::show ( bool /*showMic*/ )
402{ 402{
403 readConfig ( ); 403 readConfig ( );
404 404
405 QPoint curPos = m_icon-> mapToGlobal ( QPoint ( 0, 0 )); 405 QPoint curPos = m_icon-> mapToGlobal ( QPoint ( 0, 0 ));
406 406
407 int w = sizeHint ( ). width ( ); 407 int w = sizeHint ( ). width ( );
408 int x = curPos.x ( ) - ( w / 2 ); 408 int x = curPos.x ( ) - ( w / 2 );
409 409
410 if (( x + w ) > QPEApplication::desktop ( )-> width ( )) 410 if (( x + w ) > QPEApplication::desktop ( )-> width ( ))
411 x = QPEApplication::desktop ( )-> width ( ) - w; 411 x = QPEApplication::desktop ( )-> width ( ) - w;
412 412
413 move ( x, curPos. y ( ) - sizeHint ( ). height ( )); 413 move ( x, curPos. y ( ) - sizeHint ( ). height ( ));
414 QFrame::show ( ); 414 QFrame::show ( );
415 415
416} 416}
417 417
418void VolumeControl::readConfig ( bool force ) 418void VolumeControl::readConfig ( bool force )
419{ 419{
420 Config cfg ( "qpe" ); 420 Config cfg ( "qpe" );
421 cfg. setGroup ( "Volume" ); 421 cfg. setGroup ( "Volume" );
422 422
423 int old_vp = m_vol_percent; 423 int old_vp = m_vol_percent;
424 int old_mp = m_mic_percent; 424 int old_mp = m_mic_percent;
425 bool old_vm = m_vol_muted; 425 bool old_vm = m_vol_muted;
426 bool old_mm = m_mic_muted; 426 bool old_mm = m_mic_muted;
427 bool old_sk = m_snd_key; 427 bool old_sk = m_snd_key;
428 bool old_st = m_snd_touch; 428 bool old_st = m_snd_touch;
429 bool old_sa = m_snd_alarm; 429 bool old_sa = m_snd_alarm;
430 int old_ap = m_alarm_percent; 430 int old_ap = m_alarm_percent;
431 431
432 m_vol_percent = cfg. readNumEntry ( "VolumePercent", 50 ); 432 m_vol_percent = cfg. readNumEntry ( "VolumePercent", 50 );
433 m_mic_percent = cfg. readNumEntry ( "Mic", 50 ); 433 m_mic_percent = cfg. readNumEntry ( "Mic", 50 );
434 m_vol_muted = cfg. readBoolEntry ( "Mute", 0 ); 434 m_vol_muted = cfg. readBoolEntry ( "Mute", 0 );
435 m_mic_muted = cfg. readBoolEntry ( "MicMute", 0 ); 435 m_mic_muted = cfg. readBoolEntry ( "MicMute", 0 );
436 m_snd_key = cfg. readBoolEntry ( "KeySound", 0 ); 436 m_snd_key = cfg. readBoolEntry ( "KeySound", 0 );
437 m_snd_touch = cfg. readBoolEntry ( "TouchSound", 0 ); 437 m_snd_touch = cfg. readBoolEntry ( "TouchSound", 0 );
438 m_snd_alarm = cfg. readBoolEntry ( "AlarmSound", 1 ); 438 m_snd_alarm = cfg. readBoolEntry ( "AlarmSound", 1 );
439 m_alarm_percent = cfg. readNumEntry ( "AlarmPercent", 65 ); 439 m_alarm_percent = cfg. readNumEntry ( "AlarmPercent", 65 );
440 440
441 if ( force || ( m_vol_percent != old_vp )) 441 if ( force || ( m_vol_percent != old_vp ))
442 volSlider-> setValue ( 100 - m_vol_percent ); 442 volSlider-> setValue ( 100 - m_vol_percent );
443 if ( force || ( m_mic_percent != old_mp )) 443 if ( force || ( m_mic_percent != old_mp ))
444 micSlider-> setValue ( 100 - m_mic_percent ); 444 micSlider-> setValue ( 100 - m_mic_percent );
445 if ( force || ( m_alarm_percent != old_ap )) 445 if ( force || ( m_alarm_percent != old_ap ))
446 alarmSlider-> setValue ( 100 - m_alarm_percent ); 446 alarmSlider-> setValue ( 100 - m_alarm_percent );
447 447
448 if ( force || ( m_vol_muted != old_vm )) 448 if ( force || ( m_vol_muted != old_vm ))
449 volLed-> setOn ( !m_vol_muted ); 449 volLed-> setOn ( !m_vol_muted );
450 if ( force || ( m_mic_muted != old_mm )) 450 if ( force || ( m_mic_muted != old_mm ))
451 micLed-> setOn ( !m_mic_muted ); 451 micLed-> setOn ( !m_mic_muted );
452 if ( force || ( m_snd_alarm != old_sa )) 452 if ( force || ( m_snd_alarm != old_sa ))
453 alarmLed-> setOn ( m_snd_alarm ); 453 alarmLed-> setOn ( m_snd_alarm );
454 454
455 if ( force || ( m_snd_key != old_sk )) 455 if ( force || ( m_snd_key != old_sk ))
456 keyBox-> setChecked ( m_snd_key ); 456 keyBox-> setChecked ( m_snd_key );
457 if ( force || ( m_snd_touch != old_st )) 457 if ( force || ( m_snd_touch != old_st ))
458 tapBox-> setChecked ( m_snd_touch ); 458 tapBox-> setChecked ( m_snd_touch );
459 if ( force || ( m_snd_alarm != old_sa )) 459 if ( force || ( m_snd_alarm != old_sa ))
460 alarmBox-> setChecked ( m_snd_alarm ); 460 alarmBox-> setChecked ( m_snd_alarm );
461} 461}
462 462
463 463
464void VolumeControl::volumeChanged ( bool /*nowMuted*/ ) 464void VolumeControl::volumeChanged ( bool /*nowMuted*/ )
465{ 465{
466 int prevVol = m_vol_percent; 466 int prevVol = m_vol_percent;
467 bool prevMute = m_vol_muted; 467 bool prevMute = m_vol_muted;
468 468
469 readConfig ( ); 469 readConfig ( );
470 470
471 // Handle case where muting it toggled 471 // Handle case where muting it toggled
472 if ( m_vol_muted != prevMute ) 472 if ( m_vol_muted != prevMute )
473 m_icon-> redraw ( true ); 473 m_icon-> redraw ( true );
474 else if ( prevVol != m_vol_percent ) // Avoid over repainting 474 else if ( prevVol != m_vol_percent ) // Avoid over repainting
475 m_icon-> redraw ( false ); 475 m_icon-> redraw ( false );
476} 476}
477 477
478void VolumeControl::micChanged ( bool nowMuted ) 478void VolumeControl::micChanged ( bool nowMuted )
479{ 479{
480 if ( !nowMuted ) 480 if ( !nowMuted )
481 readConfig ( ); 481 readConfig ( );
482 m_mic_muted = nowMuted; 482 m_mic_muted = nowMuted;
483} 483}
484 484
485void VolumeControl::screenTapToggled ( bool b ) 485void VolumeControl::screenTapToggled ( bool b )
486{ 486{
487 m_snd_touch = b; 487 m_snd_touch = b;
488 writeConfigEntry ( "TouchSound", m_snd_touch, UPD_Vol ); 488 writeConfigEntry ( "TouchSound", m_snd_touch, UPD_Vol );
489} 489}
490 490
491void VolumeControl::keyClickToggled ( bool b ) 491void VolumeControl::keyClickToggled ( bool b )
492{ 492{
493 m_snd_key = b; 493 m_snd_key = b;
494 writeConfigEntry ( "KeySound", m_snd_key, UPD_Vol ); 494 writeConfigEntry ( "KeySound", m_snd_key, UPD_Vol );
495} 495}
496 496
497void VolumeControl::alarmSoundToggled ( bool b ) 497void VolumeControl::alarmSoundToggled ( bool b )
498{ 498{
499 m_snd_alarm = b; 499 m_snd_alarm = b;
500 writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); 500 writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol );
501} 501}
502 502
503void VolumeControl::volMuteToggled ( bool b ) 503void VolumeControl::volMuteToggled ( bool b )
504{ 504{
505 m_vol_muted = !b; 505 m_vol_muted = !b;
506 506
507 m_icon-> redraw ( true ); 507 m_icon-> redraw ( true );
508 508
509 writeConfigEntry ( "Mute", m_vol_muted, UPD_Vol ); 509 writeConfigEntry ( "Mute", m_vol_muted, UPD_Vol );
510} 510}
511 511
512void VolumeControl::micMuteToggled ( bool b ) 512void VolumeControl::micMuteToggled ( bool b )
513{ 513{
514 m_mic_muted = !b; 514 m_mic_muted = !b;
515 writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); 515 writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic );
516} 516}
517 517
518 518
519void VolumeControl::volMoved ( int percent ) 519void VolumeControl::volMoved ( int percent )
520{ 520{
521 m_vol_percent = 100 - percent; 521 m_vol_percent = 100 - percent;
522 522
523 // clamp volume percent to be between 0 and 100 523 // 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 ); 524 m_vol_percent = ( m_vol_percent < 0 ) ? 0 : (( m_vol_percent > 100 ) ? 100 : m_vol_percent );
525 // repaint just the little volume rectangle 525 // repaint just the little volume rectangle
526 m_icon-> redraw ( false ); 526 m_icon-> redraw ( false );
527 527
528 writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_Vol ); 528 writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_Vol );
529} 529}
530 530
531void VolumeControl::micMoved ( int percent ) 531void VolumeControl::micMoved ( int percent )
532{ 532{
533 m_mic_percent = 100 - percent; 533 m_mic_percent = 100 - percent;
534 534
535 // clamp volume percent to be between 0 and 100 535 // 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 ); 536 m_mic_percent = ( m_mic_percent < 0 ) ? 0 : (( m_mic_percent > 100 ) ? 100 : m_mic_percent );
537 537
538 writeConfigEntry ( "Mic", m_mic_percent, UPD_Mic ); 538 writeConfigEntry ( "Mic", m_mic_percent, UPD_Mic );
539} 539}
540 540
541void VolumeControl::alarmMoved ( int percent ) 541void VolumeControl::alarmMoved ( int percent )
542{ 542{
543 m_alarm_percent = 100 - percent; 543 m_alarm_percent = 100 - percent;
544 544
545 // clamp volume percent to be between 0 and 100 545 // 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 ); 546 m_alarm_percent = ( m_alarm_percent < 0 ) ? 0 : (( m_alarm_percent > 100 ) ? 100 : m_alarm_percent );
547 547
548 writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); 548 writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None );
549} 549}
550 550
551 551
552void VolumeControl::writeConfigEntry ( const char *entry, int val, eUpdate upd ) 552void VolumeControl::writeConfigEntry ( const char *entry, int val, eUpdate upd )
553{ 553{
554 Config cfg ( "qpe" ); 554 Config cfg ( "qpe" );
555 cfg. setGroup ( "Volume" ); 555 cfg. setGroup ( "Volume" );
556 cfg. writeEntry ( entry, val ); 556 cfg. writeEntry ( entry, val );
557// cfg. write ( ); 557// cfg. write ( );
558 558
559#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) 559#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
560 switch ( upd ) { 560 switch ( upd ) {
561 case UPD_Vol: { 561 case UPD_Vol: {
562 QCopEnvelope ( "QPE/System", "volumeChange(bool)" ) << m_vol_muted; 562 QCopEnvelope ( "QPE/System", "volumeChange(bool)" ) << m_vol_muted;
563 break; 563 break;
564 } 564 }
565 case UPD_Mic: { 565 case UPD_Mic: {
566 QCopEnvelope ( "QPE/System", "micChange(bool)" ) << m_mic_muted; 566 QCopEnvelope ( "QPE/System", "micChange(bool)" ) << m_mic_muted;
567 break; 567 break;
568 } 568 }
569 case UPD_None: 569 case UPD_None:
570 break; 570 break;
571 } 571 }
572#endif 572#endif
573} 573}
574 574
575//=========================================================================== 575//===========================================================================
576 576
577VolumeApplet::VolumeApplet( QWidget *parent, const char *name ) 577VolumeApplet::VolumeApplet( QWidget *parent, const char *name )
578 : QWidget( parent, name ) 578 : QWidget( parent, name )
579{ 579{
580 setFixedHeight ( 18 ); 580 setFixedHeight ( 18 );
581 setFixedWidth ( 14 ); 581 setFixedWidth ( 14 );
582 582
583 m_pixmap = new QPixmap ( Resource::loadPixmap ( "volume" )); 583 m_pixmap = new QPixmap ( Resource::loadPixmap ( "volume" ));
584 m_dialog = new VolumeControl ( this ); 584 m_dialog = new VolumeControl ( this, true, this, "volumecontrol" );
585 585
586 connect ( qApp, SIGNAL( volumeChanged ( bool )), m_dialog, SLOT( volumeChanged( bool ))); 586 connect ( qApp, SIGNAL( volumeChanged ( bool )), m_dialog, SLOT( volumeChanged( bool )));
587 connect ( qApp, SIGNAL( micChanged ( bool )), m_dialog, SLOT ( micChanged( bool ))); 587 connect ( qApp, SIGNAL( micChanged ( bool )), m_dialog, SLOT ( micChanged( bool )));
588} 588}
589 589
590VolumeApplet::~VolumeApplet() 590VolumeApplet::~VolumeApplet()
591{ 591{
592 delete m_pixmap; 592 delete m_pixmap;
593} 593}
594 594
595 595
596void VolumeApplet::mousePressEvent ( QMouseEvent * ) 596void VolumeApplet::mousePressEvent ( QMouseEvent * )
597{ 597{
598 if ( m_dialog-> isVisible ( )) 598 if ( m_dialog-> isVisible ( ))
599 m_dialog-> hide ( ); 599 m_dialog-> hide ( );
600 else 600 else
601 m_dialog-> show ( true ); 601 m_dialog-> show ( true );
602} 602}
603 603
604void VolumeApplet::redraw ( bool all ) 604void VolumeApplet::redraw ( bool all )
605{ 605{
606 if ( all ) 606 if ( all )
607 repaint ( true ); 607 repaint ( true );
608 else 608 else
609 repaint ( 2, height ( ) - 3, width ( ) - 4, 2, false ); 609 repaint ( 2, height ( ) - 3, width ( ) - 4, 2, false );
610} 610}
611 611
612 612
613void VolumeApplet::paintEvent ( QPaintEvent * ) 613void VolumeApplet::paintEvent ( QPaintEvent * )
614{ 614{
615 QPainter p ( this ); 615 QPainter p ( this );
616 616
617 p. drawPixmap ( 0, 1, *m_pixmap ); 617 p. drawPixmap ( 0, 1, *m_pixmap );
618 p. setPen ( darkGray ); 618 p. setPen ( darkGray );
619 p. drawRect ( 1, height() - 4, width() - 2, 4 ); 619 p. drawRect ( 1, height() - 4, width() - 2, 4 );
620 620
621 int pixelsWide = m_dialog-> volPercent ( ) * ( width() - 4 ) / 100; 621 int pixelsWide = m_dialog-> volPercent ( ) * ( width() - 4 ) / 100;
622 p. fillRect ( 2, height() - 3, pixelsWide, 2, red ); 622 p. fillRect ( 2, height() - 3, pixelsWide, 2, red );
623 p. fillRect ( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray ); 623 p. fillRect ( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray );
624 624
625 if ( m_dialog-> volMuted ( )) { 625 if ( m_dialog-> volMuted ( )) {
626 p. setPen ( red ); 626 p. setPen ( red );
627 p. drawLine ( 1, 2, width() - 2, height() - 5 ); 627 p. drawLine ( 1, 2, width() - 2, height() - 5 );
628 p. drawLine ( 1, 3, width() - 2, height() - 4 ); 628 p. drawLine ( 1, 3, width() - 2, height() - 4 );
629 p. drawLine ( width() - 2, 2, 1, height() - 5 ); 629 p. drawLine ( width() - 2, 2, 1, height() - 5 );
630 p. drawLine ( width() - 2, 3, 1, height() - 4 ); 630 p. drawLine ( width() - 2, 3, 1, height() - 4 );
631 } 631 }
632} 632}
633 633
634 634