Merge remote-tracking branch 'origin/raurodse-branding'

FIXES #961
main
Adriaan de Groot 6 years ago
commit 08e4090354

@ -17,6 +17,7 @@ This release contains contributions from (alphabetically by first name):
This release contains contributions from (alphabetically by first name): This release contains contributions from (alphabetically by first name):
- Arnaud Ferraris - Arnaud Ferraris
- Dominic Hayes (feren) - Dominic Hayes (feren)
- Raul Rodrigo Segura (raurodse)
## Core ## ## Core ##
@ -24,6 +25,8 @@ This release contains contributions from (alphabetically by first name):
builds without warnings when Clang 8 is used. builds without warnings when Clang 8 is used.
* A new *disable-cancel-during-exec* setting provides more fine-grained * A new *disable-cancel-during-exec* setting provides more fine-grained
control than *disable-cancel* (which hides the button entirely). control than *disable-cancel* (which hides the button entirely).
* A branding module can now also cause a stylesheet to be loaded, which
will be applied to the widgets inside Calamares. (Thanks to Raul)
## Modules ## ## Modules ##

@ -2,6 +2,7 @@
* *
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org> * Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
* Copyright 2017-2018, Adriaan de Groot <groot@kde.org> * Copyright 2017-2018, Adriaan de Groot <groot@kde.org>
* Copyright 2018, Raul Rodrigo Segura (raurodse)
* Copyright 2019, Collabora Ltd <arnaud.ferraris@collabora.com> * Copyright 2019, Collabora Ltd <arnaud.ferraris@collabora.com>
* *
* Calamares is free software: you can redistribute it and/or modify * Calamares is free software: you can redistribute it and/or modify
@ -35,6 +36,8 @@
#include <QDesktopWidget> #include <QDesktopWidget>
#include <QLabel> #include <QLabel>
#include <QTreeView> #include <QTreeView>
#include <QFile>
#include <QFileInfo>
static inline int static inline int
windowDimensionToPixels( const Calamares::Branding::WindowDimension& u ) windowDimensionToPixels( const Calamares::Branding::WindowDimension& u )
@ -67,6 +70,8 @@ CalamaresWindow::CalamaresWindow( QWidget* parent )
using CalamaresUtils::windowPreferredHeight; using CalamaresUtils::windowPreferredHeight;
using CalamaresUtils::windowPreferredWidth; using CalamaresUtils::windowPreferredWidth;
this->setObjectName("mainApp");
QSize availableSize = qApp->desktop()->availableGeometry( this ).size(); QSize availableSize = qApp->desktop()->availableGeometry( this ).size();
QSize minimumSize( qBound( windowMinimumWidth, availableSize.width(), windowPreferredWidth ), QSize minimumSize( qBound( windowMinimumWidth, availableSize.width(), windowPreferredWidth ),
qBound( windowMinimumHeight, availableSize.height(), windowPreferredHeight ) ); qBound( windowMinimumHeight, availableSize.height(), windowPreferredHeight ) );
@ -86,10 +91,12 @@ CalamaresWindow::CalamaresWindow( QWidget* parent )
setLayout( mainLayout ); setLayout( mainLayout );
QWidget* sideBox = new QWidget( this ); QWidget* sideBox = new QWidget( this );
sideBox->setObjectName("sidebarApp");
mainLayout->addWidget( sideBox ); mainLayout->addWidget( sideBox );
QBoxLayout* sideLayout = new QVBoxLayout; QBoxLayout* sideLayout = new QVBoxLayout;
sideBox->setLayout( sideLayout ); sideBox->setLayout( sideLayout );
// Set this attribute into qss file
sideBox->setFixedWidth( qBound( 100, CalamaresUtils::defaultFontHeight() * 12, w < windowPreferredWidth ? 100 : 190 ) ); sideBox->setFixedWidth( qBound( 100, CalamaresUtils::defaultFontHeight() * 12, w < windowPreferredWidth ? 100 : 190 ) );
sideBox->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); sideBox->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
@ -97,6 +104,8 @@ CalamaresWindow::CalamaresWindow( QWidget* parent )
sideLayout->addLayout( logoLayout ); sideLayout->addLayout( logoLayout );
logoLayout->addStretch(); logoLayout->addStretch();
QLabel* logoLabel = new QLabel( sideBox ); QLabel* logoLabel = new QLabel( sideBox );
logoLabel->setObjectName("logoApp");
//Define all values into qss file
{ {
QPalette plt = sideBox->palette(); QPalette plt = sideBox->palette();
sideBox->setAutoFillBackground( true ); sideBox->setAutoFillBackground( true );
@ -154,6 +163,7 @@ CalamaresWindow::CalamaresWindow( QWidget* parent )
connect( m_viewManager, &Calamares::ViewManager::enlarge, this, &CalamaresWindow::enlarge ); connect( m_viewManager, &Calamares::ViewManager::enlarge, this, &CalamaresWindow::enlarge );
mainLayout->addWidget( m_viewManager->centralWidget() ); mainLayout->addWidget( m_viewManager->centralWidget() );
setStyleSheet( Calamares::Branding::instance()->stylesheet() );
} }
void void

