[vlc-commits] Qt: display buffering in SeekSlider

Francois Cartegnie git at videolan.org
Sun Jun 12 17:39:56 CEST 2011


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Sun Jun 12 17:22:54 2011 +0200| [afd0390393425bc111e764c8fefa453c180617ee] | committer: Francois Cartegnie

Qt: display buffering in SeekSlider

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=afd0390393425bc111e764c8fefa453c180617ee
---

 modules/gui/qt4/components/controller.cpp |    2 ++
 modules/gui/qt4/util/input_slider.cpp     |   19 ++++++++++++++++++-
 modules/gui/qt4/util/input_slider.hpp     |    2 ++
 3 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/modules/gui/qt4/components/controller.cpp b/modules/gui/qt4/components/controller.cpp
index 0696bf7..11d0b75 100644
--- a/modules/gui/qt4/components/controller.cpp
+++ b/modules/gui/qt4/components/controller.cpp
@@ -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;
diff --git a/modules/gui/qt4/util/input_slider.cpp b/modules/gui/qt4/util/input_slider.cpp
index 5449a93..3c51b29 100644
--- a/modules/gui/qt4/util/input_slider.cpp
+++ b/modules/gui/qt4/util/input_slider.cpp
@@ -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 )
     {
diff --git a/modules/gui/qt4/util/input_slider.hpp b/modules/gui/qt4/util/input_slider.hpp
index 49dcc3d..ed3d83a 100644
--- a/modules/gui/qt4/util/input_slider.hpp
+++ b/modules/gui/qt4/util/input_slider.hpp
@@ -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();



More information about the vlc-commits mailing list