mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-12 09:04:33 +02:00
* Fixed in-playlist progress bar for tracks with unknown stream duration, like tracks resolved to Beats.
This commit is contained in:
@@ -672,6 +672,12 @@ PlaylistItemDelegate::drawTrack( QPainter* painter, const QStyleOptionViewItem&
|
||||
QRect playIconRect = extraRect.adjusted( extraRect.width() - h - 8, h / 2, -8, -h / 2 );
|
||||
painter->drawPixmap( playIconRect, ImageRegistry::instance()->pixmap( RESPATH "images/play.svg", playIconRect.size() ) );
|
||||
|
||||
double duration = (double)AudioEngine::instance()->currentTrackTotalTime();
|
||||
if ( duration <= 0 )
|
||||
duration = item->query()->track()->duration() * 1000;
|
||||
|
||||
if ( duration > 0 )
|
||||
{
|
||||
painter->save();
|
||||
painter->setPen( Qt::transparent );
|
||||
painter->setBrush( Qt::darkRed );
|
||||
@@ -681,12 +687,13 @@ PlaylistItemDelegate::drawTrack( QPainter* painter, const QStyleOptionViewItem&
|
||||
painter->setOpacity( 0.1 );
|
||||
painter->drawRect( playBar );
|
||||
|
||||
playBar.setWidth( ( (double)AudioEngine::instance()->currentTime() / (double)AudioEngine::instance()->currentTrackTotalTime() ) * (double)playBar.width() );
|
||||
playBar.setWidth( ( (double)AudioEngine::instance()->currentTime() / duration ) * (double)playBar.width() );
|
||||
painter->setOpacity( 1 );
|
||||
painter->drawRect( playBar );
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
}
|
||||
else if ( track->duration() > 0 )
|
||||
{
|
||||
painter->setOpacity( 0.5 * opacityCo );
|
||||
|
@@ -269,7 +269,7 @@ AudioControls::onPlaybackStarted( const Tomahawk::result_ptr result )
|
||||
|
||||
qint64 duration = AudioEngine::instance()->currentTrackTotalTime();
|
||||
|
||||
if ( duration == -1 || duration == 0 )
|
||||
if ( duration <= 0 )
|
||||
duration = result.data()->track()->duration() * 1000;
|
||||
|
||||
ui->seekSlider->setRange( 0, duration );
|
||||
|
Reference in New Issue
Block a user