@ -35,6 +35,7 @@ ProgressTreeView::ProgressTreeView( QWidget* parent )
{ {
s_instance = this; //FIXME: should assert when s_instance gets written and it wasn't nullptr s_instance = this; //FIXME: should assert when s_instance gets written and it wasn't nullptr
this->setObjectName("sidebarMenuApp");
setFrameShape( QFrame::NoFrame ); setFrameShape( QFrame::NoFrame );
setContentsMargins( 0, 0, 0, 0 ); setContentsMargins( 0, 0, 0, 0 );

@ -2,6 +2,7 @@
* *
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org> * Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
* Copyright 2017-2018, Adriaan de Groot <groot@kde.org> * Copyright 2017-2018, Adriaan de Groot <groot@kde.org>
* Copyright 2018, Raul Rodrigo Segura (raurodse)
* *
* Calamares is free software: you can redistribute it and/or modify * Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -91,7 +92,6 @@ Branding::Branding( const QString& brandingFilePath,
QObject* parent ) QObject* parent )
: QObject( parent ) : QObject( parent )
, m_descriptorPath( brandingFilePath ) , m_descriptorPath( brandingFilePath )
, m_componentName()
, m_welcomeStyleCalamares( false ) , m_welcomeStyleCalamares( false )
, m_welcomeExpandingLogo( true ) , m_welcomeExpandingLogo( true )
{ {
@ -198,6 +198,16 @@ Branding::Branding( const QString& brandingFilePath,
m_translationsPathPrefix.append( QString( "%1calamares-%2" ) m_translationsPathPrefix.append( QString( "%1calamares-%2" )
.arg( QDir::separator() ) .arg( QDir::separator() )
.arg( m_componentName ) ); .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 else
{ {
@ -216,20 +226,6 @@ Branding::Branding( const QString& brandingFilePath,
} }
QString
Branding::descriptorPath() const
{
return m_descriptorPath;
}
QString
Branding::componentName() const
{
return m_componentName;
}
QString QString
Branding::componentDirectory() const Branding::componentDirectory() const
{ {
@ -238,13 +234,6 @@ Branding::componentDirectory() const
} }
QString
Branding::translationsPathPrefix() const
{
return m_translationsPathPrefix;
}
QString QString
Branding::string( Branding::StringEntry stringEntry ) const Branding::string( Branding::StringEntry stringEntry ) const
{ {
@ -281,12 +270,6 @@ Branding::image( Branding::ImageEntry imageEntry, const QSize& size ) const
} }
QString
Branding::slideshowPath() const
{
return m_slideshowPath;
}
void void
Branding::setGlobals( GlobalStorage* globalStorage ) const Branding::setGlobals( GlobalStorage* globalStorage ) const
{ {

@ -1,7 +1,8 @@
/* === This file is part of Calamares - <https://github.com/calamares> === /* === This file is part of Calamares - <https://github.com/calamares> ===
* *
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org> * Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
* Copyright 2017, Adriaan de Groot <groot@kde.org> * Copyright 2017-2018, Adriaan de Groot <groot@kde.org>
* Copyright 2018, Raul Rodrigo Segura (raurodse)
* *
* Calamares is free software: you can redistribute it and/or modify * Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -101,16 +102,30 @@ public:
explicit Branding( const QString& brandingFilePath, explicit Branding( const QString& brandingFilePath,
QObject* parent = nullptr ); QObject* parent = nullptr );
QString descriptorPath() const; /** @brief Complete path of the branding descriptor file. */
QString componentName() const; QString descriptorPath() const { return m_descriptorPath; }
/** @brief The component name found in the descriptor file.
*
* The component name always matches the last directory name in the path.
*/
QString componentName() const { return m_componentName; }
/** @brief The directory holding all of the branding assets. */
QString componentDirectory() const; QString componentDirectory() const;
QString translationsPathPrefix() const; /** @brief The directory where branding translations live.
*
* This is componentDir + "/lang".
*/
QString translationsDirectory() const { return m_translationsPathPrefix; }
/** @brief Path to the slideshow QML file, if any. */
QString slideshowPath() const { return m_slideshowPath; }
QString string( Branding::StringEntry stringEntry ) const; QString string( Branding::StringEntry stringEntry ) const;
QString styleString( Branding::StyleEntry styleEntry ) const; QString styleString( Branding::StyleEntry styleEntry ) const;
QString imagePath( Branding::ImageEntry imageEntry ) const; QString imagePath( Branding::ImageEntry imageEntry ) const;
QPixmap image( Branding::ImageEntry imageEntry, const QSize& size ) const; QPixmap image( Branding::ImageEntry imageEntry, const QSize& size ) const;
QString slideshowPath() const; /** @brief Stylesheet to apply for this branding. May be empty. */
QString stylesheet() const { return m_stylesheet; }
bool welcomeStyleCalamares() const { return m_welcomeStyleCalamares; } bool welcomeStyleCalamares() const { return m_welcomeStyleCalamares; }
bool welcomeExpandingLogo() const { return m_welcomeExpandingLogo; } bool welcomeExpandingLogo() const { return m_welcomeExpandingLogo; }
@ -144,6 +159,7 @@ private:
QMap< QString, QString > m_style; QMap< QString, QString > m_style;
QString m_slideshowPath; QString m_slideshowPath;
QString m_translationsPathPrefix; QString m_translationsPathPrefix;
QString m_stylesheet; // Text from file
/** @brief Initialize the simple settings below */ /** @brief Initialize the simple settings below */
void initSimpleSettings( const YAML::Node& doc ); void initSimpleSettings( const YAML::Node& doc );

@ -32,6 +32,8 @@ BootInfoWidget::BootInfoWidget( QWidget* parent )
, m_bootIcon( new QLabel ) , m_bootIcon( new QLabel )
, m_bootLabel( new QLabel ) , m_bootLabel( new QLabel )
{ {
m_bootIcon->setObjectName("bootInfoIcon");
m_bootLabel->setObjectName("bootInfoLabel");
QHBoxLayout* mainLayout = new QHBoxLayout; QHBoxLayout* mainLayout = new QHBoxLayout;
setLayout( mainLayout ); setLayout( mainLayout );

@ -39,7 +39,8 @@ DeviceInfoWidget::DeviceInfoWidget( QWidget* parent )
setLayout( mainLayout ); setLayout( mainLayout );
CalamaresUtils::unmarginLayout( mainLayout ); CalamaresUtils::unmarginLayout( mainLayout );
m_ptLabel->setObjectName("deviceInfoLabel");
m_ptIcon->setObjectName("deviceInfoIcon");
mainLayout->addWidget( m_ptIcon ); mainLayout->addWidget( m_ptIcon );
mainLayout->addWidget( m_ptLabel ); mainLayout->addWidget( m_ptLabel );

@ -57,6 +57,7 @@ PartitionBarsView::PartitionBarsView( QWidget* parent )
, canBeSelected( []( const QModelIndex& ) { return true; } ) , canBeSelected( []( const QModelIndex& ) { return true; } )
, m_hoveredIndex( QModelIndex() ) , m_hoveredIndex( QModelIndex() )
{ {
this->setObjectName("partitionBarView");
setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
setFrameStyle( QFrame::NoFrame ); setFrameStyle( QFrame::NoFrame );
setSelectionBehavior( QAbstractItemView::SelectRows ); setSelectionBehavior( QAbstractItemView::SelectRows );

@ -61,7 +61,7 @@ PartitionLabelsView::PartitionLabelsView( QWidget* parent )
setFrameStyle( QFrame::NoFrame ); setFrameStyle( QFrame::NoFrame );
setSelectionBehavior( QAbstractItemView::SelectRows ); setSelectionBehavior( QAbstractItemView::SelectRows );
setSelectionMode( QAbstractItemView::SingleSelection ); setSelectionMode( QAbstractItemView::SingleSelection );
this->setObjectName("partitionLabel");
// Debug // Debug
connect( this, &PartitionLabelsView::clicked, connect( this, &PartitionLabelsView::clicked,
this, [=]( const QModelIndex& index ) this, [=]( const QModelIndex& index )

@ -42,6 +42,9 @@ SummaryPage::SummaryPage( const SummaryViewStep* thisViewStep, QWidget* parent )
, m_scrollArea( new QScrollArea( this ) ) , m_scrollArea( new QScrollArea( this ) )
{ {
Q_UNUSED( parent ) Q_UNUSED( parent )
this->setObjectName("summaryStep");
Q_ASSERT( m_thisViewStep ); Q_ASSERT( m_thisViewStep );
QVBoxLayout* layout = new QVBoxLayout( this ); QVBoxLayout* layout = new QVBoxLayout( this );
layout->setContentsMargins( 0, 0, 0, 0 ); layout->setContentsMargins( 0, 0, 0, 0 );

@ -167,7 +167,7 @@ WelcomePage::initLanguages()
QString name = m_languages->locale( matchedLocaleIndex ).name(); QString name = m_languages->locale( matchedLocaleIndex ).name();
cDebug() << Logger::SubEntry << "Matched with index" << matchedLocaleIndex << name; cDebug() << Logger::SubEntry << "Matched with index" << matchedLocaleIndex << name;
CalamaresUtils::installTranslator( name, Calamares::Branding::instance()->translationsPathPrefix(), qApp ); CalamaresUtils::installTranslator( name, Calamares::Branding::instance()->translationsDirectory(), qApp );
ui->languageWidget->setCurrentIndex( matchedLocaleIndex ); ui->languageWidget->setCurrentIndex( matchedLocaleIndex );
} }
else else
@ -183,7 +183,7 @@ WelcomePage::initLanguages()
QLocale::setDefault( selectedLocale ); QLocale::setDefault( selectedLocale );
CalamaresUtils::installTranslator( selectedLocale, CalamaresUtils::installTranslator( selectedLocale,
Calamares::Branding::instance()->translationsPathPrefix(), Calamares::Branding::instance()->translationsDirectory(),
qApp ); qApp );
} ); } );
} }

Loading…
Cancel
Save