mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-04-21 00:12:06 +02:00
* Make use of ImageRegistry.
This commit is contained in:
parent
454e645b92
commit
62247d464f
@ -49,6 +49,7 @@ namespace TomahawkUtils
|
||||
DefaultTrackImage,
|
||||
DefaultSourceAvatar,
|
||||
NowPlayingSpeaker,
|
||||
NowPlayingSpeakerDark,
|
||||
InfoIcon
|
||||
};
|
||||
|
||||
|
@ -19,12 +19,13 @@
|
||||
|
||||
#include "TomahawkUtilsGui.h"
|
||||
|
||||
#include "playlist/PlayableItem.h"
|
||||
#include "config.h"
|
||||
#include "Query.h"
|
||||
#include "Result.h"
|
||||
#include "Logger.h"
|
||||
#include "playlist/PlayableItem.h"
|
||||
#include "Source.h"
|
||||
#include "ImageRegistry.h"
|
||||
#include "Logger.h"
|
||||
|
||||
#include <QLayout>
|
||||
#include <QPainter>
|
||||
@ -402,58 +403,46 @@ QPixmap
|
||||
defaultPixmap( ImageType type, ImageMode mode, const QSize& size )
|
||||
{
|
||||
QPixmap pixmap;
|
||||
QHash< int, QPixmap > subsubcache;
|
||||
QHash< int, QHash< int, QPixmap > > subcache;
|
||||
static QHash< int, QHash< int, QHash< int, QPixmap > > > cache;
|
||||
|
||||
if ( cache.contains( type ) )
|
||||
{
|
||||
subcache = cache.value( type );
|
||||
|
||||
if ( subcache.contains( mode ) )
|
||||
{
|
||||
subsubcache = subcache.value( mode );
|
||||
|
||||
if ( subsubcache.contains( size.width() ) )
|
||||
return subsubcache.value( size.width() );
|
||||
}
|
||||
}
|
||||
|
||||
switch ( type )
|
||||
{
|
||||
case DefaultAlbumCover:
|
||||
if ( mode == CoverInCase )
|
||||
pixmap = QPixmap( RESPATH "images/no-album-art-placeholder.png" );
|
||||
pixmap = ImageRegistry::instance()->getFromCache( RESPATH "images/no-album-art-placeholder.png", size );
|
||||
else if ( mode == Grid )
|
||||
pixmap = QPixmap( RESPATH "images/album-placeholder-grid.png" );
|
||||
pixmap = ImageRegistry::instance()->getFromCache( RESPATH "images/album-placeholder-grid.png", size );
|
||||
else
|
||||
pixmap = QPixmap( RESPATH "images/no-album-no-case.png" );
|
||||
pixmap = ImageRegistry::instance()->getFromCache( RESPATH "images/no-album-no-case.png", size );
|
||||
break;
|
||||
|
||||
case DefaultArtistImage:
|
||||
if ( mode == Grid )
|
||||
pixmap = QPixmap( RESPATH "images/artist-placeholder-grid.png" );
|
||||
pixmap = ImageRegistry::instance()->getFromCache( RESPATH "images/artist-placeholder-grid.png", size );
|
||||
else
|
||||
pixmap = QPixmap( RESPATH "images/no-artist-image-placeholder.png" );
|
||||
pixmap = ImageRegistry::instance()->getFromCache( RESPATH "images/no-artist-image-placeholder.png", size );
|
||||
break;
|
||||
|
||||
case DefaultTrackImage:
|
||||
pixmap = QPixmap( RESPATH "images/track-placeholder.png" );
|
||||
pixmap = ImageRegistry::instance()->getFromCache( RESPATH "images/track-placeholder.png", size );
|
||||
break;
|
||||
|
||||
case DefaultSourceAvatar:
|
||||
if ( mode == RoundedCorners )
|
||||
pixmap = TomahawkUtils::createRoundedImage( QPixmap( RESPATH "images/user-avatar.png" ), size );
|
||||
pixmap = ImageRegistry::instance()->getFromCache( RESPATH "images/user-avatar.png", size, TomahawkUtils::RoundedCorners );
|
||||
else
|
||||
pixmap = QPixmap( RESPATH "images/user-avatar.png" );
|
||||
pixmap = ImageRegistry::instance()->getFromCache( RESPATH "images/user-avatar.png", size );
|
||||
break;
|
||||
|
||||
case NowPlayingSpeaker:
|
||||
pixmap = QPixmap( RESPATH "images/now-playing-speaker.png" );
|
||||
pixmap = ImageRegistry::instance()->getFromCache( RESPATH "images/now-playing-speaker.png", size );
|
||||
break;
|
||||
|
||||
case NowPlayingSpeakerDark:
|
||||
pixmap = ImageRegistry::instance()->getFromCache( RESPATH "images/now-playing-speaker-dark.png", size );
|
||||
break;
|
||||
|
||||
case InfoIcon:
|
||||
pixmap = QPixmap( RESPATH "images/info.png" );
|
||||
pixmap = ImageRegistry::instance()->getFromCache( RESPATH "images/info.png", size );
|
||||
|
||||
default:
|
||||
break;
|
||||
@ -465,13 +454,6 @@ defaultPixmap( ImageType type, ImageMode mode, const QSize& size )
|
||||
return QPixmap();
|
||||
}
|
||||
|
||||
if ( !size.isNull() )
|
||||
pixmap = pixmap.scaled( size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
|
||||
|
||||
subsubcache.insert( size.width(), pixmap );
|
||||
subcache.insert( mode, subsubcache );
|
||||
cache.insert( type, subcache );
|
||||
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ public:
|
||||
m_playlistIcon = QPixmap( RESPATH "images/playlist-icon.png" );
|
||||
m_autoIcon = QPixmap( RESPATH "images/automatic-playlist.png" );
|
||||
m_stationIcon = QPixmap( RESPATH "images/station.png" );
|
||||
m_defaultAvatar = TomahawkUtils::createRoundedImage( QPixmap( RESPATH "images/user-avatar.png" ), QSize( 0, 0 ) );
|
||||
m_defaultAvatar = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultSourceAvatar, TomahawkUtils::RoundedCorners );
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@ -72,8 +72,6 @@ SourceDelegate::SourceDelegate( QAbstractItemView* parent )
|
||||
m_headphonesOn.load( RESPATH "images/headphones-sidebar.png" );
|
||||
m_realtimeLocked.load( RESPATH "images/closed-padlock.png" );
|
||||
m_realtimeUnlocked.load( RESPATH "images/open-padlock.png" );
|
||||
m_nowPlayingSpeaker.load( RESPATH "images/now-playing-speaker.png" );
|
||||
m_nowPlayingSpeakerDark.load( RESPATH "images/now-playing-speaker-dark.png" );
|
||||
m_collaborativeOn.load( RESPATH "images/green-dot.png" );
|
||||
}
|
||||
|
||||
@ -149,8 +147,10 @@ SourceDelegate::paintDecorations( QPainter* painter, const QStyleOptionViewItem&
|
||||
}
|
||||
|
||||
QRect iconRect = QRect( 4, option.rect.y() + 2, iconW, iconW );
|
||||
QPixmap speaker = option.state & QStyle::State_Selected ? m_nowPlayingSpeaker : m_nowPlayingSpeakerDark;
|
||||
speaker = speaker.scaledToHeight( iconW, Qt::SmoothTransformation );
|
||||
QPixmap speaker = option.state & QStyle::State_Selected ?
|
||||
TomahawkUtils::defaultPixmap( TomahawkUtils::NowPlayingSpeaker, TomahawkUtils::Original, iconRect.size() ) :
|
||||
TomahawkUtils::defaultPixmap( TomahawkUtils::NowPlayingSpeakerDark, TomahawkUtils::Original, iconRect.size() );
|
||||
|
||||
painter->drawPixmap( iconRect, speaker );
|
||||
}
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ private:
|
||||
QMimeData* m_dropMimeData;
|
||||
mutable SourceTreeItem::DropType m_hoveredDropType; // Hack to keep easily track of the current highlighted DropType in paint()
|
||||
QMap< QModelIndex, AnimationHelper* > m_expandedMap;
|
||||
QPixmap m_headphonesOn, m_headphonesOff, m_realtimeLocked, m_realtimeUnlocked, m_nowPlayingSpeaker, m_nowPlayingSpeakerDark, m_collaborativeOn;
|
||||
QPixmap m_headphonesOn, m_headphonesOff, m_realtimeLocked, m_realtimeUnlocked, m_collaborativeOn;
|
||||
qint64 m_lastClicked;
|
||||
QMap< int, SourceTreeItem::DropType > m_dropTypeMap;
|
||||
QMap< int, QString > m_dropTypeTextMap;
|
||||
|
@ -25,16 +25,17 @@
|
||||
#include "Playlist.h"
|
||||
#include "GenericPageItems.h"
|
||||
#include "LovedTracksItem.h"
|
||||
#include "utils/TomahawkUtilsGui.h"
|
||||
#include "utils/Logger.h"
|
||||
#include "Source.h"
|
||||
#include "SourceList.h"
|
||||
#include "widgets/SocialPlaylistWidget.h"
|
||||
#include "playlist/FlexibleView.h"
|
||||
#include "playlist/PlaylistView.h"
|
||||
#include "playlist/RecentlyAddedModel.h"
|
||||
#include "playlist/RecentlyPlayedModel.h"
|
||||
#include "playlist/PlaylistLargeItemDelegate.h"
|
||||
#include "Source.h"
|
||||
#include "SourceList.h"
|
||||
#include "utils/ImageRegistry.h"
|
||||
#include "utils/TomahawkUtilsGui.h"
|
||||
#include "utils/Logger.h"
|
||||
|
||||
/// SourceItem
|
||||
|
||||
@ -104,8 +105,6 @@ SourceItem::SourceItem( SourcesModel* mdl, SourceTreeItem* parent, const Tomahaw
|
||||
/* if ( ViewManager::instance()->pageForCollection( source->collection() ) )
|
||||
model()->linkSourceItemToPage( this, ViewManager::instance()->pageForCollection( source->collection() ) );*/
|
||||
|
||||
m_defaultAvatar = TomahawkUtils::createRoundedImage( QPixmap( RESPATH "images/user-avatar.png" ), QSize( 0, 0 ) );
|
||||
|
||||
// load auto playlists and stations!
|
||||
|
||||
connect( source.data(), SIGNAL( stats( QVariantMap ) ), SIGNAL( updated() ) );
|
||||
@ -204,7 +203,7 @@ SourceItem::pixmap( const QSize& size ) const
|
||||
else
|
||||
{
|
||||
if ( m_source->avatar().isNull() )
|
||||
return m_defaultAvatar;
|
||||
return TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultSourceAvatar, TomahawkUtils::RoundedCorners );
|
||||
else
|
||||
return m_source->avatar( TomahawkUtils::RoundedCorners, size );
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ private:
|
||||
void playlistDeletedInternal( SourceTreeItem* parent, const T& playlists );
|
||||
|
||||
Tomahawk::source_ptr m_source;
|
||||
QPixmap m_superCol, m_defaultAvatar;
|
||||
QPixmap m_superCol;
|
||||
CategoryItem* m_playlists;
|
||||
CategoryItem* m_stations;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user