mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-16 02:54:33 +02:00
Move icon() from ExternalResolverGui to ExternalResolver to make ScriptCollection "GUI-less"
This commit is contained in:
@@ -376,9 +376,11 @@ Result::sourceIcon( TomahawkUtils::ImageMode style, const QSize& desiredSize ) c
|
||||
{
|
||||
if ( collection().isNull() )
|
||||
{
|
||||
const ExternalResolverGui* guiResolver = qobject_cast< ExternalResolverGui* >( m_resolvedBy.data() );
|
||||
if ( !guiResolver )
|
||||
const ExternalResolver* resolver = qobject_cast< ExternalResolver* >( m_resolvedBy.data() );
|
||||
if ( !resolver )
|
||||
{
|
||||
tLog() << "Result was not resolved by an ExternalResolver but the collection is empty too. What is going on?";
|
||||
Q_ASSERT( resolver );
|
||||
return QPixmap();
|
||||
}
|
||||
else
|
||||
@@ -388,7 +390,7 @@ Result::sourceIcon( TomahawkUtils::ImageMode style, const QSize& desiredSize ) c
|
||||
const QString key = sourceCacheKey( m_resolvedBy.data(), desiredSize, style );
|
||||
if ( !sourceIconCache()->contains( key ) )
|
||||
{
|
||||
QPixmap pixmap = guiResolver->icon();
|
||||
QPixmap pixmap = resolver->icon();
|
||||
if ( !desiredSize.isEmpty() )
|
||||
pixmap = pixmap.scaled( desiredSize, Qt::KeepAspectRatio, Qt::SmoothTransformation );
|
||||
|
||||
|
@@ -79,6 +79,8 @@ public:
|
||||
{ m_filePath = filePath; }
|
||||
|
||||
virtual QString filePath() const { return m_filePath; }
|
||||
virtual QPixmap icon() const { return QPixmap(); }
|
||||
virtual void setIcon( const QPixmap& ) {}
|
||||
|
||||
virtual void saveConfig() = 0;
|
||||
|
||||
|
@@ -44,9 +44,6 @@ public:
|
||||
ExternalResolverGui( const QString& filePath );
|
||||
virtual AccountConfigWidget* configUI() const = 0;
|
||||
|
||||
virtual QPixmap icon() const { return QPixmap(); }
|
||||
virtual void setIcon( const QPixmap& ) {}
|
||||
|
||||
protected:
|
||||
AccountConfigWidget* widgetFromData( QByteArray& data, QWidget* parent = 0 );
|
||||
QVariant configMsgFromWidget( QWidget* w );
|
||||
|
@@ -38,18 +38,12 @@ ScriptCollection::ScriptCollection( const source_ptr& source,
|
||||
: Collection( source, QString( "scriptcollection:" + resolver->name() + ":" + uuid() ), parent )
|
||||
, m_trackCount( -1 ) //null value
|
||||
{
|
||||
Q_ASSERT( resolver != 0 );
|
||||
Q_ASSERT( resolver );
|
||||
qDebug() << Q_FUNC_INFO << resolver->name() << name();
|
||||
|
||||
m_resolver = resolver;
|
||||
|
||||
m_servicePrettyName = m_resolver->name();
|
||||
|
||||
ExternalResolverGui* gResolver = qobject_cast< ExternalResolverGui* >( m_resolver );
|
||||
if ( gResolver )
|
||||
{
|
||||
m_icon = gResolver->icon();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -93,7 +87,10 @@ ScriptCollection::setIcon( const QIcon& icon )
|
||||
QIcon
|
||||
ScriptCollection::icon() const
|
||||
{
|
||||
return m_icon;
|
||||
if( !m_icon.isNull() )
|
||||
return m_icon;
|
||||
|
||||
return m_resolver->icon();
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user