Branding: move the branding stylesheet to the Branding class

This commit is contained in:
Adriaan de Groot 2018-05-22 05:43:59 -04:00
parent 975004fc63
commit 5bcfb32cf5
3 changed files with 14 additions and 22 deletions

View File

@ -149,28 +149,7 @@ CalamaresWindow::CalamaresWindow( QWidget* parent )
connect( m_viewManager, &Calamares::ViewManager::enlarge, this, &CalamaresWindow::enlarge );
mainLayout->addWidget( m_viewManager->centralWidget() );
QString brandingComponentName = Calamares::Settings::instance()->brandingComponentName();
if ( brandingComponentName.simplified().isEmpty() )
{
cError() << "FATAL: branding component not set in settings.conf";
::exit( EXIT_FAILURE );
}
QString brandingQSSDescriptorPath = QString( "/etc/calamares/branding/%1/stylesheet.qss" )
.arg( brandingComponentName );
QFileInfo importQSSPath = QFileInfo( brandingQSSDescriptorPath );
if ( importQSSPath.exists() && importQSSPath.isReadable() )
{
QFile File(brandingQSSDescriptorPath);
File.open(QFile::ReadOnly);
QString StyleSheet = QLatin1String(File.readAll());
this->setStyleSheet(StyleSheet);
}
setStyleSheet( Calamares::Branding::instance()->stylesheet() );
}
void

View File

@ -188,6 +188,16 @@ 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
{

View File

@ -98,6 +98,8 @@ 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; }
bool welcomeStyleCalamares() const { return m_welcomeStyleCalamares; }
bool welcomeExpandingLogo() const { return m_welcomeExpandingLogo; }
@ -125,6 +127,7 @@ private:
QMap< QString, QString > m_style;
QString m_slideshowPath;
QString m_translationsPathPrefix;
QString m_stylesheet; // Text from file
bool m_welcomeStyleCalamares;
bool m_welcomeExpandingLogo;