[vlc-commits] TimeSlider fix for #4328
Francois Cartegnie
git at videolan.org
Sat Jan 22 17:50:04 CET 2011
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Jan 21 20:24:52 2011 +0100| [0148372f16ababc6d59f909a9b86cd6f5d76cf78] | committer: Francois Cartegnie
TimeSlider fix for #4328
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0148372f16ababc6d59f909a9b86cd6f5d76cf78
---
modules/gui/qt4/util/input_slider.cpp | 17 +++++++----------
modules/gui/qt4/util/input_slider.hpp | 1 -
2 files changed, 7 insertions(+), 11 deletions(-)
diff --git a/modules/gui/qt4/util/input_slider.cpp b/modules/gui/qt4/util/input_slider.cpp
index 19f6ad7..a070439 100644
--- a/modules/gui/qt4/util/input_slider.cpp
+++ b/modules/gui/qt4/util/input_slider.cpp
@@ -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)
diff --git a/modules/gui/qt4/util/input_slider.hpp b/modules/gui/qt4/util/input_slider.hpp
index 08800f1..3b6ad71 100644
--- a/modules/gui/qt4/util/input_slider.hpp
+++ b/modules/gui/qt4/util/input_slider.hpp
@@ -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:
More information about the vlc-commits
mailing list