QSlider( q, _parent )
{
b_isSliding = false;
+ lastSeeked = 0;
+ timer = new QTimer(this);
+ timer->setSingleShot(true);
setMinimum( 0 );
setMouseTracking(true);
setMaximum( 1000 );
secstotimestr( psz_length, 0 );
setFocusPolicy( Qt::NoFocus );
CONNECT( this, valueChanged(int), this, userDrag( int ) );
+ CONNECT( timer, timeout(), this, seekTick() );
}
void InputSlider::setPosition( float pos, int a, int b )
void InputSlider::userDrag( int new_value )
{
- if( b_isSliding )
- {
- float f_pos = (float)(new_value)/1000.0;
+ 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 );
}
}
Qt::MouseButtons( event->buttons() ^ Qt::LeftButton ^ Qt::MidButton ),
event->modifiers() );
QSlider::mousePressEvent( &newEvent );
+
+ seekTick();
}
void InputSlider::mouseMoveEvent(QMouseEvent *event)
#include <QMouseEvent>
#include <QWheelEvent>
+#include <QTimer>
/* Input Slider derived from QSlider */
class InputSlider : public QSlider
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:
void setPosition( float, int, int );
private slots:
void userDrag( int );
+ void seekTick();
signals:
void sliderDragged( float );