]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/components/controller_widget.cpp
New icons for repeat, more obvious, done by Daniel Dreibrodt
[vlc] / modules / gui / qt4 / components / controller_widget.cpp
index 8775fe42db3904daf0f6ffe052c7b7fc645b700e..9ee711796e6498bfde5d30eee694abb584d7929a 100644 (file)
@@ -87,15 +87,15 @@ SoundWidget::SoundWidget( QWidget *_parent, intf_thread_t * _p_intf,
     {
         volumeSlider = new SoundSlider( this,
             config_GetInt( p_intf, "volume-step" ),
-            config_GetInt( p_intf, "qt-volume-complete" ),
-            config_GetPsz( p_intf, "qt-slider-colours" ) );
+            var_InheritInteger( p_intf, "qt-volume-complete" ),
+            var_InheritString( p_intf, "qt-slider-colours" ) );
     }
     else
     {
         volumeSlider = new QSlider( NULL );
         volumeSlider->setOrientation( b_special ? Qt::Vertical
                                                 : Qt::Horizontal );
-        volumeSlider->setMaximum( config_GetInt( p_intf, "qt-volume-complete" )
+        volumeSlider->setMaximum( var_InheritBool( p_intf, "qt-volume-complete" )
                                   ? 400 : 200 );
     }
     if( volumeSlider->orientation() ==  Qt::Horizontal )
@@ -111,16 +111,14 @@ SoundWidget::SoundWidget( QWidget *_parent, intf_thread_t * _p_intf,
         layout->addWidget( volumeSlider, 0, Qt::AlignBottom  );
 
     /* Set the volume from the config */
-    volumeSlider->setValue( qRound( ( (qreal)config_GetInt( p_intf, "volume" ) ) *
-                              VOLUME_MAX / (AOUT_VOLUME_MAX/2) ) );
-
+    libUpdateVolume();
     /* Force the update at build time in order to have a muted icon if needed */
-    updateVolume( volumeSlider->value() );
+    updateMuteStatus();
 
     /* Volume control connection */
     CONNECT( volumeSlider, valueChanged( int ), this, refreshLabels( void ) );
-    CONNECT( volumeSlider, sliderMoved( int ), this, updateVolume( int ) );
-    CONNECT( THEMIM, volumeChanged( void ), this, updateVolume( void ) );
+    CONNECT( volumeSlider, sliderMoved( int ), this, userUpdateVolume( int ) );
+    CONNECT( THEMIM, volumeChanged( void ), this, libUpdateVolume( void ) );
     CONNECT( THEMIM, soundMuteChanged( void ), this, updateMuteStatus( void ) );
 }
 
@@ -150,25 +148,23 @@ void SoundWidget::refreshLabels()
 }
 
 /* volumeSlider changed value event slot */
-void SoundWidget::updateVolume( int i_sliderVolume )
+void SoundWidget::userUpdateVolume( int i_sliderVolume )
 {
     /* Only if volume is set by user action on slider */
     setMuted( false );
-    playlist_t *p_playlist = pl_Hold( p_intf );
+    playlist_t *p_playlist = pl_Get( p_intf );
     int i_res = i_sliderVolume  * (AOUT_VOLUME_MAX / 2) / VOLUME_MAX;
     aout_VolumeSet( p_playlist, i_res );
-    pl_Release( p_intf );
 }
 
 /* libvlc changed value event slot */
-void SoundWidget::updateVolume()
+void SoundWidget::libUpdateVolume()
 {
     /* Audio part */
     audio_volume_t i_volume;
-    playlist_t *p_playlist = pl_Hold( p_intf );
+    playlist_t *p_playlist = pl_Get( p_intf );
 
     aout_VolumeGet( p_playlist, &i_volume );
-    pl_Release( p_intf );
     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) */
@@ -182,10 +178,12 @@ void SoundWidget::updateVolume()
 /* libvlc mute/unmute event slot */
 void SoundWidget::updateMuteStatus()
 {
-    playlist_t *p_playlist = pl_Hold( p_intf );
+    playlist_t *p_playlist = pl_Get( p_intf );
     b_is_muted = aout_IsMuted( VLC_OBJECT(p_playlist) );
-    pl_Release( p_intf );
-    (qobject_cast<SoundSlider *>(volumeSlider))->setMuted( b_is_muted );
+
+    SoundSlider *soundSlider = qobject_cast<SoundSlider *>(volumeSlider);
+    if( soundSlider )
+        soundSlider->setMuted( b_is_muted );
     refreshLabels();
 }
 
@@ -199,9 +197,8 @@ void SoundWidget::showVolumeMenu( QPoint pos )
 void SoundWidget::setMuted( bool mute )
 {
     b_is_muted = mute;
-    playlist_t *p_playlist = pl_Hold( p_intf );
+    playlist_t *p_playlist = pl_Get( p_intf );
     aout_SetMute( VLC_OBJECT(p_playlist), NULL, mute );
-    pl_Release( p_intf );
 }
 
 bool SoundWidget::eventFilter( QObject *obj, QEvent *e )