Commit 7def61c8 authored by Francois Cartegnie's avatar Francois Cartegnie

Qt: add chapters to SeekSlider

parent f2038037
......@@ -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 ),
......
......@@ -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;
......
......@@ -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 );
......
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