1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-04-21 08:21:54 +02:00

* ImageRegistry supports rendering SVGs now.

This commit is contained in:
Christian Muehlhaeuser 2012-12-04 21:07:03 +01:00
parent 93e3d6644c
commit d9c8ef9273

View File

@ -17,6 +17,9 @@
#include "ImageRegistry.h"
#include <QSvgRenderer>
#include <QPainter>
#include "utils/Logger.h"
static QHash< QString, QHash< int, QHash< int, QPixmap > > > s_cache;
@ -58,7 +61,21 @@ ImageRegistry::getFromCache( const QString& image, const QSize& size, TomahawkUt
}
// Image not found in cache. Let's load it.
QPixmap pixmap( image );
QPixmap pixmap;
if ( image.toLower().endsWith( ".svg" ) )
{
QSvgRenderer svgRenderer( image );
QPixmap p( size.isNull() ? svgRenderer.defaultSize() : size );
p.fill( Qt::transparent );
QPainter pixPainter( &p );
svgRenderer.render( &pixPainter );
pixmap = p;
}
else
pixmap = QPixmap( image );
if ( !pixmap.isNull() )
{
switch ( mode )