[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*.
main
Adriaan de Groot 6 years ago
parent b41cac6556
commit 822bbaad9c

@ -1,7 +1,7 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
* Copyright 2017-2018, Adriaan de Groot <groot@kde.org>
* Copyright 2017-2019, Adriaan de Groot <groot@kde.org>
* Copyright 2018, Raul Rodrigo Segura (raurodse)
*
* Calamares is free software: you can redistribute it and/or modify
@ -29,6 +29,7 @@
#include <QDir>
#include <QFile>
#include <QIcon>
#include <QPixmap>
#include <QVariantMap>
@ -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() )
{
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();
}
);

Loading…
Cancel
Save