mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-04 21:27:58 +02:00
* Update playback-bar below track when tracks is playing.
This commit is contained in:
@@ -91,6 +91,9 @@ PlaylistItemDelegate::PlaylistItemDelegate( TrackView* parent, PlayableProxyMode
|
|||||||
connect( this, SIGNAL( updateIndex( QModelIndex ) ), parent, SLOT( update( QModelIndex ) ) );
|
connect( this, SIGNAL( updateIndex( QModelIndex ) ), parent, SLOT( update( QModelIndex ) ) );
|
||||||
connect( proxy, SIGNAL( modelReset() ), SLOT( modelChanged() ) );
|
connect( proxy, SIGNAL( modelReset() ), SLOT( modelChanged() ) );
|
||||||
connect( parent, SIGNAL( modelChanged() ), 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 ( 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;
|
int h = extraRect.height() / 2;
|
||||||
QRect playIconRect = extraRect.adjusted( extraRect.width() - h - 8, h / 2, -8, -h / 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() ) );
|
painter->drawPixmap( playIconRect, ImageRegistry::instance()->pixmap( RESPATH "images/play.svg", playIconRect.size() ) );
|
||||||
@@ -876,3 +885,28 @@ PlaylistItemDelegate::doUpdateIndex( const QPersistentModelIndex& index )
|
|||||||
if ( index.isValid() )
|
if ( index.isValid() )
|
||||||
emit updateIndex( index );
|
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();
|
||||||
|
}
|
||||||
|
@@ -108,6 +108,9 @@ protected:
|
|||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
virtual void modelChanged();
|
virtual void modelChanged();
|
||||||
|
virtual void onAudioEngineTick( qint64 ms );
|
||||||
|
virtual void onPlaybackStarted();
|
||||||
|
virtual void onPlaybackStopped();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mutable QHash< QPersistentModelIndex, QSharedPointer< Tomahawk::PixmapDelegateFader > > m_pixmaps;
|
mutable QHash< QPersistentModelIndex, QSharedPointer< Tomahawk::PixmapDelegateFader > > m_pixmaps;
|
||||||
@@ -117,6 +120,7 @@ private:
|
|||||||
mutable QHash< QPersistentModelIndex, QHash< Tomahawk::source_ptr, QRect > > m_avatarBoxRects;
|
mutable QHash< QPersistentModelIndex, QHash< Tomahawk::source_ptr, QRect > > m_avatarBoxRects;
|
||||||
QPersistentModelIndex m_hoveringOver;
|
QPersistentModelIndex m_hoveringOver;
|
||||||
QPersistentModelIndex m_hoveringOverArtist;
|
QPersistentModelIndex m_hoveringOverArtist;
|
||||||
|
mutable QPersistentModelIndex m_nowPlaying;
|
||||||
|
|
||||||
TrackView* m_view;
|
TrackView* m_view;
|
||||||
PlayableProxyModel* m_model;
|
PlayableProxyModel* m_model;
|
||||||
|
Reference in New Issue
Block a user