vlc | branch: master | Francois Cartegnie <[email protected]> | Sun Apr 10 13:49:31 2011 +0200| [e7e26e381c537afd80a423d49080841746606f92] | committer: Francois Cartegnie
Qt: SoundSlider: don't fire back signal when a change comes from lib > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e7e26e381c537afd80a423d49080841746606f92 --- modules/gui/qt4/components/controller_widget.cpp | 18 +++++++++++++----- modules/gui/qt4/components/controller_widget.hpp | 5 +++++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/modules/gui/qt4/components/controller_widget.cpp b/modules/gui/qt4/components/controller_widget.cpp index e77cdec..0eca5e8 100644 --- a/modules/gui/qt4/components/controller_widget.cpp +++ b/modules/gui/qt4/components/controller_widget.cpp @@ -43,7 +43,7 @@ SoundWidget::SoundWidget( QWidget *_parent, intf_thread_t * _p_intf, bool b_shiny, bool b_special ) : QWidget( _parent ), p_intf( _p_intf), - b_is_muted( false ) + b_is_muted( false ), b_ignore_valuechanged( false ) { /* We need a layout for this widget */ QHBoxLayout *layout = new QHBoxLayout( this ); @@ -113,7 +113,8 @@ SoundWidget::SoundWidget( QWidget *_parent, intf_thread_t * _p_intf, /* Volume control connection */ volumeSlider->setTracking( true ); - CONNECT( volumeSlider, valueChanged( int ), this, userUpdateVolume( int ) ); + CONNECT( volumeSlider, valueChanged( int ), this, valueChangedFilter( int ) ); + CONNECT( this, valueReallyChanged( int ), this, userUpdateVolume( int ) ); CONNECT( THEMIM, volumeChanged( void ), this, libUpdateVolume( void ) ); CONNECT( THEMIM, soundMuteChanged( void ), this, updateMuteStatus( void ) ); } @@ -164,12 +165,19 @@ void SoundWidget::libUpdateVolume() i_volume = aout_VolumeGet( p_playlist ); i_volume = ( ( i_volume + 1 ) * VOLUME_MAX )/ (AOUT_VOLUME_MAX/2); int i_gauge = volumeSlider->value(); - if ( !b_is_muted && /* do not show mute effect on volume (set to 0) */ - ( i_volume - i_gauge > 1 || i_gauge - i_volume > 1 ) - ) + if ( i_volume - i_gauge != 0 ) { + b_ignore_valuechanged = true; volumeSlider->setValue( i_volume ); + b_ignore_valuechanged = false; } + refreshLabels(); +} + +void SoundWidget::valueChangedFilter( int i_val ) +{ + /* valueChanged is also emitted when the lib setValue() */ + if ( !b_ignore_valuechanged ) emit valueReallyChanged( i_val ); } /* libvlc mute/unmute event slot */ diff --git a/modules/gui/qt4/components/controller_widget.hpp b/modules/gui/qt4/components/controller_widget.hpp index 5727da3..c800020 100644 --- a/modules/gui/qt4/components/controller_widget.hpp +++ b/modules/gui/qt4/components/controller_widget.hpp @@ -86,6 +86,7 @@ private: QMenu *volumeMenu; virtual bool eventFilter( QObject *obj, QEvent *e ); bool b_is_muted; + bool b_ignore_valuechanged; protected slots: void userUpdateVolume( int ); @@ -93,6 +94,10 @@ protected slots: void updateMuteStatus( void ); void refreshLabels( void ); void showVolumeMenu( QPoint pos ); + void valueChangedFilter( int ); + +signals: + void valueReallyChanged( int ); }; #endif _______________________________________________ vlc-commits mailing list [email protected] http://mailman.videolan.org/listinfo/vlc-commits
