[libcalamaresui] images-strings loading fixed
- move the string-munge into a lambda and use the generic loadStrings()
This commit is contained in:
parent
544d905b2f
commit
62328c9940
@ -110,28 +110,6 @@ loadStrings( QMap<QString, QString>& map, const QVariantMap& config, const std::
|
|||||||
* documentation for details.
|
* documentation for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** @brief Load the @p map of image-filepaths from @p config
|
|
||||||
*
|
|
||||||
* Paths are translated relative to componentDir, and must exist.
|
|
||||||
* All paths are transformed to absolute paths before putting
|
|
||||||
* them in the map.
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
loadImages(QMap<QString, QString>& map, const QVariantMap& config)
|
|
||||||
{
|
|
||||||
map.clear();
|
|
||||||
for ( auto it = config.constBegin(); it != config.constEnd(); ++it )
|
|
||||||
{
|
|
||||||
QString pathString = it.value().toString();
|
|
||||||
QFileInfo imageFi( componentDir.absoluteFilePath( pathString ) );
|
|
||||||
if ( !imageFi.exists() )
|
|
||||||
bail( QString( "Image file %1 does not exist." )
|
|
||||||
.arg( imageFi.absoluteFilePath() ) );
|
|
||||||
|
|
||||||
map.insert( it.key(), imageFi.absoluteFilePath() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Branding::Branding( const QString& brandingFilePath,
|
Branding::Branding( const QString& brandingFilePath,
|
||||||
QObject* parent )
|
QObject* parent )
|
||||||
: QObject( parent )
|
: QObject( parent )
|
||||||
@ -170,7 +148,15 @@ Branding::Branding( const QString& brandingFilePath,
|
|||||||
|
|
||||||
if ( !doc[ "images" ].IsMap() )
|
if ( !doc[ "images" ].IsMap() )
|
||||||
bail( "Syntax error in images map." );
|
bail( "Syntax error in images map." );
|
||||||
loadImages( m_images, CalamaresUtils::yamlMapToVariant( doc[ "images" ] ).toMap() );
|
loadStrings( m_images, CalamaresUtils::yamlMapToVariant( doc[ "images" ] ).toMap(),
|
||||||
|
[&]( const QString& s ) -> QString
|
||||||
|
{
|
||||||
|
QFileInfo imageFi( componentDir.absoluteFilePath( s ) );
|
||||||
|
if ( !imageFi.exists() )
|
||||||
|
bail( QString( "Image file %1 does not exist." ).arg( imageFi.absoluteFilePath() ) );
|
||||||
|
return imageFi.absoluteFilePath();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
if ( !doc[ "style" ].IsMap() )
|
if ( !doc[ "style" ].IsMap() )
|
||||||
bail( "Syntax error in style map." );
|
bail( "Syntax error in style map." );
|
||||||
|
Loading…
Reference in New Issue
Block a user