From 4c6f42ecfadda716442874d945a6c312ccffe559 Mon Sep 17 00:00:00 2001 From: Raul Rodrigo Segura Date: Sun, 20 May 2018 16:28:31 +0200 Subject: [PATCH] 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 );