mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-13 20:39:57 +01:00
TWK-711: Some attica resolver icon fixes and optimizations. Don't write too much to disk
This commit is contained in:
parent
c9b0c92450
commit
f79ed86b57
@ -76,7 +76,10 @@ AtticaManager::loadPixmapsFromCache()
|
||||
}
|
||||
|
||||
QPixmap* icon = new QPixmap( cacheDir.absoluteFilePath( file ) );
|
||||
m_resolverStates[ info.baseName() ].pixmap = icon;
|
||||
if ( !icon->isNull() )
|
||||
{
|
||||
m_resolverStates[ info.baseName() ].pixmap = icon;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,14 +96,21 @@ AtticaManager::savePixmapsToCache()
|
||||
|
||||
foreach( const QString& id, m_resolverStates.keys() )
|
||||
{
|
||||
if ( !m_resolverStates[ id ].pixmap )
|
||||
if ( !m_resolverStates[ id ].pixmap || !m_resolverStates[ id ].pixmapDirty )
|
||||
continue;
|
||||
|
||||
const QString filename = cacheDir.absoluteFilePath( QString( "%1.png" ).arg( id ) );
|
||||
if ( !m_resolverStates[ id ].pixmap->save( filename ) )
|
||||
QFile f( filename );
|
||||
if ( !f.open( QIODevice::WriteOnly ) )
|
||||
{
|
||||
tLog() << "Failed to open cache file for writing:" << filename;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( !m_resolverStates[ id ].pixmap->save( &f ) )
|
||||
{
|
||||
tLog() << "Failed to save pixmap into opened file for writing:" << filename;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -247,6 +257,7 @@ AtticaManager::resolverIconFetched()
|
||||
QPixmap* icon = new QPixmap;
|
||||
icon->loadFromData( data );
|
||||
m_resolverStates[ resolverId ].pixmap = icon;
|
||||
m_resolverStates[ resolverId ].pixmapDirty = true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -52,9 +52,12 @@ public:
|
||||
ResolverState state;
|
||||
QPixmap* pixmap;
|
||||
|
||||
// internal
|
||||
bool pixmapDirty;
|
||||
|
||||
Resolver( const QString& v, const QString& path, int userR, ResolverState s )
|
||||
: version( v ), scriptPath( path ), userRating( userR ), state( s ), pixmap( 0 ) {}
|
||||
Resolver() : userRating( -1 ), state( Uninstalled ), pixmap( 0 ) {}
|
||||
: version( v ), scriptPath( path ), userRating( userR ), state( s ), pixmap( 0 ), pixmapDirty( false ) {}
|
||||
Resolver() : userRating( -1 ), state( Uninstalled ), pixmap( 0 ), pixmapDirty( false ) {}
|
||||
};
|
||||
|
||||
typedef QHash< QString, AtticaManager::Resolver > StateHash;
|
||||
|
Loading…
x
Reference in New Issue
Block a user