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

Show a loading spinner in album views so sourceinfopages etc don't look white for a few seconds

This commit is contained in:
Leo Franchi
2011-11-01 20:00:52 -04:00
parent 11779e2037
commit d442c2158a
6 changed files with 23 additions and 4 deletions

View File

@@ -254,6 +254,8 @@ AlbumModel::addCollection( const collection_ptr& collection, bool overwrite )
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) ); Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
m_title = tr( "All albums from %1" ).arg( collection->source()->friendlyName() ); m_title = tr( "All albums from %1" ).arg( collection->source()->friendlyName() );
emit loadingStarted();
} }
@@ -280,6 +282,8 @@ AlbumModel::addFilteredCollection( const collection_ptr& collection, unsigned in
m_title = tr( "All albums from %1" ).arg( collection->source()->friendlyName() ); m_title = tr( "All albums from %1" ).arg( collection->source()->friendlyName() );
else else
m_title = tr( "All albums" ); m_title = tr( "All albums" );
emit loadingStarted();
} }
@@ -292,6 +296,8 @@ AlbumModel::addAlbums( const QList<Tomahawk::album_ptr>& albums )
if ( m_overwriteOnAdd ) if ( m_overwriteOnAdd )
clear(); clear();
emit loadingFinished();
int c = rowCount( QModelIndex() ); int c = rowCount( QModelIndex() );
QPair< int, int > crows; QPair< int, int > crows;
crows.first = c; crows.first = c;

View File

@@ -94,6 +94,8 @@ signals:
void trackCountChanged( unsigned int tracks ); void trackCountChanged( unsigned int tracks );
void loadingStarted();
void loadingFinished();
private slots: private slots:
void onDataChanged(); void onDataChanged();

View File

@@ -32,6 +32,7 @@
#include "albummodel.h" #include "albummodel.h"
#include "viewmanager.h" #include "viewmanager.h"
#include "utils/logger.h" #include "utils/logger.h"
#include "dynamic/widgets/LoadingSpinner.h"
#define SCROLL_TIMEOUT 280 #define SCROLL_TIMEOUT 280
@@ -42,7 +43,7 @@ AlbumView::AlbumView( QWidget* parent )
: QListView( parent ) : QListView( parent )
, m_model( 0 ) , m_model( 0 )
, m_proxyModel( 0 ) , m_proxyModel( 0 )
// , m_delegate( 0 ) , m_loadingSpinner( new LoadingSpinner( this ) )
{ {
setDragEnabled( true ); setDragEnabled( true );
setDropIndicatorShown( false ); setDropIndicatorShown( false );
@@ -109,6 +110,9 @@ AlbumView::setAlbumModel( AlbumModel* model )
connect( m_proxyModel, SIGNAL( filterChanged( QString ) ), SLOT( onFilterChanged( QString ) ) ); connect( m_proxyModel, SIGNAL( filterChanged( QString ) ), SLOT( onFilterChanged( QString ) ) );
connect( m_proxyModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), SLOT( onViewChanged() ) ); connect( m_proxyModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), SLOT( onViewChanged() ) );
connect( m_model, SIGNAL( loadingStarted() ), m_loadingSpinner, SLOT( fadeIn() ) );
connect( m_model, SIGNAL( loadingFinished() ), m_loadingSpinner, SLOT( fadeOut() ) );
setAcceptDrops( false ); setAcceptDrops( false );
onViewChanged(); // Fetch covers if albums were added to model before model was attached to view onViewChanged(); // Fetch covers if albums were added to model before model was attached to view
} }

View File

@@ -28,6 +28,7 @@
#include "albumproxymodel.h" #include "albumproxymodel.h"
class AlbumModel; class AlbumModel;
class LoadingSpinner;
class DLLEXPORT AlbumView : public QListView, public Tomahawk::ViewPage class DLLEXPORT AlbumView : public QListView, public Tomahawk::ViewPage
{ {
@@ -74,7 +75,7 @@ private slots:
private: private:
AlbumModel* m_model; AlbumModel* m_model;
AlbumProxyModel* m_proxyModel; AlbumProxyModel* m_proxyModel;
// PlaylistItemDelegate* m_delegate; LoadingSpinner* m_loadingSpinner;
QTimer m_timer; QTimer m_timer;
}; };

View File

@@ -1,6 +1,6 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> === /* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
* *
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org> * Copyright 2010 Leo Franchi <lfranchi@kde.org>
* *
* Tomahawk is free software: you can redistribute it and/or modify * Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -58,6 +58,9 @@ LoadingSpinner::~LoadingSpinner()
void void
LoadingSpinner::fadeIn() LoadingSpinner::fadeIn()
{ {
if ( isVisible() )
return;
show(); show();
m_anim->start(); m_anim->start();
@@ -71,6 +74,9 @@ LoadingSpinner::fadeIn()
void void
LoadingSpinner::fadeOut() LoadingSpinner::fadeOut()
{ {
if ( !isVisible() )
return;
m_showHide->setDirection( QTimeLine::Backward ); m_showHide->setDirection( QTimeLine::Backward );
if ( m_showHide->state() != QTimeLine::Running ) if ( m_showHide->state() != QTimeLine::Running )

View File

@@ -1,6 +1,6 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> === /* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
* *
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org> * Copyright 2010 Leo Franchi <lfranchi@kde.org>
* *
* Tomahawk is free software: you can redistribute it and/or modify * Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by