[vlc-commits] Qt: add chapters to SeekSlider

Francois Cartegnie git at videolan.org
Mon Jul 11 23:14:23 CEST 2011


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Sat Jun 25 22:46:58 2011 +0200| [7def61c8a13b6184907eef4006008f2c207b4d3d] | committer: Francois Cartegnie

Qt: add chapters to SeekSlider

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

 modules/gui/qt4/components/controller.cpp |    5 ++++
 modules/gui/qt4/util/input_slider.cpp     |   38 ++++++++++++++++++++++++++++-
 modules/gui/qt4/util/input_slider.hpp     |    4 +++
 3 files changed, 46 insertions(+), 1 deletions(-)

diff --git a/modules/gui/qt4/components/controller.cpp b/modules/gui/qt4/components/controller.cpp
index 11d0b75..6a75784 100644
--- a/modules/gui/qt4/components/controller.cpp
+++ b/modules/gui/qt4/components/controller.cpp
@@ -42,6 +42,8 @@
 #include "util/input_slider.hpp"                         /* SeekSlider */
 #include "util/customwidgets.hpp"                       /* qEventToKey */
 
+#include "adapters/seekpoints.hpp"
+
 #include <QToolButton>
 #include <QHBoxLayout>
 #include <QRegion>
@@ -340,6 +342,9 @@ QWidget *AbstractController::createWidget( buttonType_e button, int options )
         break;
     case INPUT_SLIDER: {
         SeekSlider *slider = new SeekSlider( Qt::Horizontal, NULL );
+        SeekPoints *chapters = new SeekPoints( this, p_intf );
+        CONNECT( THEMIM->getIM(), titleChanged( bool ), chapters, update() );
+        slider->setChapters( chapters );
 
         /* Update the position when the IM has changed */
         CONNECT( THEMIM->getIM(), positionUpdated( float, int64_t, int ),
diff --git a/modules/gui/qt4/util/input_slider.cpp b/modules/gui/qt4/util/input_slider.cpp
index 81db2e4..1ea5b5d 100644
--- a/modules/gui/qt4/util/input_slider.cpp
+++ b/modules/gui/qt4/util/input_slider.cpp
@@ -29,6 +29,7 @@
 #include "qt4.hpp"
 
 #include "util/input_slider.hpp"
+#include "adapters/seekpoints.hpp"
 
 #include <QPaintEvent>
 #include <QPainter>
@@ -52,6 +53,7 @@ SeekSlider::SeekSlider( Qt::Orientation q, QWidget *_parent )
 {
     b_isSliding = false;
     f_buffering = 1.0;
+    chapters = NULL;
 
     /* Timer used to fire intermediate updatePos() when sliding */
     seekLimitTimer = new QTimer( this );
@@ -78,6 +80,23 @@ SeekSlider::SeekSlider( Qt::Orientation q, QWidget *_parent )
     mTimeTooltip->installEventFilter( this );
 }
 
+SeekSlider::~SeekSlider()
+{
+    delete chapters;
+}
+
+/***
+ * \brief Sets the chapters seekpoints adapter
+ *
+ * \params SeekPoints initilized with current intf thread
+***/
+void SeekSlider::setChapters( SeekPoints *chapters_ )
+{
+    delete chapters;
+    chapters = chapters_;
+    chapters->setParent( this );
+}
+
 /***
  * \brief Main public method, superseeding setValue. Disabling the slider when neeeded
  *
@@ -330,9 +349,26 @@ void SeekSlider::paintEvent( QPaintEvent *event )
         painter.drawRoundedRect( innerRect, barCorner, barCorner );
     }
 
-    // draw handle
     if ( option.state & QStyle::State_MouseOver )
     {
+        /* draw chapters tickpoints */
+        if ( chapters && inputLength && size().width() )
+        {
+            if ( orientation() == Qt::Horizontal ) /* TODO: vertical */
+            {
+                QList<SeekPoint> points = chapters->getPoints();
+                foreach( SeekPoint point, points )
+                {
+                    int x = point.time / 1000000.0 / inputLength * size().width();
+                    painter.setPen( QColor( 80, 80, 80 ) );
+                    painter.setBrush( Qt::NoBrush );
+                    painter.drawLine( x, 0, x, 3 );
+                    painter.drawLine( x, height(), x, height() - 3 );
+                }
+            }
+        }
+
+        // draw handle
         if ( sliderPos != -1 )
         {
             const int margin = 0;
diff --git a/modules/gui/qt4/util/input_slider.hpp b/modules/gui/qt4/util/input_slider.hpp
index ed3d83a..354bc28 100644
--- a/modules/gui/qt4/util/input_slider.hpp
+++ b/modules/gui/qt4/util/input_slider.hpp
@@ -36,6 +36,7 @@ class QMouseEvent;
 class QWheelEvent;
 class QHideEvent;
 class QTimer;
+class SeekPoints;
 
 /* Input Slider derived from QSlider */
 class SeekSlider : public QSlider
@@ -44,6 +45,8 @@ class SeekSlider : public QSlider
 public:
     SeekSlider( QWidget *_parent );
     SeekSlider( Qt::Orientation q, QWidget *_parent );
+    ~SeekSlider();
+    void setChapters( SeekPoints * );
 
 protected:
     virtual void mouseMoveEvent( QMouseEvent *event );
@@ -67,6 +70,7 @@ private:
     QTimer *seekLimitTimer;
     TimeTooltip *mTimeTooltip;
     float f_buffering;
+    SeekPoints* chapters;
 
 public slots:
     void setPosition( float, int64_t, int );



More information about the vlc-commits mailing list