From 51f74315f6f3885e7e885064f3458797e3afa754 Mon Sep 17 00:00:00 2001 From: Teo Mrnjavac Date: Fri, 15 May 2015 13:09:57 +0200 Subject: [PATCH] Refactor CheckerWidget for better integration with Welcome page. --- src/modules/welcome/checker/CheckerWidget.cpp | 45 ++++++++++--------- src/modules/welcome/checker/CheckerWidget.h | 1 + 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/src/modules/welcome/checker/CheckerWidget.cpp b/src/modules/welcome/checker/CheckerWidget.cpp index 8bfe3c716..7e3fdb62e 100644 --- a/src/modules/welcome/checker/CheckerWidget.cpp +++ b/src/modules/welcome/checker/CheckerWidget.cpp @@ -29,25 +29,21 @@ CheckerWidget::CheckerWidget( QWidget* parent ) - : QWidget() + : QWidget( parent ) { + setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ); + QBoxLayout* mainLayout = new QVBoxLayout; setLayout( mainLayout ); - QLabel* text = new QLabel( this ); - CALAMARES_RETRANSLATE( - text->setText( tr( "For best results, please ensure that this computer:" ) ); - ) - - mainLayout->addSpacing( CalamaresUtils::defaultFontHeight() ); - mainLayout->addWidget( text ); QHBoxLayout* spacerLayout = new QHBoxLayout; mainLayout->addLayout( spacerLayout ); - spacerLayout->addSpacing( CalamaresUtils::defaultFontHeight() * 2 ); + m_paddingSize = qBound( 32, CalamaresUtils::defaultFontHeight() * 4, 128 ); + spacerLayout->addSpacing( m_paddingSize ); m_entriesLayout = new QVBoxLayout; spacerLayout->addLayout( m_entriesLayout ); + spacerLayout->addSpacing( m_paddingSize ); CalamaresUtils::unmarginLayout( spacerLayout ); - mainLayout->addStretch(); } @@ -59,32 +55,41 @@ CheckerWidget::init( const QList< PrepareEntry >& checkEntries ) for ( const PrepareEntry& entry : checkEntries ) { - CheckItemWidget* ciw = new CheckItemWidget( entry.checked ); - CALAMARES_RETRANSLATE( ciw->setText( entry.text() ); ) - m_entriesLayout->addWidget( ciw ); - ciw->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); - if ( !entry.checked ) { + CheckItemWidget* ciw = new CheckItemWidget( entry.checked ); + CALAMARES_RETRANSLATE( ciw->setText( entry.negatedText() ); ) + m_entriesLayout->addWidget( ciw ); + ciw->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); + allChecked = false; if ( entry.required ) { requirementsSatisfied = false; } + ciw->setAutoFillBackground( true ); + QPalette pal( ciw->palette() ); + pal.setColor( QPalette::Background, Qt::white ); + ciw->setPalette( pal ); + } } if ( !allChecked ) { - QBoxLayout* mainLayout = dynamic_cast< QBoxLayout* >( layout() ); - QBoxLayout* infoLayout = new QHBoxLayout; QLabel* iconLabel = new QLabel; QLabel* textLabel = new QLabel; int iconSize = qBound( 32, CalamaresUtils::defaultFontHeight() * 6, 128 ); + QHBoxLayout* iconLayout = new QHBoxLayout; + iconLayout->addStretch(); + iconLayout->addWidget( iconLabel ); + iconLayout->addStretch(); iconLabel->setFixedSize( iconSize, iconSize ); + CalamaresUtils::unmarginLayout( iconLayout ); textLabel->setWordWrap( true ); - infoLayout->addWidget( iconLabel ); - infoLayout->addWidget( textLabel ); + m_entriesLayout->insertLayout( 0, iconLayout ); + m_entriesLayout->insertWidget( 1, textLabel ); + m_entriesLayout->insertSpacing( 2, CalamaresUtils::defaultFontHeight() / 2 ); textLabel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); if ( !requirementsSatisfied ) @@ -114,7 +119,5 @@ CheckerWidget::init( const QList< PrepareEntry >& checkEntries ) string( Calamares::Branding::ShortVersionedName ) ) ); ) } - - mainLayout->insertLayout( mainLayout->count(), infoLayout ); } } diff --git a/src/modules/welcome/checker/CheckerWidget.h b/src/modules/welcome/checker/CheckerWidget.h index 2fc50edbd..e2295411a 100644 --- a/src/modules/welcome/checker/CheckerWidget.h +++ b/src/modules/welcome/checker/CheckerWidget.h @@ -34,6 +34,7 @@ public: private: QBoxLayout* m_entriesLayout; + int m_paddingSize; }; #endif // CHECKERWIDGET_H