diff options
author | Adriaan de Groot <groot@kde.org> | 2019-04-23 16:41:22 -0400 |
---|---|---|
committer | Adriaan de Groot <groot@kde.org> | 2019-04-23 16:41:22 -0400 |
commit | 08e4090354e1563f00f9adb9d115d261edb8c2b7 (patch) | |
tree | 77a7faba3e8a9ddabc2987ab57b46fcda4aaa1e8 | |
parent | a216b5ca7632a062cea9287d80ad5086abc33537 (diff) | |
parent | 2413180c6701645b67e66b3a549607876c894dee (diff) |
Merge remote-tracking branch 'origin/raurodse-branding'
FIXES #961
-rw-r--r-- | CHANGES | 5 | ||||
-rw-r--r-- | src/calamares/CalamaresWindow.cpp | 10 | ||||
-rw-r--r-- | src/calamares/progresstree/ProgressTreeView.cpp | 1 | ||||
-rw-r--r-- | src/libcalamaresui/Branding.cpp | 39 | ||||
-rw-r--r-- | src/libcalamaresui/Branding.h | 26 | ||||
-rw-r--r-- | src/modules/partition/gui/BootInfoWidget.cpp | 4 | ||||
-rw-r--r-- | src/modules/partition/gui/DeviceInfoWidget.cpp | 3 | ||||
-rw-r--r-- | src/modules/partition/gui/PartitionBarsView.cpp | 1 | ||||
-rw-r--r-- | src/modules/partition/gui/PartitionLabelsView.cpp | 2 | ||||
-rw-r--r-- | src/modules/summary/SummaryPage.cpp | 3 | ||||
-rw-r--r-- | src/modules/welcome/WelcomePage.cpp | 4 |
11 files changed, 59 insertions, 39 deletions
@@ -17,6 +17,7 @@ This release contains contributions from (alphabetically by first name): This release contains contributions from (alphabetically by first name): - Arnaud Ferraris - Dominic Hayes (feren) + - Raul Rodrigo Segura (raurodse) ## Core ## @@ -24,7 +25,9 @@ This release contains contributions from (alphabetically by first name): builds without warnings when Clang 8 is used. * A new *disable-cancel-during-exec* setting provides more fine-grained 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 ## * All of the Python-based modules now have translations enabled. diff --git a/src/calamares/CalamaresWindow.cpp b/src/calamares/CalamaresWindow.cpp index f0ae03525..157941a90 100644 --- a/src/calamares/CalamaresWindow.cpp +++ b/src/calamares/CalamaresWindow.cpp @@ -2,6 +2,7 @@ * * Copyright 2014-2015, Teo Mrnjavac <teo@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> * * Calamares is free software: you can redistribute it and/or modify @@ -35,6 +36,8 @@ #include <QDesktopWidget> #include <QLabel> #include <QTreeView> +#include <QFile> +#include <QFileInfo> static inline int windowDimensionToPixels( const Calamares::Branding::WindowDimension& u ) @@ -67,6 +70,8 @@ CalamaresWindow::CalamaresWindow( QWidget* parent ) using CalamaresUtils::windowPreferredHeight; using CalamaresUtils::windowPreferredWidth; + this->setObjectName("mainApp"); + QSize availableSize = qApp->desktop()->availableGeometry( this ).size(); QSize minimumSize( qBound( windowMinimumWidth, availableSize.width(), windowPreferredWidth ), qBound( windowMinimumHeight, availableSize.height(), windowPreferredHeight ) ); @@ -86,10 +91,12 @@ CalamaresWindow::CalamaresWindow( QWidget* parent ) setLayout( mainLayout ); QWidget* sideBox = new QWidget( this ); + sideBox->setObjectName("sidebarApp"); mainLayout->addWidget( sideBox ); QBoxLayout* sideLayout = new QVBoxLayout; sideBox->setLayout( sideLayout ); + // Set this attribute into qss file sideBox->setFixedWidth( qBound( 100, CalamaresUtils::defaultFontHeight() * 12, w < windowPreferredWidth ? 100 : 190 ) ); sideBox->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); @@ -97,6 +104,8 @@ CalamaresWindow::CalamaresWindow( QWidget* parent ) sideLayout->addLayout( logoLayout ); logoLayout->addStretch(); QLabel* logoLabel = new QLabel( sideBox ); + logoLabel->setObjectName("logoApp"); + //Define all values into qss file { QPalette plt = sideBox->palette(); sideBox->setAutoFillBackground( true ); @@ -154,6 +163,7 @@ CalamaresWindow::CalamaresWindow( QWidget* parent ) connect( m_viewManager, &Calamares::ViewManager::enlarge, this, &CalamaresWindow::enlarge ); mainLayout->addWidget( m_viewManager->centralWidget() ); + setStyleSheet( Calamares::Branding::instance()->stylesheet() ); } void diff --git a/src/calamares/progresstree/ProgressTreeView.cpp b/src/calamares/progresstree/ProgressTreeView.cpp index b6b3ac5a9..079592848 100644 --- a/src/calamares/progresstree/ProgressTreeView.cpp +++ b/src/calamares/progresstree/ProgressTreeView.cpp @@ -35,6 +35,7 @@ ProgressTreeView::ProgressTreeView( QWidget* parent ) { s_instance = this; //FIXME: should assert when s_instance gets written and it wasn't nullptr + this->setObjectName("sidebarMenuApp"); setFrameShape( QFrame::NoFrame ); setContentsMargins( 0, 0, 0, 0 ); diff --git a/src/libcalamaresui/Branding.cpp b/src/libcalamaresui/Branding.cpp index 1838105d7..22248ae53 100644 --- a/src/libcalamaresui/Branding.cpp +++ b/src/libcalamaresui/Branding.cpp @@ -2,6 +2,7 @@ * * Copyright 2014-2015, Teo Mrnjavac <teo@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 * 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 ) , m_descriptorPath( brandingFilePath ) - , m_componentName() , m_welcomeStyleCalamares( false ) , m_welcomeExpandingLogo( true ) { @@ -198,6 +198,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 { @@ -217,20 +227,6 @@ Branding::Branding( const QString& brandingFilePath, QString -Branding::descriptorPath() const -{ - return m_descriptorPath; -} - - -QString -Branding::componentName() const -{ - return m_componentName; -} - - -QString Branding::componentDirectory() const { QFileInfo fi ( m_descriptorPath ); @@ -239,13 +235,6 @@ Branding::componentDirectory() const QString -Branding::translationsPathPrefix() const -{ - return m_translationsPathPrefix; -} - - -QString Branding::string( Branding::StringEntry stringEntry ) const { return m_strings.value( s_stringEntryStrings.value( stringEntry ) ); @@ -281,12 +270,6 @@ Branding::image( Branding::ImageEntry imageEntry, const QSize& size ) const } -QString -Branding::slideshowPath() const -{ - return m_slideshowPath; -} - void Branding::setGlobals( GlobalStorage* globalStorage ) const { diff --git a/src/libcalamaresui/Branding.h b/src/libcalamaresui/Branding.h index 197cb8ee2..572cd3682 100644 --- a/src/libcalamaresui/Branding.h +++ b/src/libcalamaresui/Branding.h @@ -1,7 +1,8 @@ /* === This file is part of Calamares - <https://github.com/calamares> === * * 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 * it under the terms of the GNU General Public License as published by @@ -101,16 +102,30 @@ public: explicit Branding( const QString& brandingFilePath, QObject* parent = nullptr ); - QString descriptorPath() const; - QString componentName() const; + /** @brief Complete path of the branding descriptor file. */ + 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 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 styleString( Branding::StyleEntry styleEntry ) const; QString imagePath( Branding::ImageEntry imageEntry ) 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 welcomeExpandingLogo() const { return m_welcomeExpandingLogo; } @@ -144,6 +159,7 @@ private: 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 ); diff --git a/src/modules/partition/gui/BootInfoWidget.cpp b/src/modules/partition/gui/BootInfoWidget.cpp index 6a985877f..696628c37 100644 --- a/src/modules/partition/gui/BootInfoWidget.cpp +++ b/src/modules/partition/gui/BootInfoWidget.cpp @@ -32,6 +32,8 @@ BootInfoWidget::BootInfoWidget( QWidget* parent ) , m_bootIcon( new QLabel ) , m_bootLabel( new QLabel ) { + m_bootIcon->setObjectName("bootInfoIcon"); + m_bootLabel->setObjectName("bootInfoLabel"); QHBoxLayout* mainLayout = new QHBoxLayout; setLayout( mainLayout ); @@ -47,7 +49,7 @@ BootInfoWidget::BootInfoWidget( QWidget* parent ) m_bootIcon->setPixmap( CalamaresUtils::defaultPixmap( CalamaresUtils::BootEnvironment, CalamaresUtils::Original, iconSize ) ); - + QFontMetrics fm = QFontMetrics( QFont() ); m_bootLabel->setMinimumWidth( fm.boundingRect( "BIOS" ).width() + CalamaresUtils::defaultFontHeight() / 2 ); m_bootLabel->setAlignment( Qt::AlignCenter ); diff --git a/src/modules/partition/gui/DeviceInfoWidget.cpp b/src/modules/partition/gui/DeviceInfoWidget.cpp index 033db147f..4d37e3b39 100644 --- a/src/modules/partition/gui/DeviceInfoWidget.cpp +++ b/src/modules/partition/gui/DeviceInfoWidget.cpp @@ -39,7 +39,8 @@ DeviceInfoWidget::DeviceInfoWidget( QWidget* parent ) setLayout( mainLayout ); CalamaresUtils::unmarginLayout( mainLayout ); - + m_ptLabel->setObjectName("deviceInfoLabel"); + m_ptIcon->setObjectName("deviceInfoIcon"); mainLayout->addWidget( m_ptIcon ); mainLayout->addWidget( m_ptLabel ); diff --git a/src/modules/partition/gui/PartitionBarsView.cpp b/src/modules/partition/gui/PartitionBarsView.cpp index 3fa1bb272..22e360182 100644 --- a/src/modules/partition/gui/PartitionBarsView.cpp +++ b/src/modules/partition/gui/PartitionBarsView.cpp @@ -57,6 +57,7 @@ PartitionBarsView::PartitionBarsView( QWidget* parent ) , canBeSelected( []( const QModelIndex& ) { return true; } ) , m_hoveredIndex( QModelIndex() ) { + this->setObjectName("partitionBarView"); setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); setFrameStyle( QFrame::NoFrame ); setSelectionBehavior( QAbstractItemView::SelectRows ); diff --git a/src/modules/partition/gui/PartitionLabelsView.cpp b/src/modules/partition/gui/PartitionLabelsView.cpp index 0da7beba8..b5fd0fc91 100644 --- a/src/modules/partition/gui/PartitionLabelsView.cpp +++ b/src/modules/partition/gui/PartitionLabelsView.cpp @@ -61,7 +61,7 @@ PartitionLabelsView::PartitionLabelsView( QWidget* parent ) setFrameStyle( QFrame::NoFrame ); setSelectionBehavior( QAbstractItemView::SelectRows ); setSelectionMode( QAbstractItemView::SingleSelection ); - + this->setObjectName("partitionLabel"); // Debug connect( this, &PartitionLabelsView::clicked, this, [=]( const QModelIndex& index ) diff --git a/src/modules/summary/SummaryPage.cpp b/src/modules/summary/SummaryPage.cpp index 6913d3e17..11a9f2863 100644 --- a/src/modules/summary/SummaryPage.cpp +++ b/src/modules/summary/SummaryPage.cpp @@ -42,6 +42,9 @@ SummaryPage::SummaryPage( const SummaryViewStep* thisViewStep, QWidget* parent ) , m_scrollArea( new QScrollArea( this ) ) { Q_UNUSED( parent ) + + this->setObjectName("summaryStep"); + Q_ASSERT( m_thisViewStep ); QVBoxLayout* layout = new QVBoxLayout( this ); layout->setContentsMargins( 0, 0, 0, 0 ); diff --git a/src/modules/welcome/WelcomePage.cpp b/src/modules/welcome/WelcomePage.cpp index afb63971d..65a475310 100644 --- a/src/modules/welcome/WelcomePage.cpp +++ b/src/modules/welcome/WelcomePage.cpp @@ -167,7 +167,7 @@ WelcomePage::initLanguages() QString name = m_languages->locale( 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 ); } else @@ -183,7 +183,7 @@ WelcomePage::initLanguages() QLocale::setDefault( selectedLocale ); CalamaresUtils::installTranslator( selectedLocale, - Calamares::Branding::instance()->translationsPathPrefix(), + Calamares::Branding::instance()->translationsDirectory(), qApp ); } ); } |