|
|
|
@ -27,8 +27,6 @@
|
|
|
|
|
#include <QPainter>
|
|
|
|
|
#include <qicon.h>
|
|
|
|
|
|
|
|
|
|
#include "utils/Logger.h"
|
|
|
|
|
|
|
|
|
|
static QHash< QString, QHash< int, QHash< qint64, QPixmap > > > s_cache;
|
|
|
|
|
ImageRegistry* ImageRegistry::s_instance = 0;
|
|
|
|
|
|
|
|
|
@ -47,9 +45,9 @@ ImageRegistry::ImageRegistry()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QIcon
|
|
|
|
|
ImageRegistry::icon( const QString& image, TomahawkUtils::ImageMode mode )
|
|
|
|
|
ImageRegistry::icon( const QString& image, CalamaresUtils::ImageMode mode )
|
|
|
|
|
{
|
|
|
|
|
return pixmap( image, TomahawkUtils::defaultIconSize(), mode );
|
|
|
|
|
return pixmap( image, CalamaresUtils::defaultIconSize(), mode );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -61,7 +59,7 @@ ImageRegistry::cacheKey( const QSize& size, float opacity, QColor tint )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QPixmap
|
|
|
|
|
ImageRegistry::pixmap( const QString& image, const QSize& size, TomahawkUtils::ImageMode mode, float opacity, QColor tint )
|
|
|
|
|
ImageRegistry::pixmap( const QString& image, const QSize& size, CalamaresUtils::ImageMode mode, float opacity, QColor tint )
|
|
|
|
|
{
|
|
|
|
|
if ( size.width() < 0 || size.height() < 0 )
|
|
|
|
|
{
|
|
|
|
@ -102,7 +100,17 @@ ImageRegistry::pixmap( const QString& image, const QSize& size, TomahawkUtils::I
|
|
|
|
|
pixPainter.end();
|
|
|
|
|
|
|
|
|
|
if ( tint.alpha() > 0 )
|
|
|
|
|
p = TomahawkUtils::tinted( p, tint );
|
|
|
|
|
{
|
|
|
|
|
QImage resultImage( p.size(), QImage::Format_ARGB32_Premultiplied );
|
|
|
|
|
QPainter painter( &resultImage );
|
|
|
|
|
painter.drawPixmap( 0, 0, p );
|
|
|
|
|
painter.setCompositionMode( QPainter::CompositionMode_Screen );
|
|
|
|
|
painter.fillRect( resultImage.rect(), tint );
|
|
|
|
|
painter.end();
|
|
|
|
|
|
|
|
|
|
resultImage.setAlphaChannel( p.toImage().alphaChannel() );
|
|
|
|
|
p = QPixmap::fromImage( resultImage );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pixmap = p;
|
|
|
|
|
}
|
|
|
|
@ -113,8 +121,8 @@ ImageRegistry::pixmap( const QString& image, const QSize& size, TomahawkUtils::I
|
|
|
|
|
{
|
|
|
|
|
switch ( mode )
|
|
|
|
|
{
|
|
|
|
|
case TomahawkUtils::RoundedCorners:
|
|
|
|
|
pixmap = TomahawkUtils::createRoundedImage( pixmap, size );
|
|
|
|
|
case CalamaresUtils::RoundedCorners:
|
|
|
|
|
pixmap = CalamaresUtils::createRoundedImage( pixmap, size );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
@ -143,10 +151,8 @@ ImageRegistry::pixmap( const QString& image, const QSize& size, TomahawkUtils::I
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
ImageRegistry::putInCache( const QString& image, const QSize& size, TomahawkUtils::ImageMode mode, float opacity, const QPixmap& pixmap, QColor tint )
|
|
|
|
|
ImageRegistry::putInCache( const QString& image, const QSize& size, CalamaresUtils::ImageMode mode, float opacity, const QPixmap& pixmap, QColor tint )
|
|
|
|
|
{
|
|
|
|
|
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Adding to image cache:" << image << size << mode;
|
|
|
|
|
|
|
|
|
|
QHash< qint64, QPixmap > subsubcache;
|
|
|
|
|
QHash< int, QHash< qint64, QPixmap > > subcache;
|
|
|
|
|
|
|
|
|
|