2014-08-21 17:50:37 +02:00
|
|
|
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
|
|
|
*
|
2015-05-14 18:00:26 +02:00
|
|
|
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
|
2017-07-04 00:07:18 +02:00
|
|
|
* Copyright 2017, Adriaan de Groot <groot@kde.org>
|
2014-08-21 17:50:37 +02:00
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2015-05-14 18:00:26 +02:00
|
|
|
#include "CheckerWidget.h"
|
2014-08-21 17:50:37 +02:00
|
|
|
|
2015-05-14 18:00:26 +02:00
|
|
|
#include "CheckItemWidget.h"
|
2014-08-26 15:18:30 +02:00
|
|
|
|
2015-06-20 01:05:55 +02:00
|
|
|
#include "Branding.h"
|
2014-08-26 15:18:30 +02:00
|
|
|
#include "utils/CalamaresUtilsGui.h"
|
2014-11-13 15:03:11 +01:00
|
|
|
#include "utils/Retranslator.h"
|
2015-06-20 01:05:55 +02:00
|
|
|
#include "widgets/FixedAspectRatioLabel.h"
|
2014-08-26 15:18:30 +02:00
|
|
|
|
2015-05-15 18:14:39 +02:00
|
|
|
#include <QAbstractButton>
|
2014-08-21 17:50:37 +02:00
|
|
|
#include <QBoxLayout>
|
2015-05-15 18:14:39 +02:00
|
|
|
#include <QDialog>
|
|
|
|
#include <QDialogButtonBox>
|
2014-08-21 17:50:37 +02:00
|
|
|
#include <QLabel>
|
|
|
|
|
|
|
|
|
2015-05-14 18:00:26 +02:00
|
|
|
CheckerWidget::CheckerWidget( QWidget* parent )
|
2015-05-15 13:09:57 +02:00
|
|
|
: QWidget( parent )
|
2014-08-21 17:50:37 +02:00
|
|
|
{
|
2015-06-20 01:05:55 +02:00
|
|
|
setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
|
2015-05-15 13:09:57 +02:00
|
|
|
|
2015-06-20 01:05:55 +02:00
|
|
|
m_mainLayout = new QVBoxLayout;
|
|
|
|
setLayout( m_mainLayout );
|
2014-08-21 17:50:37 +02:00
|
|
|
|
2014-08-26 15:18:30 +02:00
|
|
|
QHBoxLayout* spacerLayout = new QHBoxLayout;
|
2015-06-20 01:05:55 +02:00
|
|
|
m_mainLayout->addLayout( spacerLayout );
|
2015-05-15 13:09:57 +02:00
|
|
|
m_paddingSize = qBound( 32, CalamaresUtils::defaultFontHeight() * 4, 128 );
|
|
|
|
spacerLayout->addSpacing( m_paddingSize );
|
2014-08-26 15:18:30 +02:00
|
|
|
m_entriesLayout = new QVBoxLayout;
|
|
|
|
spacerLayout->addLayout( m_entriesLayout );
|
2015-05-15 13:09:57 +02:00
|
|
|
spacerLayout->addSpacing( m_paddingSize );
|
2014-08-26 15:18:30 +02:00
|
|
|
CalamaresUtils::unmarginLayout( spacerLayout );
|
2014-08-21 17:50:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2015-05-14 18:00:26 +02:00
|
|
|
CheckerWidget::init( const QList< PrepareEntry >& checkEntries )
|
2014-08-21 17:50:37 +02:00
|
|
|
{
|
2014-08-26 18:23:55 +02:00
|
|
|
bool allChecked = true;
|
|
|
|
bool requirementsSatisfied = true;
|
|
|
|
|
2014-08-26 17:26:40 +02:00
|
|
|
for ( const PrepareEntry& entry : checkEntries )
|
2014-08-26 15:18:30 +02:00
|
|
|
{
|
2014-08-26 18:23:55 +02:00
|
|
|
if ( !entry.checked )
|
|
|
|
{
|
2017-11-20 14:50:15 +01:00
|
|
|
CheckItemWidget* ciw = new CheckItemWidget( entry.checked, entry.required );
|
2015-05-15 13:09:57 +02:00
|
|
|
CALAMARES_RETRANSLATE( ciw->setText( entry.negatedText() ); )
|
|
|
|
m_entriesLayout->addWidget( ciw );
|
|
|
|
ciw->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
|
|
|
|
|
2014-08-26 18:23:55 +02:00
|
|
|
allChecked = false;
|
|
|
|
if ( entry.required )
|
|
|
|
{
|
|
|
|
requirementsSatisfied = false;
|
|
|
|
}
|
2015-05-15 13:09:57 +02:00
|
|
|
ciw->setAutoFillBackground( true );
|
|
|
|
QPalette pal( ciw->palette() );
|
|
|
|
pal.setColor( QPalette::Background, Qt::white );
|
|
|
|
ciw->setPalette( pal );
|
|
|
|
|
2014-08-26 18:23:55 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-09 02:35:22 +02:00
|
|
|
QLabel* textLabel = new QLabel;
|
|
|
|
|
|
|
|
textLabel->setWordWrap( true );
|
|
|
|
m_entriesLayout->insertWidget( 0, textLabel );
|
|
|
|
textLabel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
|
|
|
|
|
2014-08-26 18:23:55 +02:00
|
|
|
if ( !allChecked )
|
|
|
|
{
|
2015-05-18 12:46:51 +02:00
|
|
|
m_entriesLayout->insertSpacing( 1, CalamaresUtils::defaultFontHeight() / 2 );
|
2014-08-26 18:23:55 +02:00
|
|
|
|
|
|
|
if ( !requirementsSatisfied )
|
|
|
|
{
|
2014-11-13 15:03:11 +01:00
|
|
|
CALAMARES_RETRANSLATE(
|
|
|
|
textLabel->setText( tr( "This computer does not satisfy the minimum "
|
2015-05-15 18:14:39 +02:00
|
|
|
"requirements for installing %1.<br/>"
|
|
|
|
"Installation cannot continue. "
|
|
|
|
"<a href=\"#details\">Details...</a>" )
|
2017-07-04 00:07:18 +02:00
|
|
|
.arg( *Calamares::Branding::ShortVersionedName ) );
|
2014-11-13 15:03:11 +01:00
|
|
|
)
|
2015-05-15 18:14:39 +02:00
|
|
|
textLabel->setOpenExternalLinks( false );
|
|
|
|
connect( textLabel, &QLabel::linkActivated,
|
|
|
|
this, [ this, checkEntries ]( const QString& link )
|
|
|
|
{
|
|
|
|
if ( link == "#details" )
|
|
|
|
showDetailsDialog( checkEntries );
|
|
|
|
} );
|
2014-08-26 18:23:55 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-11-13 15:03:11 +01:00
|
|
|
CALAMARES_RETRANSLATE(
|
|
|
|
textLabel->setText( tr( "This computer does not satisfy some of the "
|
2015-05-15 18:14:39 +02:00
|
|
|
"recommended requirements for installing %1.<br/>"
|
2014-11-13 15:03:11 +01:00
|
|
|
"Installation can continue, but some features "
|
|
|
|
"might be disabled." )
|
2017-07-04 00:07:18 +02:00
|
|
|
.arg( *Calamares::Branding::ShortVersionedName ) );
|
2014-11-13 15:03:11 +01:00
|
|
|
)
|
2014-08-26 18:23:55 +02:00
|
|
|
}
|
2014-08-26 15:18:30 +02:00
|
|
|
}
|
2015-06-09 02:35:22 +02:00
|
|
|
|
|
|
|
if ( allChecked && requirementsSatisfied )
|
|
|
|
{
|
2015-06-20 00:19:12 +02:00
|
|
|
if ( !Calamares::Branding::instance()->
|
|
|
|
imagePath( Calamares::Branding::ProductWelcome ).isEmpty() )
|
|
|
|
{
|
|
|
|
QPixmap theImage = QPixmap( Calamares::Branding::instance()->
|
|
|
|
imagePath( Calamares::Branding::ProductWelcome ) );
|
|
|
|
if ( !theImage.isNull() )
|
|
|
|
{
|
2017-07-04 10:30:08 +02:00
|
|
|
QLabel* imageLabel;
|
|
|
|
if ( Calamares::Branding::instance()->welcomeExpandingLogo() )
|
|
|
|
{
|
|
|
|
FixedAspectRatioLabel *p = new FixedAspectRatioLabel;
|
|
|
|
p->setPixmap( theImage );
|
|
|
|
imageLabel = p;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
imageLabel = new QLabel;
|
|
|
|
imageLabel->setPixmap( theImage );
|
|
|
|
}
|
|
|
|
|
2017-06-27 15:28:32 +02:00
|
|
|
imageLabel->setContentsMargins( 4, CalamaresUtils::defaultFontHeight() * 3 / 4, 4, 4 );
|
2015-06-20 01:05:55 +02:00
|
|
|
m_mainLayout->addWidget( imageLabel );
|
2015-06-20 00:19:12 +02:00
|
|
|
imageLabel->setAlignment( Qt::AlignCenter );
|
2015-06-20 01:05:55 +02:00
|
|
|
imageLabel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
|
2015-06-20 00:19:12 +02:00
|
|
|
}
|
|
|
|
}
|
2015-06-09 02:35:22 +02:00
|
|
|
CALAMARES_RETRANSLATE(
|
|
|
|
textLabel->setText( tr( "This program will ask you some questions and "
|
|
|
|
"set up %2 on your computer." )
|
2017-07-04 00:07:18 +02:00
|
|
|
.arg( *Calamares::Branding::ProductName ) );
|
2015-06-09 02:35:22 +02:00
|
|
|
textLabel->setAlignment( Qt::AlignCenter );
|
|
|
|
)
|
|
|
|
}
|
2015-06-20 01:05:55 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
m_mainLayout->addStretch();
|
|
|
|
}
|
2014-08-21 17:50:37 +02:00
|
|
|
}
|
2015-05-15 18:14:39 +02:00
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
CheckerWidget::showDetailsDialog( const QList< PrepareEntry >& checkEntries )
|
|
|
|
{
|
|
|
|
QDialog* detailsDialog = new QDialog( this );
|
|
|
|
QBoxLayout* mainLayout = new QVBoxLayout;
|
|
|
|
detailsDialog->setLayout( mainLayout );
|
|
|
|
|
|
|
|
QLabel* textLabel = new QLabel;
|
|
|
|
mainLayout->addWidget( textLabel );
|
|
|
|
CALAMARES_RETRANSLATE(
|
|
|
|
textLabel->setText( tr( "For best results, please ensure that this computer:" ) );
|
|
|
|
)
|
|
|
|
QBoxLayout* entriesLayout = new QVBoxLayout;
|
|
|
|
CalamaresUtils::unmarginLayout( entriesLayout );
|
|
|
|
mainLayout->addLayout( entriesLayout );
|
|
|
|
|
|
|
|
for ( const PrepareEntry& entry : checkEntries )
|
|
|
|
{
|
2015-06-09 02:35:22 +02:00
|
|
|
if ( entry.enumerationText().isEmpty() )
|
|
|
|
continue;
|
|
|
|
|
2017-11-20 14:50:15 +01:00
|
|
|
CheckItemWidget* ciw = new CheckItemWidget( entry.checked, entry.required );
|
2015-05-15 18:14:39 +02:00
|
|
|
CALAMARES_RETRANSLATE( ciw->setText( entry.enumerationText() ); )
|
|
|
|
entriesLayout->addWidget( ciw );
|
|
|
|
ciw->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
|
|
|
|
|
|
|
|
ciw->setAutoFillBackground( true );
|
|
|
|
QPalette pal( ciw->palette() );
|
|
|
|
pal.setColor( QPalette::Background, Qt::white );
|
|
|
|
ciw->setPalette( pal );
|
|
|
|
}
|
|
|
|
|
|
|
|
QDialogButtonBox* buttonBox = new QDialogButtonBox( QDialogButtonBox::Close,
|
|
|
|
Qt::Horizontal,
|
|
|
|
this );
|
|
|
|
mainLayout->addWidget( buttonBox );
|
|
|
|
|
|
|
|
detailsDialog->setModal( true );
|
2015-05-16 19:39:52 +02:00
|
|
|
detailsDialog->setWindowTitle( tr( "System requirements" ) );
|
2015-05-15 18:14:39 +02:00
|
|
|
|
|
|
|
connect( buttonBox, &QDialogButtonBox::clicked,
|
|
|
|
detailsDialog, &QDialog::close );
|
|
|
|
detailsDialog->exec();
|
|
|
|
detailsDialog->deleteLater();
|
|
|
|
}
|