1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-20 07:49:42 +01: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 ) );
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() );
else
m_title = tr( "All albums" );
emit loadingStarted();
}
@ -292,6 +296,8 @@ AlbumModel::addAlbums( const QList<Tomahawk::album_ptr>& albums )
if ( m_overwriteOnAdd )
clear();
emit loadingFinished();
int c = rowCount( QModelIndex() );
QPair< int, int > crows;
crows.first = c;

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
/* === 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
* it under the terms of the GNU General Public License as published by
@ -58,6 +58,9 @@ LoadingSpinner::~LoadingSpinner()
void
LoadingSpinner::fadeIn()
{
if ( isVisible() )
return;
show();
m_anim->start();
@ -71,6 +74,9 @@ LoadingSpinner::fadeIn()
void
LoadingSpinner::fadeOut()
{
if ( !isVisible() )
return;
m_showHide->setDirection( QTimeLine::Backward );
if ( m_showHide->state() != QTimeLine::Running )

View File

@ -1,6 +1,6 @@
/* === 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
* it under the terms of the GNU General Public License as published by