mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-20 04:41:36 +02:00
change loading animation, show animation while resolving a playlist
This commit is contained in:
Binary file not shown.
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 2.5 KiB |
@@ -81,7 +81,7 @@ LoadingSpinner::hideFinished()
|
|||||||
QSize
|
QSize
|
||||||
LoadingSpinner::sizeHint() const
|
LoadingSpinner::sizeHint() const
|
||||||
{
|
{
|
||||||
return QSize( 64, 64 );
|
return QSize( 31, 31 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -99,7 +99,7 @@ LoadingSpinner::reposition()
|
|||||||
int x = ( parentWidget()->width() / 2 ) - ( width() / 2 );
|
int x = ( parentWidget()->width() / 2 ) - ( width() / 2 );
|
||||||
int y = ( parentWidget()->height() / 2 ) - ( height() / 2 );
|
int y = ( parentWidget()->height() / 2 ) - ( height() / 2 );
|
||||||
move( x, y );
|
move( x, y );
|
||||||
resize( 64, 64 );
|
resize( 31, 31 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -95,9 +95,9 @@ PlaylistModel::loadPlaylist( const Tomahawk::playlist_ptr& playlist, bool loadEn
|
|||||||
int c = rowCount( QModelIndex() );
|
int c = rowCount( QModelIndex() );
|
||||||
|
|
||||||
qDebug() << "Starting loading" << playlist->title();
|
qDebug() << "Starting loading" << playlist->title();
|
||||||
emit loadingStarts();
|
|
||||||
emit beginInsertRows( QModelIndex(), c, c + entries.count() - 1 );
|
emit beginInsertRows( QModelIndex(), c, c + entries.count() - 1 );
|
||||||
|
|
||||||
|
m_waitingForResolved.clear();
|
||||||
foreach( const plentry_ptr& entry, entries )
|
foreach( const plentry_ptr& entry, entries )
|
||||||
{
|
{
|
||||||
qDebug() << entry->query()->toString();
|
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 );
|
plitem->index = createIndex( m_rootItem->children.count() - 1, 0, plitem );
|
||||||
|
|
||||||
connect( plitem, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) );
|
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();
|
emit endInsertRows();
|
||||||
@@ -112,7 +117,9 @@ PlaylistModel::loadPlaylist( const Tomahawk::playlist_ptr& playlist, bool loadEn
|
|||||||
else
|
else
|
||||||
qDebug() << "Playlist seems empty:" << playlist->title();
|
qDebug() << "Playlist seems empty:" << playlist->title();
|
||||||
|
|
||||||
emit loadingFinished();
|
if( !m_waitingForResolved.isEmpty() )
|
||||||
|
emit loadingStarted();
|
||||||
|
|
||||||
emit trackCountChanged( rowCount( QModelIndex() ) );
|
emit trackCountChanged( rowCount( QModelIndex() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,6 +210,18 @@ PlaylistModel::insert( unsigned int row, const Tomahawk::query_ptr& query )
|
|||||||
onTracksInserted( row, ql );
|
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
|
void
|
||||||
PlaylistModel::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks )
|
PlaylistModel::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks )
|
||||||
|
@@ -70,10 +70,6 @@ signals:
|
|||||||
void shuffleModeChanged( bool enabled );
|
void shuffleModeChanged( bool enabled );
|
||||||
|
|
||||||
void itemSizeChanged( const QModelIndex& index );
|
void itemSizeChanged( const QModelIndex& index );
|
||||||
|
|
||||||
void loadingStarts();
|
|
||||||
void loadingFinished();
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onDataChanged();
|
void onDataChanged();
|
||||||
|
|
||||||
@@ -83,11 +79,13 @@ private slots:
|
|||||||
void onTracksAdded( const QList<Tomahawk::query_ptr>& tracks );
|
void onTracksAdded( const QList<Tomahawk::query_ptr>& tracks );
|
||||||
void onTracksInserted( unsigned int row, const QList<Tomahawk::query_ptr>& tracks );
|
void onTracksInserted( unsigned int row, const QList<Tomahawk::query_ptr>& tracks );
|
||||||
|
|
||||||
|
void trackResolved( bool );
|
||||||
private:
|
private:
|
||||||
QList<Tomahawk::plentry_ptr> playlistEntries() const;
|
QList<Tomahawk::plentry_ptr> playlistEntries() const;
|
||||||
|
|
||||||
Tomahawk::playlist_ptr m_playlist;
|
Tomahawk::playlist_ptr m_playlist;
|
||||||
bool m_waitForUpdate;
|
bool m_waitForUpdate;
|
||||||
|
QList< Tomahawk::Query* > m_waitingForResolved;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PLAYLISTMODEL_H
|
#endif // PLAYLISTMODEL_H
|
||||||
|
@@ -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 )
|
Query::Query( const QString& artist, const QString& track, const QString& album, const QID& qid )
|
||||||
: m_solved( false )
|
: m_solved( false )
|
||||||
, m_playable( false )
|
, m_playable( false )
|
||||||
|
, m_resolveFinished( false )
|
||||||
, m_qid( qid )
|
, m_qid( qid )
|
||||||
, m_artist( artist )
|
, m_artist( artist )
|
||||||
, m_album( album )
|
, m_album( album )
|
||||||
@@ -114,6 +115,7 @@ void
|
|||||||
Query::onResolvingFinished()
|
Query::onResolvingFinished()
|
||||||
{
|
{
|
||||||
// qDebug() << Q_FUNC_INFO << "Finished resolving." << toString();
|
// qDebug() << Q_FUNC_INFO << "Finished resolving." << toString();
|
||||||
|
m_resolveFinished = true;
|
||||||
emit resolvingFinished( m_solved );
|
emit resolvingFinished( m_solved );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -64,6 +64,8 @@ public:
|
|||||||
/// true when any result has been found (score may be less than 1.0)
|
/// true when any result has been found (score may be less than 1.0)
|
||||||
bool playable() const { return m_playable; }
|
bool playable() const { return m_playable; }
|
||||||
|
|
||||||
|
bool resolvingFinished() const { return m_resolveFinished; }
|
||||||
|
|
||||||
unsigned int lastPipelineWeight() const { return m_lastpipelineweight; }
|
unsigned int lastPipelineWeight() const { return m_lastpipelineweight; }
|
||||||
void setLastPipelineWeight( unsigned int w ) { m_lastpipelineweight = w; }
|
void setLastPipelineWeight( unsigned int w ) { m_lastpipelineweight = w; }
|
||||||
|
|
||||||
@@ -108,6 +110,7 @@ private:
|
|||||||
QList< Tomahawk::result_ptr > m_results;
|
QList< Tomahawk::result_ptr > m_results;
|
||||||
bool m_solved;
|
bool m_solved;
|
||||||
bool m_playable;
|
bool m_playable;
|
||||||
|
bool m_resolveFinished;
|
||||||
mutable QID m_qid;
|
mutable QID m_qid;
|
||||||
unsigned int m_lastpipelineweight;
|
unsigned int m_lastpipelineweight;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user