Commit afd03903 authored by Francois Cartegnie's avatar Francois Cartegnie

Qt: display buffering in SeekSlider

parent 9abb97d0
......@@ -347,6 +347,8 @@ QWidget *AbstractController::createWidget( buttonType_e button, int options )
/* And update the IM, when the position has changed */
CONNECT( slider, sliderDragged( float ),
THEMIM->getIM(), sliderUpdate( float ) );
CONNECT( THEMIM->getIM(), cachingChanged( float ),
slider, updateBuffering( float ) );
widget = slider;
}
break;
......
......@@ -51,6 +51,7 @@ SeekSlider::SeekSlider( Qt::Orientation q, QWidget *_parent )
: QSlider( q, _parent )
{
b_isSliding = false;
f_buffering = 1.0;
/* Timer used to fire intermediate updatePos() when sliding */
seekLimitTimer = new QTimer( this );
......@@ -74,7 +75,6 @@ SeekSlider::SeekSlider( Qt::Orientation q, QWidget *_parent )
CONNECT( this, sliderMoved( int ), this, startSeekTimer() );
CONNECT( seekLimitTimer, timeout(), this, updatePos() );
mTimeTooltip->installEventFilter( this );
}
......@@ -114,6 +114,12 @@ void SeekSlider::updatePos()
emit sliderDragged( f_pos ); /* Send new position to VLC's core */
}
void SeekSlider::updateBuffering( float f_buffering_ )
{
f_buffering = f_buffering_;
repaint();
}
void SeekSlider::mouseReleaseEvent( QMouseEvent *event )
{
event->accept();
......@@ -312,6 +318,17 @@ void SeekSlider::paintEvent( QPaintEvent *event )
painter.drawRoundedRect( valueRect, barCorner, barCorner );
}
// draw buffering overlay
if ( f_buffering < 1.0 )
{
QRect innerRect = barRect.adjusted( 1, 1,
barRect.width() * ( -1.0 + f_buffering ) - 1, 0 );
QColor overlayColor = QColor( "Orange" );
overlayColor.setAlpha( 128 );
painter.setBrush( overlayColor );
painter.drawRoundedRect( innerRect, barCorner, barCorner );
}
// draw handle
if ( option.state & QStyle::State_MouseOver )
{
......
......@@ -66,9 +66,11 @@ private:
char psz_length[MSTRTIME_MAX_SIZE]; /* Used for the ToolTip */
QTimer *seekLimitTimer;
TimeTooltip *mTimeTooltip;
float f_buffering;
public slots:
void setPosition( float, int64_t, int );
void updateBuffering( float );
private slots:
void startSeekTimer();
......
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