[vlc-devel] commit: Qt: remove the b_mybutton hack. Connect the appropriate events. ( Francois Cartegnie )

git version control git at videolan.org
Sun Jan 10 14:51:34 CET 2010


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Jan  8 00:02:13 2010 +0100| [18addd464ff59b5b7e8877e426e861d06b86a45a] | committer: Rémi Denis-Courmont 

Qt: remove the b_mybutton hack. Connect the appropriate events.

Signed-off-by: Rémi Denis-Courmont <remi at remlab.net>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=18addd464ff59b5b7e8877e426e861d06b86a45a
---

 modules/gui/qt4/components/controller_widget.cpp |   23 ++++++++-------------
 modules/gui/qt4/components/controller_widget.hpp |    1 -
 modules/gui/qt4/util/input_slider.cpp            |    3 ++
 3 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/modules/gui/qt4/components/controller_widget.cpp b/modules/gui/qt4/components/controller_widget.cpp
index 2e584a4..8775fe4 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_my_volume( false ), b_is_muted( false )
+                           b_is_muted( false )
 {
     /* We need a layout for this widget */
     QHBoxLayout *layout = new QHBoxLayout( this );
@@ -118,7 +118,8 @@ SoundWidget::SoundWidget( QWidget *_parent, intf_thread_t * _p_intf,
     updateVolume( volumeSlider->value() );
 
     /* Volume control connection */
-    CONNECT( volumeSlider, valueChanged( int ), this, updateVolume( int ) );
+    CONNECT( volumeSlider, valueChanged( int ), this, refreshLabels( void ) );
+    CONNECT( volumeSlider, sliderMoved( int ), this, updateVolume( int ) );
     CONNECT( THEMIM, volumeChanged( void ), this, updateVolume( void ) );
     CONNECT( THEMIM, soundMuteChanged( void ), this, updateMuteStatus( void ) );
 }
@@ -151,15 +152,12 @@ void SoundWidget::refreshLabels()
 /* volumeSlider changed value event slot */
 void SoundWidget::updateVolume( int i_sliderVolume )
 {
-    if( !b_my_volume ) /* Only if volume is set by user action on slider */
-    {
-        setMuted( false );
-        playlist_t *p_playlist = pl_Hold( p_intf );
-        int i_res = i_sliderVolume  * (AOUT_VOLUME_MAX / 2) / VOLUME_MAX;
-        aout_VolumeSet( p_playlist, i_res );
-        pl_Release( p_intf );
-    }
-    refreshLabels();
+    /* Only if volume is set by user action on slider */
+    setMuted( false );
+    playlist_t *p_playlist = pl_Hold( 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 */
@@ -173,14 +171,11 @@ void SoundWidget::updateVolume()
     pl_Release( p_intf );
     i_volume = ( ( i_volume + 1 ) *  VOLUME_MAX )/ (AOUT_VOLUME_MAX/2);
     int i_gauge = volumeSlider->value();
-    b_my_volume = false;
     if ( !b_is_muted && /* do not show mute effect on volume (set to 0) */
         ( i_volume - i_gauge > 1 || i_gauge - i_volume > 1 )
     )
     {
-        b_my_volume = true;
         volumeSlider->setValue( i_volume );
-        b_my_volume = false;
     }
 }
 
diff --git a/modules/gui/qt4/components/controller_widget.hpp b/modules/gui/qt4/components/controller_widget.hpp
index f68b238..71864e9 100644
--- a/modules/gui/qt4/components/controller_widget.hpp
+++ b/modules/gui/qt4/components/controller_widget.hpp
@@ -83,7 +83,6 @@ private:
     QLabel              *volMuteLabel;
     QAbstractSlider     *volumeSlider;
     QFrame              *volumeControlWidget;
-    bool                 b_my_volume;
     QMenu               *volumeMenu;
     virtual bool eventFilter( QObject *obj, QEvent *e );
     bool                b_is_muted;
diff --git a/modules/gui/qt4/util/input_slider.cpp b/modules/gui/qt4/util/input_slider.cpp
index a8fedc8..fb980b9 100644
--- a/modules/gui/qt4/util/input_slider.cpp
+++ b/modules/gui/qt4/util/input_slider.cpp
@@ -235,6 +235,7 @@ void SoundSlider::wheelEvent( QWheelEvent *event )
     setValue( __MIN( __MAX( minimum(), newvalue ), maximum() ) );
 
     emit sliderReleased();
+    emit sliderMoved( value() );
 }
 
 void SoundSlider::mousePressEvent( QMouseEvent *event )
@@ -246,6 +247,7 @@ void SoundSlider::mousePressEvent( QMouseEvent *event )
         i_oldvalue = value();
         emit sliderPressed();
         changeValue( event->x() - paddingL );
+        emit sliderMoved( value() );
     }
 }
 
@@ -257,6 +259,7 @@ void SoundSlider::mouseReleaseEvent( QMouseEvent *event )
         {
             emit sliderReleased();
             setValue( value() );
+            emit sliderMoved( value() );
         }
         b_isSliding = false;
         b_mouseOutside = false;




More information about the vlc-devel mailing list