Commit 4e0b6089 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt: fix seekpoint bar when first chapter does not start at 0

Close #12416
parent 961028d9
...@@ -348,23 +348,22 @@ void SeekSlider::mouseMoveEvent( QMouseEvent *event ) ...@@ -348,23 +348,22 @@ void SeekSlider::mouseMoveEvent( QMouseEvent *event )
if ( orientation() == Qt::Horizontal ) /* TODO: vertical */ if ( orientation() == Qt::Horizontal ) /* TODO: vertical */
{ {
QList<SeekPoint> points = chapters->getPoints(); QList<SeekPoint> points = chapters->getPoints();
int i_selected = -1; int i_selected = -1;
bool b_startsnonzero = false; for( int i = 0 ; i < points.count() ; i++ )
if ( points.count() > 0 ) {
b_startsnonzero = ( points.at(0).time > 0 ); int x = points.at(i).time / 1000000.0 / inputLength * size().width();
for( int i = 0 ; i < points.count() ; i++ ) if ( event->x() >= x )
{ i_selected = i;
int x = points.at(i).time / 1000000.0 / inputLength * size().width(); }
if ( event->x() >= x ) if ( i_selected >= 0 && i_selected < points.size() )
i_selected = i + ( ( b_startsnonzero )? 1 : 0 ); {
} chapterLabel = points.at( i_selected ).name;
if ( i_selected >= 0 && i_selected < points.size() ) }
chapterLabel = points.at( i_selected ).name;
} }
QPoint target( event->globalX() - ( event->x() - posX ), QPoint target( event->globalX() - ( event->x() - posX ),
QWidget::mapToGlobal( QPoint( 0, 0 ) ).y() ); QWidget::mapToGlobal( QPoint( 0, 0 ) ).y() );
if( likely( size().width() > handleLength() ) ) { if( likely( size().width() > handleLength() ) ) {
secstotimestr( psz_length, ( ( posX - margin ) * inputLength ) / ( size().width() - handleLength() ) ); secstotimestr( psz_length, ( ( posX - margin ) * inputLength ) / ( size().width() - handleLength() ) );
mTimeTooltip->setTip( target, psz_length, chapterLabel ); mTimeTooltip->setTip( target, psz_length, chapterLabel );
......
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