-rw-r--r-- | core/applets/volumeapplet/volume.cpp | 49 | ||||
-rw-r--r-- | core/applets/volumeapplet/volume.h | 2 |
2 files changed, 22 insertions, 29 deletions
diff --git a/core/applets/volumeapplet/volume.cpp b/core/applets/volumeapplet/volume.cpp index b047877..eedc749 100644 --- a/core/applets/volumeapplet/volume.cpp +++ b/core/applets/volumeapplet/volume.cpp @@ -178,30 +178,21 @@ static const char * alarm_xpm[] = { " /@. ", " "}; VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *parent, const char *name ) : QFrame ( parent, name, WStyle_StaysOnTop | WType_Popup ) { m_icon = icon; - bool has_wav_alarm = false; + bool has_wav_alarm = true; switch ( ODevice::inst ( )-> model ( )) { // we need to add other devices eventually - case OMODEL_iPAQ_H31xx: - case OMODEL_iPAQ_H36xx: - case OMODEL_iPAQ_H37xx: - case OMODEL_iPAQ_H38xx: - has_wav_alarm = true; - break; case OMODEL_Zaurus_SL5000: - has_wav_alarm = false; //poor guys probably feeling left out... - break; - default: - has_wav_alarm = true; //lets just presume + has_wav_alarm = false; //poor guys probably feeling left out... break; } setFrameStyle ( QFrame::PopupPanel | QFrame::Raised ); QGridLayout *grid = new QGridLayout ( this, 1, 1, 6, 4 ); grid-> setSpacing ( 4 ); @@ -403,26 +394,23 @@ void VolumeControl::rateTimerDone ( ) volSlider-> setValue ( volSlider-> value ( ) + 2 ); } void VolumeControl::show ( bool /*showMic*/ ) { readConfig ( ); QPoint curPos = m_icon-> mapToGlobal ( QPoint ( 0, 0 )); - printf ( "SHOW AT : %d/%d\n", curPos.x(), curPos.y()); - printf ( "SIZEHINT: %d/%d\n", sizeHint().width(),sizeHint().height()); 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" ); @@ -466,31 +454,26 @@ void VolumeControl::readConfig ( bool force ) tapBox-> setChecked ( m_snd_touch ); if ( force || ( m_snd_alarm != old_sa )) alarmBox-> setChecked ( m_snd_alarm ); } void VolumeControl::volumeChanged ( bool nowMuted ) { - int previousVolume = m_vol_percent; + int prevVol = m_vol_percent; + bool prevMute = m_vol_muted; - if ( !nowMuted ) - readConfig ( ); + readConfig ( ); // Handle case where muting it toggled - if ( m_vol_muted != nowMuted ) { - m_vol_muted = nowMuted; - m_icon-> repaint ( true ); - } - else if ( previousVolume != m_vol_percent ) { - // Avoid over repainting - m_icon-> repaint( 2, height ( ) - 3, width ( ) - 4, 2, false ); - } - + 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; } @@ -512,17 +495,17 @@ 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-> repaint ( !m_vol_muted ); // clear if removing mute + 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 ); @@ -531,18 +514,18 @@ void VolumeControl::micMuteToggled ( bool b ) 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 - repaint ( 2, height ( ) - 3, width ( ) - 4, 2, false ); - + 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 @@ -609,16 +592,24 @@ VolumeApplet::~VolumeApplet() 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 ); diff --git a/core/applets/volumeapplet/volume.h b/core/applets/volumeapplet/volume.h index ff5c64a..4d988ac 100644 --- a/core/applets/volumeapplet/volume.h +++ b/core/applets/volumeapplet/volume.h @@ -105,16 +105,18 @@ private: class VolumeApplet : public QWidget { Q_OBJECT public: VolumeApplet ( QWidget *parent = 0, const char *name=0 ); ~VolumeApplet ( ); + void redraw ( bool all = true ); + protected: virtual void mousePressEvent ( QMouseEvent * ); virtual void paintEvent ( QPaintEvent* ); private: QPixmap * m_pixmap; VolumeControl *m_dialog; }; |