1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-14 10:05:32 +02:00

Re-fetch icon when upgrading to avoid requiring a restart

This commit is contained in:
Leo Franchi
2012-09-18 17:50:55 -04:00
parent f792efe275
commit 181d4c938d
2 changed files with 27 additions and 13 deletions

View File

@@ -93,6 +93,25 @@ AtticaManager::~AtticaManager()
} }
void
AtticaManager::fetchMissingIcons()
{
foreach ( Content resolver, m_resolvers )
{
if ( !m_resolverStates.contains( resolver.id() ) )
m_resolverStates.insert( resolver.id(), Resolver() );
if ( !m_resolverStates.value( resolver.id() ).pixmap && !resolver.icons().isEmpty() && !resolver.icons().first().url().isEmpty() )
{
QNetworkReply* fetch = TomahawkUtils::nam()->get( QNetworkRequest( resolver.icons().first().url() ) );
fetch->setProperty( "resolverId", resolver.id() );
connect( fetch, SIGNAL( finished() ), this, SLOT( resolverIconFetched() ) );
}
}
}
QString QString
AtticaManager::hostname() const AtticaManager::hostname() const
{ {
@@ -368,19 +387,7 @@ AtticaManager::resolversList( BaseJob* j )
// load icon cache from disk, and fetch any we are missing // load icon cache from disk, and fetch any we are missing
loadPixmapsFromCache(); loadPixmapsFromCache();
foreach ( Content resolver, m_resolvers ) fetchMissingIcons();
{
if ( !m_resolverStates.contains( resolver.id() ) )
m_resolverStates.insert( resolver.id(), Resolver() );
if ( !m_resolverStates.value( resolver.id() ).pixmap && !resolver.icons().isEmpty() && !resolver.icons().first().url().isEmpty() )
{
QNetworkReply* fetch = TomahawkUtils::nam()->get( QNetworkRequest( resolver.icons().first().url() ) );
fetch->setProperty( "resolverId", resolver.id() );
connect( fetch, SIGNAL( finished() ), this, SLOT( resolverIconFetched() ) );
}
}
syncServerData(); syncServerData();
@@ -673,6 +680,7 @@ AtticaManager::payloadFetched()
TomahawkSettings::instance()->addAccount( resolver->accountId() ); TomahawkSettings::instance()->addAccount( resolver->accountId() );
} }
fetchMissingIcons();
installedSuccessfully = true; installedSuccessfully = true;
} }
} }
@@ -717,6 +725,8 @@ AtticaManager::uninstallResolver( const QString& pathToResolver )
if ( resolver.id() == atticaId ) // this is the one if ( resolver.id() == atticaId ) // this is the one
{ {
m_resolverStates[ atticaId ].state = Uninstalled; m_resolverStates[ atticaId ].state = Uninstalled;
delete m_resolverStates[ resolver.id() ].pixmap;
m_resolverStates[ atticaId ].pixmap = 0;
TomahawkSettingsGui::instanceGui()->setAtticaResolverState( atticaId, Uninstalled ); TomahawkSettingsGui::instanceGui()->setAtticaResolverState( atticaId, Uninstalled );
doResolverRemove( atticaId ); doResolverRemove( atticaId );
@@ -738,6 +748,9 @@ AtticaManager::uninstallResolver( const Content& resolver )
TomahawkSettingsGui::instanceGui()->setAtticaResolverState( resolver.id(), Uninstalled ); TomahawkSettingsGui::instanceGui()->setAtticaResolverState( resolver.id(), Uninstalled );
} }
delete m_resolverStates[ resolver.id() ].pixmap;
m_resolverStates[ resolver.id() ].pixmap = 0;
doResolverRemove( resolver.id() ); doResolverRemove( resolver.id() );
} }

View File

@@ -144,6 +144,7 @@ private slots:
private: private:
void doResolverRemove( const QString& id ) const; void doResolverRemove( const QString& id ) const;
void doInstallResolver( const Attica::Content& resolver, bool autoCreate, Tomahawk::Accounts::AtticaResolverAccount* handler ); void doInstallResolver( const Attica::Content& resolver, bool autoCreate, Tomahawk::Accounts::AtticaResolverAccount* handler );
void fetchMissingIcons();
QString hostname() const; QString hostname() const;
Attica::ProviderManager m_manager; Attica::ProviderManager m_manager;