From 181d4c938da787bea6f1f7b139d1cf98e98f619c Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Tue, 18 Sep 2012 17:50:55 -0400 Subject: [PATCH] Re-fetch icon when upgrading to avoid requiring a restart --- src/libtomahawk/AtticaManager.cpp | 39 ++++++++++++++++++++----------- src/libtomahawk/AtticaManager.h | 1 + 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/libtomahawk/AtticaManager.cpp b/src/libtomahawk/AtticaManager.cpp index a30daa308..9cf0737e0 100644 --- a/src/libtomahawk/AtticaManager.cpp +++ b/src/libtomahawk/AtticaManager.cpp @@ -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() ); } diff --git a/src/libtomahawk/AtticaManager.h b/src/libtomahawk/AtticaManager.h index 6271f37c7..5a8bd1532 100644 --- a/src/libtomahawk/AtticaManager.h +++ b/src/libtomahawk/AtticaManager.h @@ -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;