author | mickeyl <mickeyl> | 2003-05-10 16:58:33 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-05-10 16:58:33 (UTC) |
commit | 2a58ee1a76e1dcfa055293c5e3c24fad31678094 (patch) (unidiff) | |
tree | 8b9367ab523f0f5b3adbcd77a9debd80f7054e90 | |
parent | 7f8b43992dffa298d84a3a293fa0a198e51d6a1c (diff) | |
download | opie-2a58ee1a76e1dcfa055293c5e3c24fad31678094.zip opie-2a58ee1a76e1dcfa055293c5e3c24fad31678094.tar.gz opie-2a58ee1a76e1dcfa055293c5e3c24fad31678094.tar.bz2 |
workaround half-visible volume pixmap
Note: For after Opie 1.0 we need TaskBar::height()
-rw-r--r-- | core/applets/volumeapplet/volume.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/core/applets/volumeapplet/volume.cpp b/core/applets/volumeapplet/volume.cpp index 906bb77..b129be3 100644 --- a/core/applets/volumeapplet/volume.cpp +++ b/core/applets/volumeapplet/volume.cpp | |||
@@ -346,438 +346,438 @@ VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *pa | |||
346 | micSlider = new QSlider ( this ); | 346 | micSlider = new QSlider ( this ); |
347 | micSlider-> setRange ( 0, 100 ); | 347 | micSlider-> setRange ( 0, 100 ); |
348 | micSlider-> setTickmarks ( QSlider::Both ); | 348 | micSlider-> setTickmarks ( QSlider::Both ); |
349 | micSlider-> setTickInterval ( 20 ); | 349 | micSlider-> setTickInterval ( 20 ); |
350 | micSlider-> setFocusPolicy ( QWidget::NoFocus ); | 350 | micSlider-> setFocusPolicy ( QWidget::NoFocus ); |
351 | 351 | ||
352 | l = new QLabel ( this ); | 352 | l = new QLabel ( this ); |
353 | l-> setPixmap ( QPixmap ( mic_xpm )); | 353 | l-> setPixmap ( QPixmap ( mic_xpm )); |
354 | 354 | ||
355 | grid-> addWidget ( l, 0, 2, AlignCenter ); | 355 | grid-> addWidget ( l, 0, 2, AlignCenter ); |
356 | grid-> addWidget ( micSlider, 1, 2, AlignCenter ); | 356 | grid-> addWidget ( micSlider, 1, 2, AlignCenter ); |
357 | 357 | ||
358 | micLed = new OLedBox ( red, this ); | 358 | micLed = new OLedBox ( red, this ); |
359 | micLed-> setFocusPolicy ( QWidget::NoFocus ); | 359 | micLed-> setFocusPolicy ( QWidget::NoFocus ); |
360 | micLed-> setFixedSize ( 16, 16 ); | 360 | micLed-> setFixedSize ( 16, 16 ); |
361 | 361 | ||
362 | grid-> addWidget ( micLed, 2, 2, AlignCenter ); | 362 | grid-> addWidget ( micLed, 2, 2, AlignCenter ); |
363 | 363 | ||
364 | alarmSlider = new QSlider ( this ); | 364 | alarmSlider = new QSlider ( this ); |
365 | alarmSlider-> setRange ( 0, 100 ); | 365 | alarmSlider-> setRange ( 0, 100 ); |
366 | alarmSlider-> setTickmarks ( QSlider::Both ); | 366 | alarmSlider-> setTickmarks ( QSlider::Both ); |
367 | alarmSlider-> setTickInterval ( 20 ); | 367 | alarmSlider-> setTickInterval ( 20 ); |
368 | alarmSlider-> setFocusPolicy ( QWidget::NoFocus ); | 368 | alarmSlider-> setFocusPolicy ( QWidget::NoFocus ); |
369 | 369 | ||
370 | QLabel *alarmLabel = new QLabel ( this ); | 370 | QLabel *alarmLabel = new QLabel ( this ); |
371 | alarmLabel-> setPixmap ( QPixmap ( alarm_xpm )); | 371 | alarmLabel-> setPixmap ( QPixmap ( alarm_xpm )); |
372 | 372 | ||
373 | grid-> addWidget ( alarmLabel, 0, 3, AlignCenter ); | 373 | grid-> addWidget ( alarmLabel, 0, 3, AlignCenter ); |
374 | grid-> addWidget ( alarmSlider, 1, 3, AlignCenter ); | 374 | grid-> addWidget ( alarmSlider, 1, 3, AlignCenter ); |
375 | 375 | ||
376 | alarmLed = new OLedBox ( yellow, this ); | 376 | alarmLed = new OLedBox ( yellow, this ); |
377 | alarmLed-> setFocusPolicy ( QWidget::NoFocus ); | 377 | alarmLed-> setFocusPolicy ( QWidget::NoFocus ); |
378 | alarmLed-> setFixedSize ( 16, 16 ); | 378 | alarmLed-> setFixedSize ( 16, 16 ); |
379 | 379 | ||
380 | grid-> addWidget ( alarmLed, 2, 3, AlignCenter ); | 380 | grid-> addWidget ( alarmLed, 2, 3, AlignCenter ); |
381 | 381 | ||
382 | if ( !has_wav_alarm ) { | 382 | if ( !has_wav_alarm ) { |
383 | alarmSlider-> hide ( ); | 383 | alarmSlider-> hide ( ); |
384 | alarmLabel-> hide ( ); | 384 | alarmLabel-> hide ( ); |
385 | alarmLed-> hide ( ); | 385 | alarmLed-> hide ( ); |
386 | } | 386 | } |
387 | 387 | ||
388 | grid-> addWidget ( new QLabel ( tr( "Enable Sounds for:" ), this ), 0, 6, AlignVCenter | AlignLeft ); | 388 | grid-> addWidget ( new QLabel ( tr( "Enable Sounds for:" ), this ), 0, 6, AlignVCenter | AlignLeft ); |
389 | 389 | ||
390 | vbox = new QVBoxLayout ( ); | 390 | vbox = new QVBoxLayout ( ); |
391 | vbox-> setSpacing ( 4 ); | 391 | vbox-> setSpacing ( 4 ); |
392 | grid-> addMultiCellLayout ( vbox, 1, 2, 6, 6 ); | 392 | grid-> addMultiCellLayout ( vbox, 1, 2, 6, 6 ); |
393 | 393 | ||
394 | tapBox = new QCheckBox ( tr( "Screen Taps" ), this ); | 394 | tapBox = new QCheckBox ( tr( "Screen Taps" ), this ); |
395 | tapBox-> setFocusPolicy ( QWidget::NoFocus ); | 395 | tapBox-> setFocusPolicy ( QWidget::NoFocus ); |
396 | 396 | ||
397 | vbox-> addWidget ( tapBox, AlignVCenter | AlignLeft ); | 397 | vbox-> addWidget ( tapBox, AlignVCenter | AlignLeft ); |
398 | 398 | ||
399 | keyBox = new QCheckBox ( tr( "Key Clicks" ), this ); | 399 | keyBox = new QCheckBox ( tr( "Key Clicks" ), this ); |
400 | keyBox-> setFocusPolicy ( QWidget::NoFocus ); | 400 | keyBox-> setFocusPolicy ( QWidget::NoFocus ); |
401 | 401 | ||
402 | vbox-> addWidget ( keyBox, AlignVCenter | AlignLeft ); | 402 | vbox-> addWidget ( keyBox, AlignVCenter | AlignLeft ); |
403 | 403 | ||
404 | alarmBox = new QCheckBox ( tr( "Alarm Sound" ), this ); | 404 | alarmBox = new QCheckBox ( tr( "Alarm Sound" ), this ); |
405 | alarmBox-> setFocusPolicy ( QWidget::NoFocus ); | 405 | alarmBox-> setFocusPolicy ( QWidget::NoFocus ); |
406 | 406 | ||
407 | vbox-> addWidget ( alarmBox, AlignVCenter | AlignLeft ); | 407 | vbox-> addWidget ( alarmBox, AlignVCenter | AlignLeft ); |
408 | 408 | ||
409 | if ( has_wav_alarm ) { | 409 | if ( has_wav_alarm ) { |
410 | alarmBox-> hide ( ); | 410 | alarmBox-> hide ( ); |
411 | } | 411 | } |
412 | 412 | ||
413 | vbox-> addStretch ( 100 ); | 413 | vbox-> addStretch ( 100 ); |
414 | 414 | ||
415 | setFixedSize ( sizeHint ( )); | 415 | setFixedSize ( sizeHint ( )); |
416 | setFocusPolicy ( QWidget::NoFocus ); | 416 | setFocusPolicy ( QWidget::NoFocus ); |
417 | 417 | ||
418 | rateTimer = new QTimer( this ); | 418 | rateTimer = new QTimer( this ); |
419 | connect ( rateTimer, SIGNAL( timeout ( )), this, SLOT( rateTimerDone ( ))); | 419 | connect ( rateTimer, SIGNAL( timeout ( )), this, SLOT( rateTimerDone ( ))); |
420 | 420 | ||
421 | connect ( upButton, SIGNAL( pressed ( )), this, SLOT( buttonChanged ( ))); | 421 | connect ( upButton, SIGNAL( pressed ( )), this, SLOT( buttonChanged ( ))); |
422 | connect ( upButton, SIGNAL( released ( )), this, SLOT( buttonChanged ( ))); | 422 | connect ( upButton, SIGNAL( released ( )), this, SLOT( buttonChanged ( ))); |
423 | connect ( downButton, SIGNAL( pressed ( )), this, SLOT( buttonChanged ( ))); | 423 | connect ( downButton, SIGNAL( pressed ( )), this, SLOT( buttonChanged ( ))); |
424 | connect ( downButton, SIGNAL( released ( )), this, SLOT( buttonChanged ( ))); | 424 | connect ( downButton, SIGNAL( released ( )), this, SLOT( buttonChanged ( ))); |
425 | 425 | ||
426 | connect ( micSlider, SIGNAL( valueChanged ( int )), this, SLOT( micMoved( int ))); | 426 | connect ( micSlider, SIGNAL( valueChanged ( int )), this, SLOT( micMoved( int ))); |
427 | connect ( volSlider, SIGNAL( valueChanged ( int )), this, SLOT( volMoved( int ))); | 427 | connect ( volSlider, SIGNAL( valueChanged ( int )), this, SLOT( volMoved( int ))); |
428 | connect ( alarmSlider, SIGNAL( valueChanged ( int )), this, SLOT( alarmMoved( int ))); | 428 | connect ( alarmSlider, SIGNAL( valueChanged ( int )), this, SLOT( alarmMoved( int ))); |
429 | connect ( bassSlider, SIGNAL( valueChanged ( int )), this, SLOT( bassMoved( int ))); | 429 | connect ( bassSlider, SIGNAL( valueChanged ( int )), this, SLOT( bassMoved( int ))); |
430 | connect ( trebleSlider, SIGNAL( valueChanged ( int )), this, SLOT( trebleMoved( int ))); | 430 | connect ( trebleSlider, SIGNAL( valueChanged ( int )), this, SLOT( trebleMoved( int ))); |
431 | 431 | ||
432 | 432 | ||
433 | connect ( volLed, SIGNAL( toggled ( bool )), this, SLOT( volMuteToggled ( bool ))); | 433 | connect ( volLed, SIGNAL( toggled ( bool )), this, SLOT( volMuteToggled ( bool ))); |
434 | connect ( micLed, SIGNAL( toggled ( bool )), this, SLOT( micMuteToggled ( bool ))); | 434 | connect ( micLed, SIGNAL( toggled ( bool )), this, SLOT( micMuteToggled ( bool ))); |
435 | connect ( alarmLed, SIGNAL( toggled ( bool )), this, SLOT( alarmSoundToggled ( bool ))); | 435 | connect ( alarmLed, SIGNAL( toggled ( bool )), this, SLOT( alarmSoundToggled ( bool ))); |
436 | 436 | ||
437 | connect ( alarmBox, SIGNAL( toggled ( bool )), this, SLOT( alarmSoundToggled ( bool ))); | 437 | connect ( alarmBox, SIGNAL( toggled ( bool )), this, SLOT( alarmSoundToggled ( bool ))); |
438 | connect ( keyBox, SIGNAL( toggled ( bool )), this, SLOT( keyClickToggled ( bool ))); | 438 | connect ( keyBox, SIGNAL( toggled ( bool )), this, SLOT( keyClickToggled ( bool ))); |
439 | connect ( tapBox, SIGNAL( toggled ( bool )), this, SLOT( screenTapToggled ( bool ))); | 439 | connect ( tapBox, SIGNAL( toggled ( bool )), this, SLOT( screenTapToggled ( bool ))); |
440 | 440 | ||
441 | // initialize variables | 441 | // initialize variables |
442 | 442 | ||
443 | readConfig ( true ); | 443 | readConfig ( true ); |
444 | 444 | ||
445 | // initialize the config file, in case some entries are missing | 445 | // initialize the config file, in case some entries are missing |
446 | 446 | ||
447 | writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_None ); | 447 | writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_None ); |
448 | writeConfigEntry ( "BassPercent", m_vol_percent, UPD_None ); | 448 | writeConfigEntry ( "BassPercent", m_vol_percent, UPD_None ); |
449 | writeConfigEntry ( "TreblePercent", m_vol_percent, UPD_None ); | 449 | writeConfigEntry ( "TreblePercent", m_vol_percent, UPD_None ); |
450 | writeConfigEntry ( "Mute", m_vol_muted, UPD_None ); | 450 | writeConfigEntry ( "Mute", m_vol_muted, UPD_None ); |
451 | writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); | 451 | writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); |
452 | writeConfigEntry ( "TouchSound", m_snd_touch, UPD_None ); | 452 | writeConfigEntry ( "TouchSound", m_snd_touch, UPD_None ); |
453 | writeConfigEntry ( "KeySound", m_snd_key, UPD_None ); | 453 | writeConfigEntry ( "KeySound", m_snd_key, UPD_None ); |
454 | writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); | 454 | writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); |
455 | 455 | ||
456 | writeConfigEntry ( "Mic", m_mic_percent, UPD_None ); | 456 | writeConfigEntry ( "Mic", m_mic_percent, UPD_None ); |
457 | writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); | 457 | writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); |
458 | } | 458 | } |
459 | 459 | ||
460 | bool VolumeControl::volMuted ( ) const | 460 | bool VolumeControl::volMuted ( ) const |
461 | { | 461 | { |
462 | return m_vol_muted; | 462 | return m_vol_muted; |
463 | } | 463 | } |
464 | 464 | ||
465 | int VolumeControl::volPercent ( ) const | 465 | int VolumeControl::volPercent ( ) const |
466 | { | 466 | { |
467 | return m_vol_percent; | 467 | return m_vol_percent; |
468 | } | 468 | } |
469 | 469 | ||
470 | void VolumeControl::keyPressEvent ( QKeyEvent *e ) | 470 | void VolumeControl::keyPressEvent ( QKeyEvent *e ) |
471 | { | 471 | { |
472 | switch ( e-> key ( )) { | 472 | switch ( e-> key ( )) { |
473 | case Key_Up: | 473 | case Key_Up: |
474 | volSlider-> subtractStep ( ); | 474 | volSlider-> subtractStep ( ); |
475 | break; | 475 | break; |
476 | case Key_Down: | 476 | case Key_Down: |
477 | volSlider-> addStep ( ); | 477 | volSlider-> addStep ( ); |
478 | break; | 478 | break; |
479 | case Key_Space: | 479 | case Key_Space: |
480 | volLed-> toggle ( ); | 480 | volLed-> toggle ( ); |
481 | break; | 481 | break; |
482 | case Key_Escape: | 482 | case Key_Escape: |
483 | hide ( ); | 483 | hide ( ); |
484 | break; | 484 | break; |
485 | } | 485 | } |
486 | } | 486 | } |
487 | 487 | ||
488 | void VolumeControl::buttonChanged ( ) | 488 | void VolumeControl::buttonChanged ( ) |
489 | { | 489 | { |
490 | if ( upButton-> isDown ( ) || downButton->isDown ( )) { | 490 | if ( upButton-> isDown ( ) || downButton->isDown ( )) { |
491 | rateTimerDone ( ); // Call it one time manually, otherwise it wont get | 491 | rateTimerDone ( ); // Call it one time manually, otherwise it wont get |
492 | // called at all when a button is pressed for a time | 492 | // called at all when a button is pressed for a time |
493 | // shorter than RATE_TIMER_INTERVAL. | 493 | // shorter than RATE_TIMER_INTERVAL. |
494 | rateTimer-> start ( RATE_TIMER_INTERVAL, false ); | 494 | rateTimer-> start ( RATE_TIMER_INTERVAL, false ); |
495 | } | 495 | } |
496 | else | 496 | else |
497 | rateTimer-> stop ( ); | 497 | rateTimer-> stop ( ); |
498 | } | 498 | } |
499 | 499 | ||
500 | void VolumeControl::rateTimerDone ( ) | 500 | void VolumeControl::rateTimerDone ( ) |
501 | { | 501 | { |
502 | if ( upButton-> isDown ( )) | 502 | if ( upButton-> isDown ( )) |
503 | volSlider-> setValue ( volSlider-> value ( ) - 2 ); | 503 | volSlider-> setValue ( volSlider-> value ( ) - 2 ); |
504 | else // if ( downButton-> isDown ( )) | 504 | else // if ( downButton-> isDown ( )) |
505 | volSlider-> setValue ( volSlider-> value ( ) + 2 ); | 505 | volSlider-> setValue ( volSlider-> value ( ) + 2 ); |
506 | } | 506 | } |
507 | 507 | ||
508 | void VolumeControl::show ( bool /*showMic*/ ) | 508 | void VolumeControl::show ( bool /*showMic*/ ) |
509 | { | 509 | { |
510 | readConfig ( ); | 510 | readConfig ( ); |
511 | 511 | ||
512 | QPoint curPos = m_icon-> mapToGlobal ( QPoint ( 0, 0 )); | 512 | QPoint curPos = m_icon-> mapToGlobal ( QPoint ( 0, 0 )); |
513 | 513 | ||
514 | int w = sizeHint ( ). width ( ); | 514 | int w = sizeHint ( ). width ( ); |
515 | int x = curPos.x ( ) - ( w / 2 ); | 515 | int x = curPos.x ( ) - ( w / 2 ); |
516 | 516 | ||
517 | if (( x + w ) > QPEApplication::desktop ( )-> width ( )) | 517 | if (( x + w ) > QPEApplication::desktop ( )-> width ( )) |
518 | x = QPEApplication::desktop ( )-> width ( ) - w; | 518 | x = QPEApplication::desktop ( )-> width ( ) - w; |
519 | 519 | ||
520 | move ( x, curPos. y ( ) - sizeHint ( ). height ( )); | 520 | move ( x, curPos. y ( ) - sizeHint ( ). height ( )); |
521 | QFrame::show ( ); | 521 | QFrame::show ( ); |
522 | 522 | ||
523 | } | 523 | } |
524 | 524 | ||
525 | void VolumeControl::readConfig ( bool force ) | 525 | void VolumeControl::readConfig ( bool force ) |
526 | { | 526 | { |
527 | Config cfg ( "qpe" ); | 527 | Config cfg ( "qpe" ); |
528 | cfg. setGroup ( "Volume" ); | 528 | cfg. setGroup ( "Volume" ); |
529 | 529 | ||
530 | int old_vp = m_vol_percent; | 530 | int old_vp = m_vol_percent; |
531 | int old_mp = m_mic_percent; | 531 | int old_mp = m_mic_percent; |
532 | int old_bass = m_bass_percent; | 532 | int old_bass = m_bass_percent; |
533 | int old_treble = m_treble_percent; | 533 | int old_treble = m_treble_percent; |
534 | bool old_vm = m_vol_muted; | 534 | bool old_vm = m_vol_muted; |
535 | bool old_mm = m_mic_muted; | 535 | bool old_mm = m_mic_muted; |
536 | bool old_sk = m_snd_key; | 536 | bool old_sk = m_snd_key; |
537 | bool old_st = m_snd_touch; | 537 | bool old_st = m_snd_touch; |
538 | bool old_sa = m_snd_alarm; | 538 | bool old_sa = m_snd_alarm; |
539 | int old_ap = m_alarm_percent; | 539 | int old_ap = m_alarm_percent; |
540 | 540 | ||
541 | m_vol_percent = cfg. readNumEntry ( "VolumePercent", 50 ); | 541 | m_vol_percent = cfg. readNumEntry ( "VolumePercent", 50 ); |
542 | m_mic_percent = cfg. readNumEntry ( "Mic", 50 ); | 542 | m_mic_percent = cfg. readNumEntry ( "Mic", 50 ); |
543 | m_bass_percent = cfg. readNumEntry ( "BassPercent", 50 ); | 543 | m_bass_percent = cfg. readNumEntry ( "BassPercent", 50 ); |
544 | m_treble_percent = cfg. readNumEntry ( "TreblePercent", 50 ); | 544 | m_treble_percent = cfg. readNumEntry ( "TreblePercent", 50 ); |
545 | m_vol_muted = cfg. readBoolEntry ( "Mute", 0 ); | 545 | m_vol_muted = cfg. readBoolEntry ( "Mute", 0 ); |
546 | m_mic_muted = cfg. readBoolEntry ( "MicMute", 0 ); | 546 | m_mic_muted = cfg. readBoolEntry ( "MicMute", 0 ); |
547 | m_snd_key = cfg. readBoolEntry ( "KeySound", 0 ); | 547 | m_snd_key = cfg. readBoolEntry ( "KeySound", 0 ); |
548 | m_snd_touch = cfg. readBoolEntry ( "TouchSound", 0 ); | 548 | m_snd_touch = cfg. readBoolEntry ( "TouchSound", 0 ); |
549 | m_snd_alarm = cfg. readBoolEntry ( "AlarmSound", 1 ); | 549 | m_snd_alarm = cfg. readBoolEntry ( "AlarmSound", 1 ); |
550 | m_alarm_percent = cfg. readNumEntry ( "AlarmPercent", 65 ); | 550 | m_alarm_percent = cfg. readNumEntry ( "AlarmPercent", 65 ); |
551 | 551 | ||
552 | if ( force || ( m_vol_percent != old_vp )) | 552 | if ( force || ( m_vol_percent != old_vp )) |
553 | volSlider-> setValue ( 100 - m_vol_percent ); | 553 | volSlider-> setValue ( 100 - m_vol_percent ); |
554 | if ( force || ( m_mic_percent != old_mp )) | 554 | if ( force || ( m_mic_percent != old_mp )) |
555 | micSlider-> setValue ( 100 - m_mic_percent ); | 555 | micSlider-> setValue ( 100 - m_mic_percent ); |
556 | if ( force || ( m_alarm_percent != old_ap )) | 556 | if ( force || ( m_alarm_percent != old_ap )) |
557 | alarmSlider-> setValue ( 100 - m_alarm_percent ); | 557 | alarmSlider-> setValue ( 100 - m_alarm_percent ); |
558 | if ( force || ( m_bass_percent != old_bass )) | 558 | if ( force || ( m_bass_percent != old_bass )) |
559 | bassSlider-> setValue ( 100 - m_bass_percent ); | 559 | bassSlider-> setValue ( 100 - m_bass_percent ); |
560 | if ( force || ( m_treble_percent != old_treble )) | 560 | if ( force || ( m_treble_percent != old_treble )) |
561 | trebleSlider-> setValue ( 100 - m_treble_percent ); | 561 | trebleSlider-> setValue ( 100 - m_treble_percent ); |
562 | 562 | ||
563 | 563 | ||
564 | if ( force || ( m_vol_muted != old_vm )) | 564 | if ( force || ( m_vol_muted != old_vm )) |
565 | volLed-> setOn ( !m_vol_muted ); | 565 | volLed-> setOn ( !m_vol_muted ); |
566 | if ( force || ( m_mic_muted != old_mm )) | 566 | if ( force || ( m_mic_muted != old_mm )) |
567 | micLed-> setOn ( !m_mic_muted ); | 567 | micLed-> setOn ( !m_mic_muted ); |
568 | if ( force || ( m_snd_alarm != old_sa )) | 568 | if ( force || ( m_snd_alarm != old_sa )) |
569 | alarmLed-> setOn ( m_snd_alarm ); | 569 | alarmLed-> setOn ( m_snd_alarm ); |
570 | 570 | ||
571 | if ( force || ( m_snd_key != old_sk )) | 571 | if ( force || ( m_snd_key != old_sk )) |
572 | keyBox-> setChecked ( m_snd_key ); | 572 | keyBox-> setChecked ( m_snd_key ); |
573 | if ( force || ( m_snd_touch != old_st )) | 573 | if ( force || ( m_snd_touch != old_st )) |
574 | tapBox-> setChecked ( m_snd_touch ); | 574 | tapBox-> setChecked ( m_snd_touch ); |
575 | if ( force || ( m_snd_alarm != old_sa )) | 575 | if ( force || ( m_snd_alarm != old_sa )) |
576 | alarmBox-> setChecked ( m_snd_alarm ); | 576 | alarmBox-> setChecked ( m_snd_alarm ); |
577 | } | 577 | } |
578 | 578 | ||
579 | 579 | ||
580 | void VolumeControl::volumeChanged ( bool /*nowMuted*/ ) | 580 | void VolumeControl::volumeChanged ( bool /*nowMuted*/ ) |
581 | { | 581 | { |
582 | int prevVol = m_vol_percent; | 582 | int prevVol = m_vol_percent; |
583 | bool prevMute = m_vol_muted; | 583 | bool prevMute = m_vol_muted; |
584 | 584 | ||
585 | readConfig ( ); | 585 | readConfig ( ); |
586 | 586 | ||
587 | // Handle case where muting it toggled | 587 | // Handle case where muting it toggled |
588 | if ( m_vol_muted != prevMute ) | 588 | if ( m_vol_muted != prevMute ) |
589 | m_icon-> redraw ( true ); | 589 | m_icon-> redraw ( true ); |
590 | else if ( prevVol != m_vol_percent ) // Avoid over repainting | 590 | else if ( prevVol != m_vol_percent ) // Avoid over repainting |
591 | m_icon-> redraw ( false ); | 591 | m_icon-> redraw ( false ); |
592 | } | 592 | } |
593 | 593 | ||
594 | void VolumeControl::micChanged ( bool nowMuted ) | 594 | void VolumeControl::micChanged ( bool nowMuted ) |
595 | { | 595 | { |
596 | if ( !nowMuted ) | 596 | if ( !nowMuted ) |
597 | readConfig ( ); | 597 | readConfig ( ); |
598 | m_mic_muted = nowMuted; | 598 | m_mic_muted = nowMuted; |
599 | } | 599 | } |
600 | 600 | ||
601 | void VolumeControl::screenTapToggled ( bool b ) | 601 | void VolumeControl::screenTapToggled ( bool b ) |
602 | { | 602 | { |
603 | m_snd_touch = b; | 603 | m_snd_touch = b; |
604 | writeConfigEntry ( "TouchSound", m_snd_touch, UPD_Vol ); | 604 | writeConfigEntry ( "TouchSound", m_snd_touch, UPD_Vol ); |
605 | } | 605 | } |
606 | 606 | ||
607 | void VolumeControl::keyClickToggled ( bool b ) | 607 | void VolumeControl::keyClickToggled ( bool b ) |
608 | { | 608 | { |
609 | m_snd_key = b; | 609 | m_snd_key = b; |
610 | writeConfigEntry ( "KeySound", m_snd_key, UPD_Vol ); | 610 | writeConfigEntry ( "KeySound", m_snd_key, UPD_Vol ); |
611 | } | 611 | } |
612 | 612 | ||
613 | void VolumeControl::alarmSoundToggled ( bool b ) | 613 | void VolumeControl::alarmSoundToggled ( bool b ) |
614 | { | 614 | { |
615 | m_snd_alarm = b; | 615 | m_snd_alarm = b; |
616 | writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); | 616 | writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); |
617 | } | 617 | } |
618 | 618 | ||
619 | void VolumeControl::volMuteToggled ( bool b ) | 619 | void VolumeControl::volMuteToggled ( bool b ) |
620 | { | 620 | { |
621 | m_vol_muted = !b; | 621 | m_vol_muted = !b; |
622 | 622 | ||
623 | m_icon-> redraw ( true ); | 623 | m_icon-> redraw ( true ); |
624 | 624 | ||
625 | writeConfigEntry ( "Mute", m_vol_muted, UPD_Vol ); | 625 | writeConfigEntry ( "Mute", m_vol_muted, UPD_Vol ); |
626 | } | 626 | } |
627 | 627 | ||
628 | void VolumeControl::micMuteToggled ( bool b ) | 628 | void VolumeControl::micMuteToggled ( bool b ) |
629 | { | 629 | { |
630 | m_mic_muted = !b; | 630 | m_mic_muted = !b; |
631 | writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); | 631 | writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); |
632 | } | 632 | } |
633 | 633 | ||
634 | 634 | ||
635 | void VolumeControl::volMoved ( int percent ) | 635 | void VolumeControl::volMoved ( int percent ) |
636 | { | 636 | { |
637 | m_vol_percent = 100 - percent; | 637 | m_vol_percent = 100 - percent; |
638 | 638 | ||
639 | // clamp volume percent to be between 0 and 100 | 639 | // clamp volume percent to be between 0 and 100 |
640 | m_vol_percent = ( m_vol_percent < 0 ) ? 0 : (( m_vol_percent > 100 ) ? 100 : m_vol_percent ); | 640 | m_vol_percent = ( m_vol_percent < 0 ) ? 0 : (( m_vol_percent > 100 ) ? 100 : m_vol_percent ); |
641 | // repaint just the little volume rectangle | 641 | // repaint just the little volume rectangle |
642 | m_icon-> redraw ( false ); | 642 | m_icon-> redraw ( false ); |
643 | 643 | ||
644 | writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_Vol ); | 644 | writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_Vol ); |
645 | } | 645 | } |
646 | 646 | ||
647 | void VolumeControl::micMoved ( int percent ) | 647 | void VolumeControl::micMoved ( int percent ) |
648 | { | 648 | { |
649 | m_mic_percent = 100 - percent; | 649 | m_mic_percent = 100 - percent; |
650 | 650 | ||
651 | // clamp volume percent to be between 0 and 100 | 651 | // clamp volume percent to be between 0 and 100 |
652 | m_mic_percent = ( m_mic_percent < 0 ) ? 0 : (( m_mic_percent > 100 ) ? 100 : m_mic_percent ); | 652 | m_mic_percent = ( m_mic_percent < 0 ) ? 0 : (( m_mic_percent > 100 ) ? 100 : m_mic_percent ); |
653 | 653 | ||
654 | writeConfigEntry ( "Mic", m_mic_percent, UPD_Mic ); | 654 | writeConfigEntry ( "Mic", m_mic_percent, UPD_Mic ); |
655 | } | 655 | } |
656 | 656 | ||
657 | void VolumeControl::alarmMoved ( int percent ) | 657 | void VolumeControl::alarmMoved ( int percent ) |
658 | { | 658 | { |
659 | m_alarm_percent = 100 - percent; | 659 | m_alarm_percent = 100 - percent; |
660 | 660 | ||
661 | // clamp volume percent to be between 0 and 100 | 661 | // clamp volume percent to be between 0 and 100 |
662 | m_alarm_percent = ( m_alarm_percent < 0 ) ? 0 : (( m_alarm_percent > 100 ) ? 100 : m_alarm_percent ); | 662 | m_alarm_percent = ( m_alarm_percent < 0 ) ? 0 : (( m_alarm_percent > 100 ) ? 100 : m_alarm_percent ); |
663 | 663 | ||
664 | writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); | 664 | writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); |
665 | } | 665 | } |
666 | 666 | ||
667 | 667 | ||
668 | void VolumeControl::bassMoved ( int percent ) | 668 | void VolumeControl::bassMoved ( int percent ) |
669 | { | 669 | { |
670 | m_bass_percent = 100 - percent; | 670 | m_bass_percent = 100 - percent; |
671 | 671 | ||
672 | // clamp bass percent to be between 0 and 100 | 672 | // clamp bass percent to be between 0 and 100 |
673 | m_bass_percent = ( m_bass_percent < 0 ) ? 0 : (( m_bass_percent > 100 ) ? 100 : m_bass_percent ); | 673 | m_bass_percent = ( m_bass_percent < 0 ) ? 0 : (( m_bass_percent > 100 ) ? 100 : m_bass_percent ); |
674 | 674 | ||
675 | writeConfigEntry ( "BassPercent", m_bass_percent, UPD_Bass ); | 675 | writeConfigEntry ( "BassPercent", m_bass_percent, UPD_Bass ); |
676 | } | 676 | } |
677 | 677 | ||
678 | 678 | ||
679 | 679 | ||
680 | void VolumeControl::trebleMoved ( int percent ) | 680 | void VolumeControl::trebleMoved ( int percent ) |
681 | { | 681 | { |
682 | m_treble_percent = 100 - percent; | 682 | m_treble_percent = 100 - percent; |
683 | 683 | ||
684 | // clamp treble percent to be between 0 and 100 | 684 | // clamp treble percent to be between 0 and 100 |
685 | m_treble_percent = ( m_treble_percent < 0 ) ? 0 : (( m_treble_percent > 100 ) ? 100 : m_treble_percent ); | 685 | m_treble_percent = ( m_treble_percent < 0 ) ? 0 : (( m_treble_percent > 100 ) ? 100 : m_treble_percent ); |
686 | 686 | ||
687 | writeConfigEntry ( "TreblePercent", m_treble_percent, UPD_Treble ); | 687 | writeConfigEntry ( "TreblePercent", m_treble_percent, UPD_Treble ); |
688 | } | 688 | } |
689 | 689 | ||
690 | 690 | ||
691 | 691 | ||
692 | void VolumeControl::writeConfigEntry ( const char *entry, int val, eUpdate upd ) | 692 | void VolumeControl::writeConfigEntry ( const char *entry, int val, eUpdate upd ) |
693 | { | 693 | { |
694 | Config cfg ( "qpe" ); | 694 | Config cfg ( "qpe" ); |
695 | cfg. setGroup ( "Volume" ); | 695 | cfg. setGroup ( "Volume" ); |
696 | cfg. writeEntry ( entry, val ); | 696 | cfg. writeEntry ( entry, val ); |
697 | // cfg. write ( ); | 697 | // cfg. write ( ); |
698 | 698 | ||
699 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) | 699 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) |
700 | switch ( upd ) { | 700 | switch ( upd ) { |
701 | case UPD_Vol: { | 701 | case UPD_Vol: { |
702 | QCopEnvelope ( "QPE/System", "volumeChange(bool)" ) << m_vol_muted; | 702 | QCopEnvelope ( "QPE/System", "volumeChange(bool)" ) << m_vol_muted; |
703 | break; | 703 | break; |
704 | } | 704 | } |
705 | case UPD_Mic: { | 705 | case UPD_Mic: { |
706 | QCopEnvelope ( "QPE/System", "micChange(bool)" ) << m_mic_muted; | 706 | QCopEnvelope ( "QPE/System", "micChange(bool)" ) << m_mic_muted; |
707 | break; | 707 | break; |
708 | } | 708 | } |
709 | case UPD_Bass: { | 709 | case UPD_Bass: { |
710 | QCopEnvelope ( "QPE/System", "bassChange(bool)" ) << true; | 710 | QCopEnvelope ( "QPE/System", "bassChange(bool)" ) << true; |
711 | break; | 711 | break; |
712 | } | 712 | } |
713 | case UPD_Treble: { | 713 | case UPD_Treble: { |
714 | QCopEnvelope ( "QPE/System", "trebleChange(bool)" ) << true; | 714 | QCopEnvelope ( "QPE/System", "trebleChange(bool)" ) << true; |
715 | break; | 715 | break; |
716 | } | 716 | } |
717 | 717 | ||
718 | case UPD_None: | 718 | case UPD_None: |
719 | break; | 719 | break; |
720 | } | 720 | } |
721 | #endif | 721 | #endif |
722 | } | 722 | } |
723 | 723 | ||
724 | //=========================================================================== | 724 | //=========================================================================== |
725 | 725 | ||
726 | VolumeApplet::VolumeApplet( QWidget *parent, const char *name ) | 726 | VolumeApplet::VolumeApplet( QWidget *parent, const char *name ) |
727 | : QWidget( parent, name ) | 727 | : QWidget( parent, name ) |
728 | { | 728 | { |
729 | setFixedWidth ( AppLnk::smallIconSize() ); | 729 | setFixedWidth ( AppLnk::smallIconSize() ); |
730 | setFixedHeight ( AppLnk::smallIconSize() ); | 730 | setFixedHeight ( AppLnk::smallIconSize()+4 ); |
731 | 731 | ||
732 | m_pixmap = new QPixmap ( Resource::loadPixmap ( "volume" )); | 732 | m_pixmap = new QPixmap ( Resource::loadPixmap ( "volume" )); |
733 | m_dialog = new VolumeControl ( this, true, this, "volumecontrol" ); | 733 | m_dialog = new VolumeControl ( this, true, this, "volumecontrol" ); |
734 | 734 | ||
735 | connect ( qApp, SIGNAL( volumeChanged ( bool )), m_dialog, SLOT( volumeChanged( bool ))); | 735 | connect ( qApp, SIGNAL( volumeChanged ( bool )), m_dialog, SLOT( volumeChanged( bool ))); |
736 | connect ( qApp, SIGNAL( micChanged ( bool )), m_dialog, SLOT ( micChanged( bool ))); | 736 | connect ( qApp, SIGNAL( micChanged ( bool )), m_dialog, SLOT ( micChanged( bool ))); |
737 | } | 737 | } |
738 | 738 | ||
739 | VolumeApplet::~VolumeApplet() | 739 | VolumeApplet::~VolumeApplet() |
740 | { | 740 | { |
741 | delete m_pixmap; | 741 | delete m_pixmap; |
742 | } | 742 | } |
743 | 743 | ||
744 | 744 | ||
745 | void VolumeApplet::mousePressEvent ( QMouseEvent * ) | 745 | void VolumeApplet::mousePressEvent ( QMouseEvent * ) |
746 | { | 746 | { |
747 | if ( m_dialog-> isVisible ( )) | 747 | if ( m_dialog-> isVisible ( )) |
748 | m_dialog-> hide ( ); | 748 | m_dialog-> hide ( ); |
749 | else | 749 | else |
750 | m_dialog-> show ( true ); | 750 | m_dialog-> show ( true ); |
751 | } | 751 | } |
752 | 752 | ||
753 | void VolumeApplet::redraw ( bool all ) | 753 | void VolumeApplet::redraw ( bool all ) |
754 | { | 754 | { |
755 | if ( all ) | 755 | if ( all ) |
756 | repaint ( true ); | 756 | repaint ( true ); |
757 | else | 757 | else |
758 | repaint ( 2, height ( ) - 3, width ( ) - 4, 2, false ); | 758 | repaint ( 2, height ( ) - 3, width ( ) - 4, 2, false ); |
759 | } | 759 | } |
760 | 760 | ||
761 | 761 | ||
762 | void VolumeApplet::paintEvent ( QPaintEvent * ) | 762 | void VolumeApplet::paintEvent ( QPaintEvent * ) |
763 | { | 763 | { |
764 | QPainter p ( this ); | 764 | QPainter p ( this ); |
765 | 765 | ||
766 | p. drawPixmap ( 0, 1, *m_pixmap ); | 766 | p. drawPixmap ( 0, 1, *m_pixmap ); |
767 | p. setPen ( darkGray ); | 767 | p. setPen ( darkGray ); |
768 | p. drawRect ( 1, height() - 4, width() - 2, 4 ); | 768 | p. drawRect ( 1, height() - 4, width() - 2, 4 ); |
769 | 769 | ||
770 | int pixelsWide = m_dialog-> volPercent ( ) * ( width() - 4 ) / 100; | 770 | int pixelsWide = m_dialog-> volPercent ( ) * ( width() - 4 ) / 100; |
771 | p. fillRect ( 2, height() - 3, pixelsWide, 2, red ); | 771 | p. fillRect ( 2, height() - 3, pixelsWide, 2, red ); |
772 | p. fillRect ( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray ); | 772 | p. fillRect ( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray ); |
773 | 773 | ||
774 | if ( m_dialog-> volMuted ( )) { | 774 | if ( m_dialog-> volMuted ( )) { |
775 | p. setPen ( red ); | 775 | p. setPen ( red ); |
776 | p. drawLine ( 1, 2, width() - 2, height() - 5 ); | 776 | p. drawLine ( 1, 2, width() - 2, height() - 5 ); |
777 | p. drawLine ( 1, 3, width() - 2, height() - 4 ); | 777 | p. drawLine ( 1, 3, width() - 2, height() - 4 ); |
778 | p. drawLine ( width() - 2, 2, 1, height() - 5 ); | 778 | p. drawLine ( width() - 2, 2, 1, height() - 5 ); |
779 | p. drawLine ( width() - 2, 3, 1, height() - 4 ); | 779 | p. drawLine ( width() - 2, 3, 1, height() - 4 ); |
780 | } | 780 | } |
781 | } | 781 | } |
782 | 782 | ||
783 | 783 | ||