From b04a8907989e85e97abaa2903963dddefca7b82b Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 19 Sep 2017 16:22:59 +0200 Subject: [PATCH] Fix code using re-imported imageregistry --- src/libcalamaresui/utils/ImageRegistry.cpp | 28 +++++++++++++--------- src/libcalamaresui/utils/ImageRegistry.h | 12 +++++----- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/libcalamaresui/utils/ImageRegistry.cpp b/src/libcalamaresui/utils/ImageRegistry.cpp index 5e871c884..442017048 100644 --- a/src/libcalamaresui/utils/ImageRegistry.cpp +++ b/src/libcalamaresui/utils/ImageRegistry.cpp @@ -27,8 +27,6 @@ #include #include -#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; diff --git a/src/libcalamaresui/utils/ImageRegistry.h b/src/libcalamaresui/utils/ImageRegistry.h index 091127187..e35eaf74a 100644 --- a/src/libcalamaresui/utils/ImageRegistry.h +++ b/src/libcalamaresui/utils/ImageRegistry.h @@ -26,22 +26,22 @@ #include -#include "utils/TomahawkUtilsGui.h" -#include "DllMacro.h" +#include "utils/CalamaresUtilsGui.h" +#include "UiDllMacro.h" -class DLLEXPORT ImageRegistry +class UIDLLEXPORT ImageRegistry { public: static ImageRegistry* instance(); explicit ImageRegistry(); - QIcon icon( const QString& image, TomahawkUtils::ImageMode mode = TomahawkUtils::Original ); - QPixmap pixmap( const QString& image, const QSize& size, TomahawkUtils::ImageMode mode = TomahawkUtils::Original, float opacity = 1.0, QColor tint = QColor( 0, 0, 0, 0 ) ); + QIcon icon( const QString& image, CalamaresUtils::ImageMode mode = CalamaresUtils::Original ); + QPixmap pixmap( const QString& image, const QSize& size, CalamaresUtils::ImageMode mode = CalamaresUtils::Original, float opacity = 1.0, QColor tint = QColor( 0, 0, 0, 0 ) ); private: qint64 cacheKey( const QSize& size, float opacity, QColor tint ); - void putInCache( const QString& image, const QSize& size, TomahawkUtils::ImageMode mode, float opacity, const QPixmap& pixmap, QColor tint ); + void putInCache( const QString& image, const QSize& size, CalamaresUtils::ImageMode mode, float opacity, const QPixmap& pixmap, QColor tint ); static ImageRegistry* s_instance; };