summaryrefslogtreecommitdiff
path: root/core/applets/volumeapplet/volume.cpp
Unidiff
Diffstat (limited to 'core/applets/volumeapplet/volume.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/volumeapplet/volume.cpp36
1 files changed, 18 insertions, 18 deletions
diff --git a/core/applets/volumeapplet/volume.cpp b/core/applets/volumeapplet/volume.cpp
index 8fd88f6..942cebb 100644
--- a/core/applets/volumeapplet/volume.cpp
+++ b/core/applets/volumeapplet/volume.cpp
@@ -363,117 +363,117 @@ VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *pa
363 alarmLabel-> setPixmap ( QPixmap ( alarm_xpm )); 363 alarmLabel-> setPixmap ( QPixmap ( alarm_xpm ));
364 364
365 grid-> addWidget ( alarmLabel, 0, 3, AlignCenter ); 365 grid-> addWidget ( alarmLabel, 0, 3, AlignCenter );
366 grid-> addWidget ( alarmSlider, 1, 3, AlignCenter ); 366 grid-> addWidget ( alarmSlider, 1, 3, AlignCenter );
367 367
368 alarmLed = new OLedBox ( yellow, this ); 368 alarmLed = new OLedBox ( yellow, this );
369 alarmLed-> setFocusPolicy ( QWidget::NoFocus ); 369 alarmLed-> setFocusPolicy ( QWidget::NoFocus );
370 alarmLed-> setFixedSize ( 16, 16 ); 370 alarmLed-> setFixedSize ( 16, 16 );
371 371
372 grid-> addWidget ( alarmLed, 2, 3, AlignCenter ); 372 grid-> addWidget ( alarmLed, 2, 3, AlignCenter );
373 373
374 if ( !has_wav_alarm ) { 374 if ( !has_wav_alarm ) {
375 alarmSlider-> hide ( ); 375 alarmSlider-> hide ( );
376 alarmLabel-> hide ( ); 376 alarmLabel-> hide ( );
377 alarmLed-> hide ( ); 377 alarmLed-> hide ( );
378 } 378 }
379 379
380 grid-> addWidget ( new QLabel ( tr( "Enable Sounds for:" ), this ), 0, 6, AlignVCenter | AlignLeft ); 380 grid-> addWidget ( new QLabel ( tr( "Enable Sounds for:" ), this ), 0, 6, AlignVCenter | AlignLeft );
381 381
382 vbox = new QVBoxLayout ( ); 382 vbox = new QVBoxLayout ( );
383 vbox-> setSpacing ( 4 ); 383 vbox-> setSpacing ( 4 );
384 grid-> addMultiCellLayout ( vbox, 1, 2, 6, 6 ); 384 grid-> addMultiCellLayout ( vbox, 1, 2, 6, 6 );
385 385
386 tapBox = new QCheckBox ( tr( "Screen Taps" ), this ); 386 tapBox = new QCheckBox ( tr( "Screen Taps" ), this );
387 tapBox-> setFocusPolicy ( QWidget::NoFocus ); 387 tapBox-> setFocusPolicy ( QWidget::NoFocus );
388 388
389 vbox-> addWidget ( tapBox, AlignVCenter | AlignLeft ); 389 vbox-> addWidget ( tapBox, AlignVCenter | AlignLeft );
390 390
391 keyBox = new QCheckBox ( tr( "Key Clicks" ), this ); 391 keyBox = new QCheckBox ( tr( "Key Clicks" ), this );
392 keyBox-> setFocusPolicy ( QWidget::NoFocus ); 392 keyBox-> setFocusPolicy ( QWidget::NoFocus );
393 393
394 vbox-> addWidget ( keyBox, AlignVCenter | AlignLeft ); 394 vbox-> addWidget ( keyBox, AlignVCenter | AlignLeft );
395 395
396 alarmBox = new QCheckBox ( tr( "Alarm Sound" ), this ); 396 alarmBox = new QCheckBox ( tr( "Alarm Sound" ), this );
397 alarmBox-> setFocusPolicy ( QWidget::NoFocus ); 397 alarmBox-> setFocusPolicy ( QWidget::NoFocus );
398 398
399 vbox-> addWidget ( alarmBox, AlignVCenter | AlignLeft ); 399 vbox-> addWidget ( alarmBox, AlignVCenter | AlignLeft );
400 400
401 if ( has_wav_alarm ) { 401 if ( has_wav_alarm ) {
402 alarmBox-> hide ( ); 402 alarmBox-> hide ( );
403 } 403 }
404 404
405 vbox-> addStretch ( 100 ); 405 vbox-> addStretch ( 100 );
406 406
407 setFixedSize ( sizeHint ( )); 407 setFixedSize ( sizeHint ( ));
408 setFocusPolicy ( QWidget::NoFocus ); 408 setFocusPolicy ( QWidget::NoFocus );
409 409
410 rateTimer = new QTimer( this ); 410 rateTimer = new QTimer( this );
411 connect ( rateTimer, SIGNAL( timeout ( )), this, SLOT( rateTimerDone ( ))); 411 connect ( rateTimer, SIGNAL( timeout()), this, SLOT( rateTimerDone()));
412 412
413 connect ( upButton, SIGNAL( pressed ( )), this, SLOT( buttonChanged ( ))); 413 connect ( upButton, SIGNAL( pressed()), this, SLOT( buttonChanged()));
414 connect ( upButton, SIGNAL( released ( )), this, SLOT( buttonChanged ( ))); 414 connect ( upButton, SIGNAL( released()), this, SLOT( buttonChanged()));
415 connect ( downButton, SIGNAL( pressed ( )), this, SLOT( buttonChanged ( ))); 415 connect ( downButton, SIGNAL( pressed()), this, SLOT( buttonChanged()));
416 connect ( downButton, SIGNAL( released ( )), this, SLOT( buttonChanged ( ))); 416 connect ( downButton, SIGNAL( released()), this, SLOT( buttonChanged()));
417 417
418 connect ( micSlider, SIGNAL( valueChanged ( int )), this, SLOT( micMoved( int ))); 418 connect ( micSlider, SIGNAL( valueChanged(int)), this, SLOT( micMoved(int)));
419 connect ( volSlider, SIGNAL( valueChanged ( int )), this, SLOT( volMoved( int ))); 419 connect ( volSlider, SIGNAL( valueChanged(int)), this, SLOT( volMoved(int)));
420 connect ( alarmSlider, SIGNAL( valueChanged ( int )), this, SLOT( alarmMoved( int ))); 420 connect ( alarmSlider, SIGNAL( valueChanged(int)), this, SLOT( alarmMoved(int)));
421 connect ( bassSlider, SIGNAL( valueChanged ( int )), this, SLOT( bassMoved( int ))); 421 connect ( bassSlider, SIGNAL( valueChanged(int)), this, SLOT( bassMoved(int)));
422 connect ( trebleSlider, SIGNAL( valueChanged ( int )), this, SLOT( trebleMoved( int ))); 422 connect ( trebleSlider, SIGNAL( valueChanged(int)), this, SLOT( trebleMoved(int)));
423 423
424 424
425 connect ( volLed, SIGNAL( toggled ( bool )), this, SLOT( volMuteToggled ( bool ))); 425 connect ( volLed, SIGNAL( toggled(bool)), this, SLOT( volMuteToggled(bool)));
426 connect ( micLed, SIGNAL( toggled ( bool )), this, SLOT( micMuteToggled ( bool ))); 426 connect ( micLed, SIGNAL( toggled(bool)), this, SLOT( micMuteToggled(bool)));
427 connect ( alarmLed, SIGNAL( toggled ( bool )), this, SLOT( alarmSoundToggled ( bool ))); 427 connect ( alarmLed, SIGNAL( toggled(bool)), this, SLOT( alarmSoundToggled(bool)));
428 428
429 connect ( alarmBox, SIGNAL( toggled ( bool )), this, SLOT( alarmSoundToggled ( bool ))); 429 connect ( alarmBox, SIGNAL( toggled(bool)), this, SLOT( alarmSoundToggled(bool)));
430 connect ( keyBox, SIGNAL( toggled ( bool )), this, SLOT( keyClickToggled ( bool ))); 430 connect ( keyBox, SIGNAL( toggled(bool)), this, SLOT( keyClickToggled(bool)));
431 connect ( tapBox, SIGNAL( toggled ( bool )), this, SLOT( screenTapToggled ( bool ))); 431 connect ( tapBox, SIGNAL( toggled(bool)), this, SLOT( screenTapToggled(bool)));
432 432
433 // initialize variables 433 // initialize variables
434 434
435 readConfig ( true ); 435 readConfig ( true );
436 436
437 // initialize the config file, in case some entries are missing 437 // initialize the config file, in case some entries are missing
438 438
439 writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_None ); 439 writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_None );
440 writeConfigEntry ( "BassPercent", m_vol_percent, UPD_None ); 440 writeConfigEntry ( "BassPercent", m_vol_percent, UPD_None );
441 writeConfigEntry ( "TreblePercent", m_vol_percent, UPD_None ); 441 writeConfigEntry ( "TreblePercent", m_vol_percent, UPD_None );
442 writeConfigEntry ( "Mute", m_vol_muted, UPD_None ); 442 writeConfigEntry ( "Mute", m_vol_muted, UPD_None );
443 writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); 443 writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None );
444 writeConfigEntry ( "TouchSound", m_snd_touch, UPD_None ); 444 writeConfigEntry ( "TouchSound", m_snd_touch, UPD_None );
445 writeConfigEntry ( "KeySound", m_snd_key, UPD_None ); 445 writeConfigEntry ( "KeySound", m_snd_key, UPD_None );
446 writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); 446 writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol );
447 447
448 writeConfigEntry ( "Mic", m_mic_percent, UPD_None ); 448 writeConfigEntry ( "Mic", m_mic_percent, UPD_None );
449 writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); 449 writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic );
450} 450}
451 451
452bool VolumeControl::volMuted ( ) const 452bool VolumeControl::volMuted ( ) const
453{ 453{
454 return m_vol_muted; 454 return m_vol_muted;
455} 455}
456 456
457int VolumeControl::volPercent ( ) const 457int VolumeControl::volPercent ( ) const
458{ 458{
459 return m_vol_percent; 459 return m_vol_percent;
460} 460}
461 461
462void VolumeControl::keyPressEvent ( QKeyEvent *e ) 462void VolumeControl::keyPressEvent ( QKeyEvent *e )
463{ 463{
464 switch ( e-> key ( )) { 464 switch ( e-> key ( )) {
465 case Key_Up: 465 case Key_Up:
466 volSlider-> subtractStep ( ); 466 volSlider-> subtractStep ( );
467 break; 467 break;
468 case Key_Down: 468 case Key_Down:
469 volSlider-> addStep ( ); 469 volSlider-> addStep ( );
470 break; 470 break;
471 case Key_Space: 471 case Key_Space:
472 volLed-> toggle ( ); 472 volLed-> toggle ( );
473 break; 473 break;
474 case Key_Escape: 474 case Key_Escape:
475 hide ( ); 475 hide ( );
476 break; 476 break;
477 } 477 }
478} 478}
479 479
@@ -679,98 +679,98 @@ void VolumeControl::trebleMoved ( int percent )
679 writeConfigEntry ( "TreblePercent", m_treble_percent, UPD_Treble ); 679 writeConfigEntry ( "TreblePercent", m_treble_percent, UPD_Treble );
680} 680}
681 681
682 682
683 683
684void VolumeControl::writeConfigEntry ( const char *entry, int val, eUpdate upd ) 684void VolumeControl::writeConfigEntry ( const char *entry, int val, eUpdate upd )
685{ 685{
686 Config cfg ( "qpe" ); 686 Config cfg ( "qpe" );
687 cfg. setGroup ( "Volume" ); 687 cfg. setGroup ( "Volume" );
688 cfg. writeEntry ( entry, val ); 688 cfg. writeEntry ( entry, val );
689// cfg. write ( ); 689// cfg. write ( );
690 690
691#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) 691#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
692 switch ( upd ) { 692 switch ( upd ) {
693 case UPD_Vol: { 693 case UPD_Vol: {
694 QCopEnvelope ( "QPE/System", "volumeChange(bool)" ) << m_vol_muted; 694 QCopEnvelope ( "QPE/System", "volumeChange(bool)" ) << m_vol_muted;
695 break; 695 break;
696 } 696 }
697 case UPD_Mic: { 697 case UPD_Mic: {
698 QCopEnvelope ( "QPE/System", "micChange(bool)" ) << m_mic_muted; 698 QCopEnvelope ( "QPE/System", "micChange(bool)" ) << m_mic_muted;
699 break; 699 break;
700 } 700 }
701 case UPD_Bass: { 701 case UPD_Bass: {
702 QCopEnvelope ( "QPE/System", "bassChange(bool)" ) << true; 702 QCopEnvelope ( "QPE/System", "bassChange(bool)" ) << true;
703 break; 703 break;
704 } 704 }
705 case UPD_Treble: { 705 case UPD_Treble: {
706 QCopEnvelope ( "QPE/System", "trebleChange(bool)" ) << true; 706 QCopEnvelope ( "QPE/System", "trebleChange(bool)" ) << true;
707 break; 707 break;
708 } 708 }
709 709
710 case UPD_None: 710 case UPD_None:
711 break; 711 break;
712 } 712 }
713#endif 713#endif
714} 714}
715 715
716//=========================================================================== 716//===========================================================================
717 717
718VolumeApplet::VolumeApplet( QWidget *parent, const char *name ) 718VolumeApplet::VolumeApplet( QWidget *parent, const char *name )
719 : QWidget( parent, name ) 719 : QWidget( parent, name )
720{ 720{
721 setFixedWidth ( AppLnk::smallIconSize() ); 721 setFixedWidth ( AppLnk::smallIconSize() );
722 setFixedHeight ( AppLnk::smallIconSize()+4 ); 722 setFixedHeight ( AppLnk::smallIconSize()+4 );
723 723
724 m_pixmap = new QPixmap ( Resource::loadPixmap ( "volume" )); 724 m_pixmap = new QPixmap ( Resource::loadPixmap ( "volume" ));
725 m_dialog = new VolumeControl ( this, true, this, "volumecontrol" ); 725 m_dialog = new VolumeControl ( this, true, this, "volumecontrol" );
726 726
727 connect ( qApp, SIGNAL( volumeChanged ( bool )), m_dialog, SLOT( volumeChanged( bool ))); 727 connect ( qApp, SIGNAL( volumeChanged(bool)), m_dialog, SLOT( volumeChanged(bool)));
728 connect ( qApp, SIGNAL( micChanged ( bool )), m_dialog, SLOT ( micChanged( bool ))); 728 connect ( qApp, SIGNAL( micChanged(bool)), m_dialog, SLOT ( micChanged(bool)));
729} 729}
730 730
731VolumeApplet::~VolumeApplet() 731VolumeApplet::~VolumeApplet()
732{ 732{
733 delete m_pixmap; 733 delete m_pixmap;
734} 734}
735 735
736int VolumeApplet::position() 736int VolumeApplet::position()
737{ 737{
738 return 6; 738 return 6;
739} 739}
740 740
741void VolumeApplet::mousePressEvent ( QMouseEvent * ) 741void VolumeApplet::mousePressEvent ( QMouseEvent * )
742{ 742{
743 if ( m_dialog-> isVisible ( )) 743 if ( m_dialog-> isVisible ( ))
744 m_dialog-> hide ( ); 744 m_dialog-> hide ( );
745 else 745 else
746 m_dialog-> show ( true ); 746 m_dialog-> show ( true );
747} 747}
748 748
749void VolumeApplet::redraw ( bool all ) 749void VolumeApplet::redraw ( bool all )
750{ 750{
751 if ( all ) 751 if ( all )
752 repaint ( true ); 752 repaint ( true );
753 else 753 else
754 repaint ( 2, height ( ) - 3, width ( ) - 4, 2, false ); 754 repaint ( 2, height ( ) - 3, width ( ) - 4, 2, false );
755} 755}
756 756
757 757
758void VolumeApplet::paintEvent ( QPaintEvent * ) 758void VolumeApplet::paintEvent ( QPaintEvent * )
759{ 759{
760 QPainter p ( this ); 760 QPainter p ( this );
761 761
762 p. drawPixmap ( (width()- m_pixmap->width())/2, QMAX( (height()-4-m_pixmap->height() )/2, 1), *m_pixmap ); 762 p. drawPixmap ( (width()- m_pixmap->width())/2, QMAX( (height()-4-m_pixmap->height() )/2, 1), *m_pixmap );
763 p. setPen ( darkGray ); 763 p. setPen ( darkGray );
764 p. drawRect ( 1, height() - 4, width() - 2, 4 ); 764 p. drawRect ( 1, height() - 4, width() - 2, 4 );
765 765
766 int pixelsWide = m_dialog-> volPercent ( ) * ( width() - 4 ) / 100; 766 int pixelsWide = m_dialog-> volPercent ( ) * ( width() - 4 ) / 100;
767 p. fillRect ( 2, height() - 3, pixelsWide, 2, red ); 767 p. fillRect ( 2, height() - 3, pixelsWide, 2, red );
768 p. fillRect ( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray ); 768 p. fillRect ( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray );
769 769
770 if ( m_dialog-> volMuted ( )) { 770 if ( m_dialog-> volMuted ( )) {
771 p. setPen ( red ); 771 p. setPen ( red );
772 p. drawLine ( 1, 2, width() - 2, height() - 5 ); 772 p. drawLine ( 1, 2, width() - 2, height() - 5 );
773 p. drawLine ( 1, 3, width() - 2, height() - 4 ); 773 p. drawLine ( 1, 3, width() - 2, height() - 4 );
774 p. drawLine ( width() - 2, 2, 1, height() - 5 ); 774 p. drawLine ( width() - 2, 2, 1, height() - 5 );
775 p. drawLine ( width() - 2, 3, 1, height() - 4 ); 775 p. drawLine ( width() - 2, 3, 1, height() - 4 );
776 } 776 }