]> git.sesse.net Git - vlc/commitdiff
TimeSlider fix for #4328
authorFrancois Cartegnie <fcvlcdev@free.fr>
Fri, 21 Jan 2011 19:24:52 +0000 (20:24 +0100)
committerFrancois Cartegnie <fcvlcdev@free.fr>
Sat, 22 Jan 2011 16:49:40 +0000 (17:49 +0100)
modules/gui/qt4/util/input_slider.cpp
modules/gui/qt4/util/input_slider.hpp

index 19f6ad7e7ee36212a7d5447f72e1dd28ba0016af..a0704399611291dc1c56ea6bff3e0b8d4486f9c0 100644 (file)
@@ -41,8 +41,8 @@ InputSlider::InputSlider( Qt::Orientation q, QWidget *_parent ) :
                                  QSlider( q, _parent )
 {
     b_isSliding = false;
-    lastSeeked  = 0;
 
+    /* Timer used to fire intermediate seekTick() when sliding */
     timer = new QTimer(this);
     timer->setSingleShot(true);
 
@@ -58,7 +58,7 @@ InputSlider::InputSlider( Qt::Orientation q, QWidget *_parent ) :
     setPosition( -1.0, 0, 0 );
     secstotimestr( psz_length, 0 );
 
-    CONNECT( this, valueChanged(int), this, userDrag( int ) );
+    CONNECT( this, sliderMoved(int), this, userDrag( int ) );
     CONNECT( timer, timeout(), this, seekTick() );
 }
 
@@ -80,25 +80,24 @@ void InputSlider::setPosition( float pos, int64_t a, int b )
 
 void InputSlider::userDrag( int new_value )
 {
+    /* Only fire one update, when sliding, every 150ms */
     if( b_isSliding && !timer->isActive() )
         timer->start( 150 );
 }
 
 void InputSlider::seekTick()
 {
-    if( value() != lastSeeked )
-    {
-        lastSeeked = value();
-        float f_pos = (float)(lastSeeked)/1000.0;
-        emit sliderDragged( f_pos );
-    }
+    float f_pos = (float)(value())/1000.0;
+    emit sliderDragged( f_pos ); /* Send new position to our video */
 }
 
 void InputSlider::mouseReleaseEvent( QMouseEvent *event )
 {
+    timer->stop(); /* We're not sliding anymore: only last seek on release */
     b_isSliding = false;
     event->accept();
     QSlider::mouseReleaseEvent( event );
+    seekTick();
 }
 
 void InputSlider::mousePressEvent(QMouseEvent* event)
@@ -116,8 +115,6 @@ void InputSlider::mousePressEvent(QMouseEvent* event)
         Qt::MouseButtons( event->buttons() ^ Qt::LeftButton ^ Qt::MidButton ),
         event->modifiers() );
     QSlider::mousePressEvent( &newEvent );
-
-    seekTick();
 }
 
 void InputSlider::mouseMoveEvent(QMouseEvent *event)
index 08800f1ded9f986890322bee77405fe1fd6816ef..3b6ad718c08136db9f1cfe943690562f820fa592 100644 (file)
@@ -50,7 +50,6 @@ private:
     bool b_isSliding; /* Whether we are currently sliding by user action */
     int inputLength;  /* InputLength that can change */
     char psz_length[MSTRTIME_MAX_SIZE]; /* Used for the ToolTip */
-    int lastSeeked;
     QTimer *timer;
 
 public slots: