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