1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-18 11:51:44 +02:00

change loading animation, show animation while resolving a playlist

This commit is contained in:
Leo Franchi
2011-04-04 18:43:51 -04:00
parent 9cc74abccc
commit 806b3a3281
6 changed files with 30 additions and 8 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@@ -81,7 +81,7 @@ LoadingSpinner::hideFinished()
QSize
LoadingSpinner::sizeHint() const
{
return QSize( 64, 64 );
return QSize( 31, 31 );
}
void
@@ -99,7 +99,7 @@ LoadingSpinner::reposition()
int x = ( parentWidget()->width() / 2 ) - ( width() / 2 );
int y = ( parentWidget()->height() / 2 ) - ( height() / 2 );
move( x, y );
resize( 64, 64 );
resize( 31, 31 );
}

View File

@@ -95,9 +95,9 @@ PlaylistModel::loadPlaylist( const Tomahawk::playlist_ptr& playlist, bool loadEn
int c = rowCount( QModelIndex() );
qDebug() << "Starting loading" << playlist->title();
emit loadingStarts();
emit beginInsertRows( QModelIndex(), c, c + entries.count() - 1 );
m_waitingForResolved.clear();
foreach( const plentry_ptr& entry, entries )
{
qDebug() << entry->query()->toString();
@@ -105,6 +105,11 @@ PlaylistModel::loadPlaylist( const Tomahawk::playlist_ptr& playlist, bool loadEn
plitem->index = createIndex( m_rootItem->children.count() - 1, 0, plitem );
connect( plitem, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) );
if( !entry->query()->resolvingFinished() ) {
m_waitingForResolved.append( entry->query().data() );
connect( entry->query().data(), SIGNAL( resolvingFinished( bool ) ), this, SLOT( trackResolved( bool ) ) );
}
}
emit endInsertRows();
@@ -112,7 +117,9 @@ PlaylistModel::loadPlaylist( const Tomahawk::playlist_ptr& playlist, bool loadEn
else
qDebug() << "Playlist seems empty:" << playlist->title();
emit loadingFinished();
if( !m_waitingForResolved.isEmpty() )
emit loadingStarted();
emit trackCountChanged( rowCount( QModelIndex() ) );
}
@@ -203,6 +210,18 @@ PlaylistModel::insert( unsigned int row, const Tomahawk::query_ptr& query )
onTracksInserted( row, ql );
}
void
PlaylistModel::trackResolved( bool )
{
Tomahawk::Query* q = qobject_cast< Query* >( sender() );
Q_ASSERT( q );
m_waitingForResolved.removeAll( q );
if( m_waitingForResolved.isEmpty() )
emit loadingFinished();
}
void
PlaylistModel::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks )

View File

@@ -70,10 +70,6 @@ signals:
void shuffleModeChanged( bool enabled );
void itemSizeChanged( const QModelIndex& index );
void loadingStarts();
void loadingFinished();
private slots:
void onDataChanged();
@@ -83,11 +79,13 @@ private slots:
void onTracksAdded( const QList<Tomahawk::query_ptr>& tracks );
void onTracksInserted( unsigned int row, const QList<Tomahawk::query_ptr>& tracks );
void trackResolved( bool );
private:
QList<Tomahawk::plentry_ptr> playlistEntries() const;
Tomahawk::playlist_ptr m_playlist;
bool m_waitForUpdate;
QList< Tomahawk::Query* > m_waitingForResolved;
};
#endif // PLAYLISTMODEL_H

View File

@@ -45,6 +45,7 @@ Query::get( const QString& artist, const QString& track, const QString& album, c
Query::Query( const QString& artist, const QString& track, const QString& album, const QID& qid )
: m_solved( false )
, m_playable( false )
, m_resolveFinished( false )
, m_qid( qid )
, m_artist( artist )
, m_album( album )
@@ -114,6 +115,7 @@ void
Query::onResolvingFinished()
{
// qDebug() << Q_FUNC_INFO << "Finished resolving." << toString();
m_resolveFinished = true;
emit resolvingFinished( m_solved );
}

View File

@@ -64,6 +64,8 @@ public:
/// true when any result has been found (score may be less than 1.0)
bool playable() const { return m_playable; }
bool resolvingFinished() const { return m_resolveFinished; }
unsigned int lastPipelineWeight() const { return m_lastpipelineweight; }
void setLastPipelineWeight( unsigned int w ) { m_lastpipelineweight = w; }
@@ -108,6 +110,7 @@ private:
QList< Tomahawk::result_ptr > m_results;
bool m_solved;
bool m_playable;
bool m_resolveFinished;
mutable QID m_qid;
unsigned int m_lastpipelineweight;