From d9c8ef9273c439d6c2e2bdad23a3c3a56aa50003 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Tue, 4 Dec 2012 21:07:03 +0100 Subject: [PATCH] * ImageRegistry supports rendering SVGs now. --- src/libtomahawk/utils/ImageRegistry.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/libtomahawk/utils/ImageRegistry.cpp b/src/libtomahawk/utils/ImageRegistry.cpp index b8a4c21cb..288789980 100644 --- a/src/libtomahawk/utils/ImageRegistry.cpp +++ b/src/libtomahawk/utils/ImageRegistry.cpp @@ -17,6 +17,9 @@ #include "ImageRegistry.h" +#include +#include + #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 )