From 822bbaad9c3021a922aaf7b85c6663b0375a72e6 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 27 May 2019 15:26:57 +0200 Subject: [PATCH] [libcalamaresui] Allow icon names in branding images - It's ok to use path / filenames in images, but you can also use icon names according to the FDO icon spec. This makes sense for at least *productLogo*, possibly *productIcon*, but not really for *productWelcome*. --- src/libcalamaresui/Branding.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/libcalamaresui/Branding.cpp b/src/libcalamaresui/Branding.cpp index a27b39ae6..680e9b926 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(); } );