1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-04 13:17:34 +02:00

* Update playback-bar below track when tracks is playing.

This commit is contained in:
Christian Muehlhaeuser
2014-08-19 08:24:47 +02:00
parent 471c11fd8e
commit 93b7fb3ce7
3 changed files with 39 additions and 1 deletions

View File

@@ -256,7 +256,7 @@ GridItemDelegate::onPlayClicked( const QPersistentModelIndex& index )
PlayableItem* item = m_model->sourceModel()->itemFromIndex( m_model->mapToSource( index ) );
NewClosure( AudioEngine::instance(), SIGNAL( started( Tomahawk::result_ptr ) ),
NewClosure( AudioEngine::instance(), SIGNAL( started( Tomahawk::result_ptr ) ),
const_cast<GridItemDelegate*>(this), SLOT( onPlaybackStarted( QPersistentModelIndex ) ), QPersistentModelIndex( index ) );
if ( item )

View File

@@ -91,6 +91,9 @@ PlaylistItemDelegate::PlaylistItemDelegate( TrackView* parent, PlayableProxyMode
connect( this, SIGNAL( updateIndex( QModelIndex ) ), parent, SLOT( update( QModelIndex ) ) );
connect( proxy, SIGNAL( modelReset() ), SLOT( modelChanged() ) );
connect( parent, SIGNAL( modelChanged() ), SLOT( modelChanged() ) );
connect( AudioEngine::instance(), SIGNAL( started( Tomahawk::result_ptr ) ), SLOT( onPlaybackStarted() ) );
connect( AudioEngine::instance(), SIGNAL( stopped() ), SLOT( onPlaybackStopped() ) );
}
@@ -648,6 +651,12 @@ PlaylistItemDelegate::drawTrack( QPainter* painter, const QStyleOptionViewItem&
if ( item->isPlaying() )
{
if ( m_nowPlaying != index )
{
connect( AudioEngine::instance(), SIGNAL( timerMilliSeconds( qint64 ) ), SLOT( onAudioEngineTick( qint64 ) ), Qt::UniqueConnection );
m_nowPlaying = QPersistentModelIndex( index );
}
int h = extraRect.height() / 2;
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() ) );
@@ -876,3 +885,28 @@ PlaylistItemDelegate::doUpdateIndex( const QPersistentModelIndex& index )
if ( index.isValid() )
emit updateIndex( index );
}
void
PlaylistItemDelegate::onAudioEngineTick( qint64 /* ms */ )
{
doUpdateIndex( m_nowPlaying );
}
void
PlaylistItemDelegate::onPlaybackStarted()
{
disconnect( AudioEngine::instance(), SIGNAL( timerMilliSeconds( qint64 ) ), this, SLOT( onAudioEngineTick( qint64 ) ) );
doUpdateIndex( m_nowPlaying );
m_nowPlaying = QModelIndex();
}
void
PlaylistItemDelegate::onPlaybackStopped()
{
disconnect( AudioEngine::instance(), SIGNAL( timerMilliSeconds( qint64 ) ), this, SLOT( onAudioEngineTick( qint64 ) ) );
doUpdateIndex( m_nowPlaying );
m_nowPlaying = QModelIndex();
}

View File

@@ -108,6 +108,9 @@ protected:
protected slots:
virtual void modelChanged();
virtual void onAudioEngineTick( qint64 ms );
virtual void onPlaybackStarted();
virtual void onPlaybackStopped();
private:
mutable QHash< QPersistentModelIndex, QSharedPointer< Tomahawk::PixmapDelegateFader > > m_pixmaps;
@@ -117,6 +120,7 @@ private:
mutable QHash< QPersistentModelIndex, QHash< Tomahawk::source_ptr, QRect > > m_avatarBoxRects;
QPersistentModelIndex m_hoveringOver;
QPersistentModelIndex m_hoveringOverArtist;
mutable QPersistentModelIndex m_nowPlaying;
TrackView* m_view;
PlayableProxyModel* m_model;