-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 aec346b..06eec58 100644 --- a/core/applets/volumeapplet/volume.cpp +++ b/core/applets/volumeapplet/volume.cpp @@ -392,243 +392,243 @@ void VolumeControl::buttonChanged ( ) void VolumeControl::rateTimerDone ( ) { if ( upButton-> isDown ( )) volSlider-> setValue ( volSlider-> value ( ) - 2 ); else // if ( downButton-> isDown ( )) volSlider-> setValue ( volSlider-> value ( ) + 2 ); } void VolumeControl::show ( bool /*showMic*/ ) { readConfig ( ); QPoint curPos = m_icon-> mapToGlobal ( QPoint ( 0, 0 )); int w = sizeHint ( ). width ( ); int x = curPos.x ( ) - ( w / 2 ); if (( x + w ) > QPEApplication::desktop ( )-> width ( )) x = QPEApplication::desktop ( )-> width ( ) - w; move ( x, curPos. y ( ) - sizeHint ( ). height ( )); QFrame::show ( ); } void VolumeControl::readConfig ( bool force ) { Config cfg ( "qpe" ); cfg. setGroup ( "Volume" ); int old_vp = m_vol_percent; int old_mp = m_mic_percent; bool old_vm = m_vol_muted; bool old_mm = m_mic_muted; bool old_sk = m_snd_key; bool old_st = m_snd_touch; bool old_sa = m_snd_alarm; int old_ap = m_alarm_percent; m_vol_percent = cfg. readNumEntry ( "VolumePercent", 50 ); m_mic_percent = cfg. readNumEntry ( "Mic", 50 ); m_vol_muted = cfg. readBoolEntry ( "Mute", 0 ); m_mic_muted = cfg. readBoolEntry ( "MicMute", 0 ); m_snd_key = cfg. readBoolEntry ( "KeySound", 0 ); m_snd_touch = cfg. readBoolEntry ( "TouchSound", 0 ); m_snd_alarm = cfg. readBoolEntry ( "AlarmSound", 1 ); m_alarm_percent = cfg. readNumEntry ( "AlarmPercent", 65 ); if ( force || ( m_vol_percent != old_vp )) volSlider-> setValue ( 100 - m_vol_percent ); if ( force || ( m_mic_percent != old_mp )) micSlider-> setValue ( 100 - m_mic_percent ); if ( force || ( m_alarm_percent != old_ap )) alarmSlider-> setValue ( 100 - m_alarm_percent ); if ( force || ( m_vol_muted != old_vm )) volLed-> setOn ( !m_vol_muted ); if ( force || ( m_mic_muted != old_mm )) micLed-> setOn ( !m_mic_muted ); if ( force || ( m_snd_alarm != old_sa )) alarmLed-> setOn ( m_snd_alarm ); if ( force || ( m_snd_key != old_sk )) keyBox-> setChecked ( m_snd_key ); if ( force || ( m_snd_touch != old_st )) tapBox-> setChecked ( m_snd_touch ); if ( force || ( m_snd_alarm != old_sa )) alarmBox-> setChecked ( m_snd_alarm ); } void VolumeControl::volumeChanged ( bool /*nowMuted*/ ) { int prevVol = m_vol_percent; bool prevMute = m_vol_muted; readConfig ( ); // Handle case where muting it toggled if ( m_vol_muted != prevMute ) m_icon-> redraw ( true ); else if ( prevVol != m_vol_percent ) // Avoid over repainting m_icon-> redraw ( false ); } void VolumeControl::micChanged ( bool nowMuted ) { if ( !nowMuted ) readConfig ( ); m_mic_muted = nowMuted; } void VolumeControl::screenTapToggled ( bool b ) { m_snd_touch = b; writeConfigEntry ( "TouchSound", m_snd_touch, UPD_Vol ); } void VolumeControl::keyClickToggled ( bool b ) { m_snd_key = b; writeConfigEntry ( "KeySound", m_snd_key, UPD_Vol ); } void VolumeControl::alarmSoundToggled ( bool b ) { m_snd_alarm = b; writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); } void VolumeControl::volMuteToggled ( bool b ) { m_vol_muted = !b; m_icon-> redraw ( true ); writeConfigEntry ( "Mute", m_vol_muted, UPD_Vol ); } void VolumeControl::micMuteToggled ( bool b ) { m_mic_muted = !b; writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); } void VolumeControl::volMoved ( int percent ) { m_vol_percent = 100 - percent; // clamp volume percent to be between 0 and 100 m_vol_percent = ( m_vol_percent < 0 ) ? 0 : (( m_vol_percent > 100 ) ? 100 : m_vol_percent ); // repaint just the little volume rectangle m_icon-> redraw ( false ); writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_Vol ); } void VolumeControl::micMoved ( int percent ) { m_mic_percent = 100 - percent; // clamp volume percent to be between 0 and 100 m_mic_percent = ( m_mic_percent < 0 ) ? 0 : (( m_mic_percent > 100 ) ? 100 : m_mic_percent ); writeConfigEntry ( "Mic", m_mic_percent, UPD_Mic ); } void VolumeControl::alarmMoved ( int percent ) { m_alarm_percent = 100 - percent; // clamp volume percent to be between 0 and 100 m_alarm_percent = ( m_alarm_percent < 0 ) ? 0 : (( m_alarm_percent > 100 ) ? 100 : m_alarm_percent ); writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); } void VolumeControl::writeConfigEntry ( const char *entry, int val, eUpdate upd ) { Config cfg ( "qpe" ); cfg. setGroup ( "Volume" ); cfg. writeEntry ( entry, val ); // cfg. write ( ); #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) switch ( upd ) { case UPD_Vol: { QCopEnvelope ( "QPE/System", "volumeChange(bool)" ) << m_vol_muted; break; } case UPD_Mic: { QCopEnvelope ( "QPE/System", "micChange(bool)" ) << m_mic_muted; break; } case UPD_None: break; } #endif } //=========================================================================== VolumeApplet::VolumeApplet( QWidget *parent, const char *name ) : QWidget( parent, name ) { setFixedHeight ( 18 ); setFixedWidth ( 14 ); m_pixmap = new QPixmap ( Resource::loadPixmap ( "volume" )); - m_dialog = new VolumeControl ( this ); + m_dialog = new VolumeControl ( this, true, this, "volumecontrol" ); connect ( qApp, SIGNAL( volumeChanged ( bool )), m_dialog, SLOT( volumeChanged( bool ))); connect ( qApp, SIGNAL( micChanged ( bool )), m_dialog, SLOT ( micChanged( bool ))); } VolumeApplet::~VolumeApplet() { delete m_pixmap; } void VolumeApplet::mousePressEvent ( QMouseEvent * ) { if ( m_dialog-> isVisible ( )) m_dialog-> hide ( ); else m_dialog-> show ( true ); } void VolumeApplet::redraw ( bool all ) { if ( all ) repaint ( true ); else repaint ( 2, height ( ) - 3, width ( ) - 4, 2, false ); } void VolumeApplet::paintEvent ( QPaintEvent * ) { QPainter p ( this ); p. drawPixmap ( 0, 1, *m_pixmap ); p. setPen ( darkGray ); p. drawRect ( 1, height() - 4, width() - 2, 4 ); int pixelsWide = m_dialog-> volPercent ( ) * ( width() - 4 ) / 100; p. fillRect ( 2, height() - 3, pixelsWide, 2, red ); p. fillRect ( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray ); if ( m_dialog-> volMuted ( )) { p. setPen ( red ); p. drawLine ( 1, 2, width() - 2, height() - 5 ); p. drawLine ( 1, 3, width() - 2, height() - 4 ); p. drawLine ( width() - 2, 2, 1, height() - 5 ); p. drawLine ( width() - 2, 3, 1, height() - 4 ); } } |