From 4c6f42ecfadda716442874d945a6c312ccffe559 Mon Sep 17 00:00:00 2001 From: Raul Rodrigo Segura Date: Sun, 20 May 2018 16:28:31 +0200 Subject: [PATCH 1/8] Set Object name to graphical elements to thematize by qss --- src/calamares/CalamaresWindow.cpp | 13 ++++++++++++- src/calamares/progresstree/ProgressTreeView.cpp | 1 + src/modules/partition/gui/BootInfoWidget.cpp | 4 +++- src/modules/partition/gui/DeviceInfoWidget.cpp | 3 ++- src/modules/partition/gui/PartitionBarsView.cpp | 1 + src/modules/summary/SummaryPage.cpp | 1 + 6 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/calamares/CalamaresWindow.cpp b/src/calamares/CalamaresWindow.cpp index 9f2ab6472..55ee9c69b 100644 --- a/src/calamares/CalamaresWindow.cpp +++ b/src/calamares/CalamaresWindow.cpp @@ -34,6 +34,7 @@ #include #include #include +#include CalamaresWindow::CalamaresWindow( QWidget* parent ) : QWidget( parent ) @@ -51,7 +52,8 @@ CalamaresWindow::CalamaresWindow( QWidget* parent ) using CalamaresUtils::windowPreferredWidth; QSize availableSize = qApp->desktop()->availableGeometry( this ).size(); - + this->setObjectName("mainApp"); + cDebug() << "Available size" << availableSize; if ( ( availableSize.width() < windowPreferredWidth ) || ( availableSize.height() < windowPreferredHeight ) ) @@ -71,10 +73,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 ); @@ -82,6 +86,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 ); @@ -142,6 +148,11 @@ CalamaresWindow::CalamaresWindow( QWidget* parent ) connect( m_viewManager, &Calamares::ViewManager::enlarge, this, &CalamaresWindow::enlarge ); mainLayout->addWidget( m_viewManager->centralWidget() ); + QFile File("/etc/calamares/stylesheet.qss"); + File.open(QFile::ReadOnly); + QString StyleSheet = QLatin1String(File.readAll()); + this->setStyleSheet(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/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/summary/SummaryPage.cpp b/src/modules/summary/SummaryPage.cpp index de68b1211..b70bce2b9 100644 --- a/src/modules/summary/SummaryPage.cpp +++ b/src/modules/summary/SummaryPage.cpp @@ -39,6 +39,7 @@ SummaryPage::SummaryPage( const SummaryViewStep* thisViewStep, QWidget* parent ) , m_contentWidget( nullptr ) , m_scrollArea( new QScrollArea( this ) ) { + this->setObjectName("summaryStep"); Q_UNUSED( parent ); Q_ASSERT( m_thisViewStep ); QVBoxLayout* layout = new QVBoxLayout( this ); From 1636f665c30cc9e4eed98ef641b5c1a562506d67 Mon Sep 17 00:00:00 2001 From: Raul Rodrigo Segura Date: Sun, 20 May 2018 16:29:38 +0200 Subject: [PATCH 2/8] Set Object name to graphical elements to thematize by qss --- src/modules/partition/gui/PartitionLabelsView.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/partition/gui/PartitionLabelsView.cpp b/src/modules/partition/gui/PartitionLabelsView.cpp index fbcc1de72..01c7a150e 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 ) From e2801daf33790040caa879dad6bb679476093720 Mon Sep 17 00:00:00 2001 From: Raul Rodrigo Segura Date: Sun, 20 May 2018 16:47:20 +0200 Subject: [PATCH 3/8] check path --- src/calamares/CalamaresWindow.cpp | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/calamares/CalamaresWindow.cpp b/src/calamares/CalamaresWindow.cpp index 55ee9c69b..6fc0a3622 100644 --- a/src/calamares/CalamaresWindow.cpp +++ b/src/calamares/CalamaresWindow.cpp @@ -53,7 +53,7 @@ CalamaresWindow::CalamaresWindow( QWidget* parent ) QSize availableSize = qApp->desktop()->availableGeometry( this ).size(); this->setObjectName("mainApp"); - + cDebug() << "Available size" << availableSize; if ( ( availableSize.width() < windowPreferredWidth ) || ( availableSize.height() < windowPreferredHeight ) ) @@ -148,10 +148,27 @@ CalamaresWindow::CalamaresWindow( QWidget* parent ) connect( m_viewManager, &Calamares::ViewManager::enlarge, this, &CalamaresWindow::enlarge ); mainLayout->addWidget( m_viewManager->centralWidget() ); - QFile File("/etc/calamares/stylesheet.qss"); - File.open(QFile::ReadOnly); - QString StyleSheet = QLatin1String(File.readAll()); - this->setStyleSheet(StyleSheet); + + + + 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 ); + + importQSSPath = QFileInfo( brandingQSSDescriptorPath ); + if ( importQSSPath.exists() && importQSSPath.isReadable() ) + { + QFile File(importQSSPath); + File.open(QFile::ReadOnly); + QString StyleSheet = QLatin1String(File.readAll()); + this->setStyleSheet(StyleSheet); + } } From 3f2cc854f49591d49c9a7a9064d1216cad68b22f Mon Sep 17 00:00:00 2001 From: Raul Rodrigo Segura Date: Mon, 21 May 2018 09:22:28 +0200 Subject: [PATCH 4/8] Set type to variable and import library --- src/calamares/CalamaresWindow.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/calamares/CalamaresWindow.cpp b/src/calamares/CalamaresWindow.cpp index 6fc0a3622..31f1b5c21 100644 --- a/src/calamares/CalamaresWindow.cpp +++ b/src/calamares/CalamaresWindow.cpp @@ -35,6 +35,7 @@ #include #include #include +#include CalamaresWindow::CalamaresWindow( QWidget* parent ) : QWidget( parent ) @@ -161,7 +162,7 @@ CalamaresWindow::CalamaresWindow( QWidget* parent ) QString brandingQSSDescriptorPath = QString( "/etc/calamares/branding/%1/stylesheet.qss" ) .arg( brandingComponentName ); - importQSSPath = QFileInfo( brandingQSSDescriptorPath ); + QFileInfo importQSSPath = QFileInfo( brandingQSSDescriptorPath ); if ( importQSSPath.exists() && importQSSPath.isReadable() ) { QFile File(importQSSPath); From 7b6c76ba1528a4f4e09966bf5bedfdd614c51023 Mon Sep 17 00:00:00 2001 From: Raul Rodrigo Segura Date: Mon, 21 May 2018 09:27:58 +0200 Subject: [PATCH 5/8] fix typo --- src/calamares/CalamaresWindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calamares/CalamaresWindow.cpp b/src/calamares/CalamaresWindow.cpp index 31f1b5c21..2dbda3c36 100644 --- a/src/calamares/CalamaresWindow.cpp +++ b/src/calamares/CalamaresWindow.cpp @@ -165,7 +165,7 @@ CalamaresWindow::CalamaresWindow( QWidget* parent ) QFileInfo importQSSPath = QFileInfo( brandingQSSDescriptorPath ); if ( importQSSPath.exists() && importQSSPath.isReadable() ) { - QFile File(importQSSPath); + QFile File(brandingQSSDescriptorPath); File.open(QFile::ReadOnly); QString StyleSheet = QLatin1String(File.readAll()); this->setStyleSheet(StyleSheet); From 975004fc6324a78b639e204c48deba281d553bfb Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 22 May 2018 05:21:20 -0400 Subject: [PATCH 6/8] [libcalamaresui] Document accessors in Branding - document accessors - put all path and directory accessors together - make simple accessors inline - rename "pathprefix" to "directory" to be consistent with others --- src/libcalamaresui/Branding.cpp | 28 ---------------------------- src/libcalamaresui/Branding.h | 21 ++++++++++++++++----- src/modules/welcome/WelcomePage.cpp | 4 ++-- 3 files changed, 18 insertions(+), 35 deletions(-) diff --git a/src/libcalamaresui/Branding.cpp b/src/libcalamaresui/Branding.cpp index 584d85c0b..f9f66a9fc 100644 --- a/src/libcalamaresui/Branding.cpp +++ b/src/libcalamaresui/Branding.cpp @@ -81,7 +81,6 @@ Branding::Branding( const QString& brandingFilePath, QObject* parent ) : QObject( parent ) , m_descriptorPath( brandingFilePath ) - , m_componentName() , m_welcomeStyleCalamares( false ) , m_welcomeExpandingLogo( true ) { @@ -207,20 +206,6 @@ Branding::Branding( const QString& brandingFilePath, } -QString -Branding::descriptorPath() const -{ - return m_descriptorPath; -} - - -QString -Branding::componentName() const -{ - return m_componentName; -} - - QString Branding::componentDirectory() const { @@ -229,13 +214,6 @@ Branding::componentDirectory() const } -QString -Branding::translationsPathPrefix() const -{ - return m_translationsPathPrefix; -} - - QString Branding::string( Branding::StringEntry stringEntry ) const { @@ -272,12 +250,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 fe9a83979..a3253e500 100644 --- a/src/libcalamaresui/Branding.h +++ b/src/libcalamaresui/Branding.h @@ -63,7 +63,7 @@ public: ProductIcon, ProductWelcome }; - + enum StyleEntry : short { SidebarBackground, @@ -77,16 +77,27 @@ 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; bool welcomeStyleCalamares() const { return m_welcomeStyleCalamares; } bool welcomeExpandingLogo() const { return m_welcomeExpandingLogo; } diff --git a/src/modules/welcome/WelcomePage.cpp b/src/modules/welcome/WelcomePage.cpp index 0a1d2fb7d..c7a30c4f2 100644 --- a/src/modules/welcome/WelcomePage.cpp +++ b/src/modules/welcome/WelcomePage.cpp @@ -257,7 +257,7 @@ WelcomePage::initLanguages() if ( isTranslationAvailable ) CalamaresUtils::installTranslator( matchedLocale.name(), - Calamares::Branding::instance()->translationsPathPrefix(), + Calamares::Branding::instance()->translationsDirectory(), qApp ); else cWarning() << "No available translation matched" << defaultLocale; @@ -272,7 +272,7 @@ WelcomePage::initLanguages() QLocale::setDefault( selectedLocale ); CalamaresUtils::installTranslator( selectedLocale, - Calamares::Branding::instance()->translationsPathPrefix(), + Calamares::Branding::instance()->translationsDirectory(), qApp ); } ); } From 5bcfb32cf5b42937c606b35f0912e23aaf939dad Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 22 May 2018 05:43:59 -0400 Subject: [PATCH 7/8] Branding: move the branding stylesheet to the Branding class --- src/calamares/CalamaresWindow.cpp | 23 +---------------------- src/libcalamaresui/Branding.cpp | 10 ++++++++++ src/libcalamaresui/Branding.h | 3 +++ 3 files changed, 14 insertions(+), 22 deletions(-) diff --git a/src/calamares/CalamaresWindow.cpp b/src/calamares/CalamaresWindow.cpp index 2dbda3c36..8c4f6a3cd 100644 --- a/src/calamares/CalamaresWindow.cpp +++ b/src/calamares/CalamaresWindow.cpp @@ -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 diff --git a/src/libcalamaresui/Branding.cpp b/src/libcalamaresui/Branding.cpp index f9f66a9fc..8df39a7d4 100644 --- a/src/libcalamaresui/Branding.cpp +++ b/src/libcalamaresui/Branding.cpp @@ -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 { diff --git a/src/libcalamaresui/Branding.h b/src/libcalamaresui/Branding.h index a3253e500..f7de939f1 100644 --- a/src/libcalamaresui/Branding.h +++ b/src/libcalamaresui/Branding.h @@ -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; From 2413180c6701645b67e66b3a549607876c894dee Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 22 May 2018 05:47:14 -0400 Subject: [PATCH 8/8] Branding: update copyright notices --- src/calamares/CalamaresWindow.cpp | 1 + src/libcalamaresui/Branding.cpp | 3 ++- src/libcalamaresui/Branding.h | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/calamares/CalamaresWindow.cpp b/src/calamares/CalamaresWindow.cpp index 8c4f6a3cd..e2e03a237 100644 --- a/src/calamares/CalamaresWindow.cpp +++ b/src/calamares/CalamaresWindow.cpp @@ -2,6 +2,7 @@ * * Copyright 2014-2015, Teo Mrnjavac * Copyright 2017-2018, Adriaan de Groot + * 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 diff --git a/src/libcalamaresui/Branding.cpp b/src/libcalamaresui/Branding.cpp index 8df39a7d4..583f9d20c 100644 --- a/src/libcalamaresui/Branding.cpp +++ b/src/libcalamaresui/Branding.cpp @@ -1,7 +1,8 @@ /* === This file is part of Calamares - === * * Copyright 2014-2015, Teo Mrnjavac - * Copyright 2017, Adriaan de Groot + * Copyright 2017-2018, Adriaan de Groot + * 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 diff --git a/src/libcalamaresui/Branding.h b/src/libcalamaresui/Branding.h index f7de939f1..f8ccf3069 100644 --- a/src/libcalamaresui/Branding.h +++ b/src/libcalamaresui/Branding.h @@ -1,7 +1,8 @@ /* === This file is part of Calamares - === * * Copyright 2014-2015, Teo Mrnjavac - * Copyright 2017, Adriaan de Groot + * Copyright 2017-2018, Adriaan de Groot + * 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