mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-17 11:30:49 +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() )
|
if ( collection().isNull() )
|
||||||
{
|
{
|
||||||
const ExternalResolverGui* guiResolver = qobject_cast< ExternalResolverGui* >( m_resolvedBy.data() );
|
const ExternalResolver* resolver = qobject_cast< ExternalResolver* >( m_resolvedBy.data() );
|
||||||
if ( !guiResolver )
|
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();
|
return QPixmap();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -388,7 +390,7 @@ Result::sourceIcon( TomahawkUtils::ImageMode style, const QSize& desiredSize ) c
|
|||||||
const QString key = sourceCacheKey( m_resolvedBy.data(), desiredSize, style );
|
const QString key = sourceCacheKey( m_resolvedBy.data(), desiredSize, style );
|
||||||
if ( !sourceIconCache()->contains( key ) )
|
if ( !sourceIconCache()->contains( key ) )
|
||||||
{
|
{
|
||||||
QPixmap pixmap = guiResolver->icon();
|
QPixmap pixmap = resolver->icon();
|
||||||
if ( !desiredSize.isEmpty() )
|
if ( !desiredSize.isEmpty() )
|
||||||
pixmap = pixmap.scaled( desiredSize, Qt::KeepAspectRatio, Qt::SmoothTransformation );
|
pixmap = pixmap.scaled( desiredSize, Qt::KeepAspectRatio, Qt::SmoothTransformation );
|
||||||
|
|
||||||
|
@@ -79,6 +79,8 @@ public:
|
|||||||
{ m_filePath = filePath; }
|
{ m_filePath = filePath; }
|
||||||
|
|
||||||
virtual QString filePath() const { return m_filePath; }
|
virtual QString filePath() const { return m_filePath; }
|
||||||
|
virtual QPixmap icon() const { return QPixmap(); }
|
||||||
|
virtual void setIcon( const QPixmap& ) {}
|
||||||
|
|
||||||
virtual void saveConfig() = 0;
|
virtual void saveConfig() = 0;
|
||||||
|
|
||||||
|
@@ -44,9 +44,6 @@ public:
|
|||||||
ExternalResolverGui( const QString& filePath );
|
ExternalResolverGui( const QString& filePath );
|
||||||
virtual AccountConfigWidget* configUI() const = 0;
|
virtual AccountConfigWidget* configUI() const = 0;
|
||||||
|
|
||||||
virtual QPixmap icon() const { return QPixmap(); }
|
|
||||||
virtual void setIcon( const QPixmap& ) {}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
AccountConfigWidget* widgetFromData( QByteArray& data, QWidget* parent = 0 );
|
AccountConfigWidget* widgetFromData( QByteArray& data, QWidget* parent = 0 );
|
||||||
QVariant configMsgFromWidget( QWidget* w );
|
QVariant configMsgFromWidget( QWidget* w );
|
||||||
|
@@ -38,18 +38,12 @@ ScriptCollection::ScriptCollection( const source_ptr& source,
|
|||||||
: Collection( source, QString( "scriptcollection:" + resolver->name() + ":" + uuid() ), parent )
|
: Collection( source, QString( "scriptcollection:" + resolver->name() + ":" + uuid() ), parent )
|
||||||
, m_trackCount( -1 ) //null value
|
, m_trackCount( -1 ) //null value
|
||||||
{
|
{
|
||||||
Q_ASSERT( resolver != 0 );
|
Q_ASSERT( resolver );
|
||||||
qDebug() << Q_FUNC_INFO << resolver->name() << name();
|
qDebug() << Q_FUNC_INFO << resolver->name() << name();
|
||||||
|
|
||||||
m_resolver = resolver;
|
m_resolver = resolver;
|
||||||
|
|
||||||
m_servicePrettyName = m_resolver->name();
|
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
|
QIcon
|
||||||
ScriptCollection::icon() const
|
ScriptCollection::icon() const
|
||||||
{
|
{
|
||||||
|
if( !m_icon.isNull() )
|
||||||
return m_icon;
|
return m_icon;
|
||||||
|
|
||||||
|
return m_resolver->icon();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user