diff --git a/CHANGES b/CHANGES index 731465158..6de55bff7 100644 --- a/CHANGES +++ b/CHANGES @@ -15,6 +15,10 @@ This release contains contributions from (alphabetically by first name): - *branding* now supports os-release variables in the *strings* section, which allows re-using (at runtime) information set in /etc/os-release . This requires KDE Frameworks 5.58. #1150 + - *branding* allows the use of FreeDesktop.org icon names for the + *productLogo* and *productIcon* keys. If a file is named there, then + the file is used, and otherwise the icon is looked up in the current + theme. # 3.2.8 (2019-05-10) # diff --git a/src/libcalamaresui/Branding.cpp b/src/libcalamaresui/Branding.cpp index a27b39ae6..4dc07ff19 100644 --- a/src/libcalamaresui/Branding.cpp +++ b/src/libcalamaresui/Branding.cpp @@ -1,7 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2014-2015, Teo Mrnjavac - * Copyright 2017-2018, Adriaan de Groot + * Copyright 2017-2019, Adriaan de Groot * Copyright 2018, Raul Rodrigo Segura (raurodse) * * Calamares is free software: you can redistribute it and/or modify @@ -29,6 +29,7 @@ #include #include +#include #include #include @@ -185,9 +186,16 @@ Branding::Branding( const QString& brandingFilePath, loadStrings( m_images, doc, "images", [&]( const QString& s ) -> QString { - QFileInfo imageFi( componentDir.absoluteFilePath( expand( s ) ) ); + const QString imageName( expand( s ) ); + QFileInfo imageFi( componentDir.absoluteFilePath( imageName ) ); if ( !imageFi.exists() ) - bail( QString( "Image file %1 does not exist." ).arg( imageFi.absoluteFilePath() ) ); + { + const auto icon = QIcon::fromTheme( imageName ); + // Not found, bail out with the filename used + if ( icon.isNull() ) + bail( QString( "Image file %1 does not exist." ).arg( imageFi.absoluteFilePath() ) ); + return imageName; // Not turned into a path + } return imageFi.absoluteFilePath(); } ); @@ -289,15 +297,21 @@ Branding::imagePath( Branding::ImageEntry imageEntry ) const QPixmap Branding::image( Branding::ImageEntry imageEntry, const QSize& size ) const { - QPixmap pixmap = - ImageRegistry::instance()->pixmap( imagePath( imageEntry ), size ); - - if ( pixmap.isNull() ) + const auto path = imagePath( imageEntry ); + if ( path.contains( '/' ) ) { - Q_ASSERT( false ); - return QPixmap(); + QPixmap pixmap = ImageRegistry::instance()->pixmap( path, size ); + + Q_ASSERT( !pixmap.isNull() ); + return pixmap; + } + else + { + auto icon = QIcon::fromTheme(path); + + Q_ASSERT( !icon.isNull() ); + return icon.pixmap( size ); } - return pixmap; } QString diff --git a/src/libcalamaresui/utils/ImageRegistry.cpp b/src/libcalamaresui/utils/ImageRegistry.cpp index 442017048..96ea92bbb 100644 --- a/src/libcalamaresui/utils/ImageRegistry.cpp +++ b/src/libcalamaresui/utils/ImageRegistry.cpp @@ -61,9 +61,9 @@ ImageRegistry::cacheKey( const QSize& size, float opacity, QColor tint ) QPixmap ImageRegistry::pixmap( const QString& image, const QSize& size, CalamaresUtils::ImageMode mode, float opacity, QColor tint ) { + Q_ASSERT( !(size.width() < 0 || size.height() < 0) ); if ( size.width() < 0 || size.height() < 0 ) { - Q_ASSERT( false ); return QPixmap(); } @@ -159,15 +159,9 @@ ImageRegistry::putInCache( const QString& image, const QSize& size, CalamaresUti if ( s_cache.contains( image ) ) { subcache = s_cache.value( image ); - if ( subcache.contains( mode ) ) { subsubcache = subcache.value( mode ); - -/* if ( subsubcache.contains( size.width() * size.height() ) ) - { - Q_ASSERT( false ); - }*/ } }