diff --git a/modules/gui/qt4/components/controller.cpp b/modules/gui/qt4/components/controller.cpp index 11d0b755cfa77429f789348c7f01c8af4dff505d..6a75784ce33022120c10429c6af76bca9f0f4a5b 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 81db2e4436112554eda8c09cbdb31f8395ee7a48..1ea5b5de77d403bbdb5e31a47e8e18ebcea54d0f 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 ed3d83ae80807de51ff59e6d3f806094266e4444..354bc28837d178a6e6e9c37b2a32663a3d719b76 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 );