diff --git a/src/libcalamaresui/Branding.cpp b/src/libcalamaresui/Branding.cpp index 2f9407bb7..673b3df42 100644 --- a/src/libcalamaresui/Branding.cpp +++ b/src/libcalamaresui/Branding.cpp @@ -153,7 +153,7 @@ Branding::Branding( const QString& brandingFilePath, #ifdef WITH_KOSRelease KOSRelease relInfo; - + QHash< QString, QString > relMap{ std::initializer_list< std::pair< QString, QString > > { { QStringLiteral( "NAME" ), relInfo.name() }, @@ -239,16 +239,6 @@ Branding::Branding( const QString& brandingFilePath, m_translationsPathPrefix.append( QString( "%1calamares-%2" ) .arg( QDir::separator() ) .arg( m_componentName ) ); - - QFileInfo importQSSPath( componentDir.filePath( "stylesheet.qss" ) ); - if ( importQSSPath.exists() && importQSSPath.isReadable() ) - { - QFile stylesheetFile( importQSSPath.filePath() ); - stylesheetFile.open( QFile::ReadOnly ); - m_stylesheet = stylesheetFile.readAll(); - } - else - cWarning() << "the branding component" << componentDir.absolutePath() << "does not ship stylesheet.qss."; } else { @@ -310,6 +300,21 @@ Branding::image( Branding::ImageEntry imageEntry, const QSize& size ) const return pixmap; } +QString +Branding::stylesheet() const +{ + QFileInfo fi( m_descriptorPath ); + QFileInfo importQSSPath( fi.absoluteDir().filePath( "stylesheet.qss" ) ); + if ( importQSSPath.exists() && importQSSPath.isReadable() ) + { + QFile stylesheetFile( importQSSPath.filePath() ); + stylesheetFile.open( QFile::ReadOnly ); + return stylesheetFile.readAll(); + } + else + cWarning() << "The branding component" << fi.absoluteDir().absolutePath() << "does not ship stylesheet.qss."; + return QString(); +} void Branding::setGlobals( GlobalStorage* globalStorage ) const diff --git a/src/libcalamaresui/Branding.h b/src/libcalamaresui/Branding.h index 29a39f103..00174f604 100644 --- a/src/libcalamaresui/Branding.h +++ b/src/libcalamaresui/Branding.h @@ -123,8 +123,13 @@ public: QString styleString( Branding::StyleEntry styleEntry ) const; QString imagePath( Branding::ImageEntry imageEntry ) const; QPixmap image( Branding::ImageEntry imageEntry, const QSize& size ) const; - /** @brief Stylesheet to apply for this branding. May be empty. */ - QString stylesheet() const { return m_stylesheet; } + /** @brief Stylesheet to apply for this branding. May be empty. + * + * The file is loaded every time this function is called, so + * it may be quite expensive -- although normally it will be + * called only once, on startup. (Or from the debug window) + */ + QString stylesheet() const; bool welcomeStyleCalamares() const { return m_welcomeStyleCalamares; } bool welcomeExpandingLogo() const { return m_welcomeExpandingLogo; } @@ -151,14 +156,13 @@ private: [[noreturn]] void bail( const QString& message ); - QString m_descriptorPath; - QString m_componentName; + QString m_descriptorPath; // Path to descriptor (e.g. "/etc/calamares/default/branding.desc") + QString m_componentName; // Matches last part of full path to containing directory QMap< QString, QString > m_strings; QMap< QString, QString > m_images; QMap< QString, QString > m_style; QString m_slideshowPath; QString m_translationsPathPrefix; - QString m_stylesheet; // Text from file /** @brief Initialize the simple settings below */ void initSimpleSettings( const YAML::Node& doc );