1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-12 09:04:33 +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
AtticaManager::hostname() const
{
@@ -368,19 +387,7 @@ AtticaManager::resolversList( BaseJob* j )
// load icon cache from disk, and fetch any we are missing
loadPixmapsFromCache();
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() ) );
}
}
fetchMissingIcons();
syncServerData();
@@ -673,6 +680,7 @@ AtticaManager::payloadFetched()
TomahawkSettings::instance()->addAccount( resolver->accountId() );
}
fetchMissingIcons();
installedSuccessfully = true;
}
}
@@ -717,6 +725,8 @@ AtticaManager::uninstallResolver( const QString& pathToResolver )
if ( resolver.id() == atticaId ) // this is the one
{
m_resolverStates[ atticaId ].state = Uninstalled;
delete m_resolverStates[ resolver.id() ].pixmap;
m_resolverStates[ atticaId ].pixmap = 0;
TomahawkSettingsGui::instanceGui()->setAtticaResolverState( atticaId, Uninstalled );
doResolverRemove( atticaId );
@@ -738,6 +748,9 @@ AtticaManager::uninstallResolver( const Content& resolver )
TomahawkSettingsGui::instanceGui()->setAtticaResolverState( resolver.id(), Uninstalled );
}
delete m_resolverStates[ resolver.id() ].pixmap;
m_resolverStates[ resolver.id() ].pixmap = 0;
doResolverRemove( resolver.id() );
}

View File

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