[libcalamaresui] Support os-release substitutions in images
- Branding images might want to use os-release data as well. - Refactor a little to keep the number of #ifdefs the same; an intermediate expand() lambda handles expansion (or not, if it's not enabled). FIXES #1153
This commit is contained in:
parent
368e7aac16
commit
cd38ded8d5
@ -83,6 +83,8 @@ strings:
|
|||||||
# any size and proportion, and will be scaled to fit inside
|
# any size and proportion, and will be scaled to fit inside
|
||||||
# the window. Use `welcomeExpandingLogo` to make it non-scaled.
|
# the window. Use `welcomeExpandingLogo` to make it non-scaled.
|
||||||
# Recommended size is 320x150.
|
# Recommended size is 320x150.
|
||||||
|
#
|
||||||
|
# These strings can also use substitutions from os-release (see above).
|
||||||
images:
|
images:
|
||||||
productLogo: "squid.png"
|
productLogo: "squid.png"
|
||||||
productIcon: "squid.png"
|
productIcon: "squid.png"
|
||||||
|
@ -152,6 +152,7 @@ Branding::Branding( const QString& brandingFilePath,
|
|||||||
initSimpleSettings( doc );
|
initSimpleSettings( doc );
|
||||||
|
|
||||||
#ifdef WITH_KOSRelease
|
#ifdef WITH_KOSRelease
|
||||||
|
// Copy the os-release information into a QHash for use by KMacroExpander.
|
||||||
KOSRelease relInfo;
|
KOSRelease relInfo;
|
||||||
|
|
||||||
QHash< QString, QString > relMap{
|
QHash< QString, QString > relMap{
|
||||||
@ -173,19 +174,18 @@ Branding::Branding( const QString& brandingFilePath,
|
|||||||
{ QStringLiteral( "VARIANT_ID" ), relInfo.variantId() },
|
{ QStringLiteral( "VARIANT_ID" ), relInfo.variantId() },
|
||||||
{ QStringLiteral( "LOGO" ), relInfo.logo() }
|
{ QStringLiteral( "LOGO" ), relInfo.logo() }
|
||||||
} };
|
} };
|
||||||
loadStrings( m_strings, doc, "strings",
|
auto expand = [&]( const QString& s ) -> QString { return KMacroExpander::expandMacros( s, relMap, QLatin1Char( '@' ) ); };
|
||||||
[&]( const QString& s ) -> QString { return KMacroExpander::expandMacros( s, relMap, QLatin1Char( '@' ) ); }
|
|
||||||
);
|
|
||||||
#else
|
#else
|
||||||
// No support for substituting in os-release values.
|
auto expand = []( const QString& s ) -> QString { return s; };
|
||||||
loadStrings( m_strings, doc, "strings",
|
|
||||||
[]( const QString& s ) -> QString { return s; }
|
|
||||||
);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// Massage the strings, images and style sections.
|
||||||
|
loadStrings( m_strings, doc, "strings", expand );
|
||||||
loadStrings( m_images, doc, "images",
|
loadStrings( m_images, doc, "images",
|
||||||
[&]( const QString& s ) -> QString
|
[&]( const QString& s ) -> QString
|
||||||
{
|
{
|
||||||
QFileInfo imageFi( componentDir.absoluteFilePath( s ) );
|
QFileInfo imageFi( componentDir.absoluteFilePath( expand( s ) ) );
|
||||||
if ( !imageFi.exists() )
|
if ( !imageFi.exists() )
|
||||||
bail( QString( "Image file %1 does not exist." ).arg( imageFi.absoluteFilePath() ) );
|
bail( QString( "Image file %1 does not exist." ).arg( imageFi.absoluteFilePath() ) );
|
||||||
return imageFi.absoluteFilePath();
|
return imageFi.absoluteFilePath();
|
||||||
|
Loading…
Reference in New Issue
Block a user