Commit e7e26e38 authored by Francois Cartegnie's avatar Francois Cartegnie

Qt: SoundSlider: don't fire back signal when a change comes from lib

parent f8fe27ad
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
SoundWidget::SoundWidget( QWidget *_parent, intf_thread_t * _p_intf, SoundWidget::SoundWidget( QWidget *_parent, intf_thread_t * _p_intf,
bool b_shiny, bool b_special ) bool b_shiny, bool b_special )
: QWidget( _parent ), p_intf( _p_intf), : 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 */ /* We need a layout for this widget */
QHBoxLayout *layout = new QHBoxLayout( this ); QHBoxLayout *layout = new QHBoxLayout( this );
...@@ -113,7 +113,8 @@ SoundWidget::SoundWidget( QWidget *_parent, intf_thread_t * _p_intf, ...@@ -113,7 +113,8 @@ SoundWidget::SoundWidget( QWidget *_parent, intf_thread_t * _p_intf,
/* Volume control connection */ /* Volume control connection */
volumeSlider->setTracking( true ); 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, volumeChanged( void ), this, libUpdateVolume( void ) );
CONNECT( THEMIM, soundMuteChanged( void ), this, updateMuteStatus( void ) ); CONNECT( THEMIM, soundMuteChanged( void ), this, updateMuteStatus( void ) );
} }
...@@ -164,12 +165,19 @@ void SoundWidget::libUpdateVolume() ...@@ -164,12 +165,19 @@ void SoundWidget::libUpdateVolume()
i_volume = aout_VolumeGet( p_playlist ); i_volume = aout_VolumeGet( p_playlist );
i_volume = ( ( i_volume + 1 ) * VOLUME_MAX )/ (AOUT_VOLUME_MAX/2); i_volume = ( ( i_volume + 1 ) * VOLUME_MAX )/ (AOUT_VOLUME_MAX/2);
int i_gauge = volumeSlider->value(); int i_gauge = volumeSlider->value();
if ( !b_is_muted && /* do not show mute effect on volume (set to 0) */ if ( i_volume - i_gauge != 0 )
( i_volume - i_gauge > 1 || i_gauge - i_volume > 1 )
)
{ {
b_ignore_valuechanged = true;
volumeSlider->setValue( i_volume ); 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 */ /* libvlc mute/unmute event slot */
......
...@@ -86,6 +86,7 @@ private: ...@@ -86,6 +86,7 @@ private:
QMenu *volumeMenu; QMenu *volumeMenu;
virtual bool eventFilter( QObject *obj, QEvent *e ); virtual bool eventFilter( QObject *obj, QEvent *e );
bool b_is_muted; bool b_is_muted;
bool b_ignore_valuechanged;
protected slots: protected slots:
void userUpdateVolume( int ); void userUpdateVolume( int );
...@@ -93,6 +94,10 @@ protected slots: ...@@ -93,6 +94,10 @@ protected slots:
void updateMuteStatus( void ); void updateMuteStatus( void );
void refreshLabels( void ); void refreshLabels( void );
void showVolumeMenu( QPoint pos ); void showVolumeMenu( QPoint pos );
void valueChangedFilter( int );
signals:
void valueReallyChanged( int );
}; };
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment