calamares/src/modules/summary/SummaryPage.cpp

91 lines
2.3 KiB
C++
Raw Normal View History

2014-07-08 17:28:35 +02:00
/* === This file is part of Calamares - <http://github.com/calamares> ===
*
* Copyright 2014, Teo Mrnjavac <teo@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Calamares is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#include "SummaryPage.h"
#include "ViewManager.h"
#include "viewpages/ViewStep.h"
2014-07-08 17:28:35 +02:00
#include <QBoxLayout>
#include <QLabel>
static const int SECTION_SPACING = 12;
2014-07-08 17:28:35 +02:00
SummaryPage::SummaryPage( QWidget* parent )
: QWidget()
{
QVBoxLayout* layout = new QVBoxLayout( this );
layout->setContentsMargins( 0, 0, 0, 0 );
}
void
SummaryPage::onActivate()
{
createContentWidget();
QString text;
bool first = true;
foreach ( Calamares::ViewStep* step,
Calamares::ViewManager::instance()->prepareSteps() )
{
QString text = step->prettyStatus();
QWidget* widget = step->createSummaryWidget();
if ( text.isEmpty() && !widget )
continue;
if ( first )
first = false;
else
m_layout->addSpacing( SECTION_SPACING );
m_layout->addWidget( createTitleLabel( step->prettyName() ) );
if ( !text.isEmpty() )
m_layout->addWidget( createBodyLabel( text ) );
if ( widget )
m_layout->addWidget( widget );
}
m_layout->addStretch();
}
2014-07-08 17:28:35 +02:00
void
SummaryPage::createContentWidget()
{
delete m_contentWidget;
m_contentWidget = new QWidget;
m_layout = new QVBoxLayout( m_contentWidget );
layout()->addWidget( m_contentWidget );
}
QLabel*
SummaryPage::createTitleLabel( const QString& text ) const
{
QLabel* label = new QLabel( text );
QFont fnt = font();
fnt.setBold( true );
label->setFont( fnt );
return label;
}
QLabel*
SummaryPage::createBodyLabel( const QString& text ) const
{
return new QLabel( text );
2014-07-08 17:28:35 +02:00
}