From 7f73c073be6a015a6d2ecff9a5a200fc788bd0e1 Mon Sep 17 00:00:00 2001 From: Teo Mrnjavac Date: Sat, 26 Jan 2013 00:11:52 +0100 Subject: [PATCH] Fix collection page icons. --- src/libtomahawk/Collection.cpp | 9 +++++++ src/libtomahawk/Collection.h | 1 + src/libtomahawk/database/LocalCollection.cpp | 1 + src/libtomahawk/playlist/TreeModel.cpp | 3 +-- .../resolvers/ScriptCollection.cpp | 27 +++++++++++++++++++ src/libtomahawk/resolvers/ScriptCollection.h | 1 + 6 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/libtomahawk/Collection.cpp b/src/libtomahawk/Collection.cpp index 06d4a98bc..c0851f7c2 100644 --- a/src/libtomahawk/Collection.cpp +++ b/src/libtomahawk/Collection.cpp @@ -78,6 +78,15 @@ Collection::icon() const } +QPixmap +Collection::bigIcon() const +{ + if ( !source()->avatar().isNull() ) + return source()->avatar( TomahawkUtils::RoundedCorners ); + return TomahawkUtils::defaultPixmap( TomahawkUtils::SuperCollection ); +} + + QString Collection::emptyText() const { diff --git a/src/libtomahawk/Collection.h b/src/libtomahawk/Collection.h index b3ed5b07e..4fcba22b8 100644 --- a/src/libtomahawk/Collection.h +++ b/src/libtomahawk/Collection.h @@ -55,6 +55,7 @@ public: virtual QString itemName() const; virtual QString type() const { return QString(); } virtual QIcon icon() const; + virtual QPixmap bigIcon() const; //for the ViewPage header virtual QString emptyText() const; virtual void loadPlaylists() { qDebug() << Q_FUNC_INFO; } diff --git a/src/libtomahawk/database/LocalCollection.cpp b/src/libtomahawk/database/LocalCollection.cpp index 0448aa5f4..2a1d8979e 100644 --- a/src/libtomahawk/database/LocalCollection.cpp +++ b/src/libtomahawk/database/LocalCollection.cpp @@ -23,6 +23,7 @@ #include "SourceList.h" #include #include "utils/Logger.h" +#include "utils/TomahawkUtilsGui.h" #ifndef ENABLE_HEADLESS #include "ViewManager.h" diff --git a/src/libtomahawk/playlist/TreeModel.cpp b/src/libtomahawk/playlist/TreeModel.cpp index 2c6ce8cb1..ee6d2203d 100644 --- a/src/libtomahawk/playlist/TreeModel.cpp +++ b/src/libtomahawk/playlist/TreeModel.cpp @@ -259,8 +259,7 @@ TreeModel::addCollection( const collection_ptr& collection ) connect( collection.data(), SIGNAL( changed() ), SLOT( onCollectionChanged() ), Qt::UniqueConnection ); - if ( !collection->source()->avatar().isNull() ) - setIcon( collection->source()->avatar( TomahawkUtils::RoundedCorners ) ); + setIcon( collection->bigIcon() ); setTitle( collection->prettyName() ); } diff --git a/src/libtomahawk/resolvers/ScriptCollection.cpp b/src/libtomahawk/resolvers/ScriptCollection.cpp index 89200d722..9ce06cca8 100644 --- a/src/libtomahawk/resolvers/ScriptCollection.cpp +++ b/src/libtomahawk/resolvers/ScriptCollection.cpp @@ -21,8 +21,10 @@ #include "Source.h" #include "ExternalResolverGui.h" +#include "utils/TomahawkUtilsGui.h" #include +#include using namespace Tomahawk; @@ -80,6 +82,31 @@ ScriptCollection::icon() const } +QPixmap +ScriptCollection::bigIcon() const +{ + QPixmap big = Collection::bigIcon(); + QPixmap base = icon().pixmap( big.size() ); + + if ( !source()->isLocal() ) + { + big = big.scaled( TomahawkUtils::defaultIconSize(), + Qt::KeepAspectRatio, + Qt::SmoothTransformation ); + + QPainter painter( &base ); + painter.drawPixmap( base.width() - big.width(), + base.height() - big.height(), + big.width(), + big.height(), + big ); + painter.end(); + } + + return base; +} + + void ScriptCollection::artists() { diff --git a/src/libtomahawk/resolvers/ScriptCollection.h b/src/libtomahawk/resolvers/ScriptCollection.h index 7c4c60ccd..00645ac4d 100644 --- a/src/libtomahawk/resolvers/ScriptCollection.h +++ b/src/libtomahawk/resolvers/ScriptCollection.h @@ -44,6 +44,7 @@ public: virtual QString itemName() const; virtual QString type() const { return "scriptcollection"; } virtual QIcon icon() const; + virtual QPixmap bigIcon() const; virtual ExternalResolver* resolver() { return m_resolver; }