Commit 0148372f authored by Francois Cartegnie's avatar Francois Cartegnie

TimeSlider fix for #4328

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