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>
|
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
|
|
|
|
|
|
|
#include "utils/CalamaresUtilsGui.h"
|
2014-11-13 15:03:11 +01:00
|
|
|
#include "utils/Retranslator.h"
|
2014-10-16 16:59:29 +02:00
|
|
|
#include "Branding.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-05-15 13:09:57 +02:00
|
|
|
setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum );
|
|
|
|
|
2015-02-26 01:57:19 +01:00
|
|
|
QBoxLayout* mainLayout = new QVBoxLayout;
|
2014-08-21 17:50:37 +02:00
|
|
|
setLayout( mainLayout );
|
|
|
|
|
2014-08-26 15:18:30 +02:00
|
|
|
QHBoxLayout* spacerLayout = new QHBoxLayout;
|
|
|
|
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 )
|
|
|
|
{
|
2015-05-15 13:09:57 +02:00
|
|
|
CheckItemWidget* ciw = new CheckItemWidget( entry.checked );
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !allChecked )
|
|
|
|
{
|
|
|
|
QLabel* iconLabel = new QLabel;
|
|
|
|
QLabel* textLabel = new QLabel;
|
|
|
|
int iconSize = qBound( 32, CalamaresUtils::defaultFontHeight() * 6, 128 );
|
2015-05-15 13:09:57 +02:00
|
|
|
QHBoxLayout* iconLayout = new QHBoxLayout;
|
|
|
|
iconLayout->addStretch();
|
|
|
|
iconLayout->addWidget( iconLabel );
|
|
|
|
iconLayout->addStretch();
|
2014-08-26 18:23:55 +02:00
|
|
|
iconLabel->setFixedSize( iconSize, iconSize );
|
2015-05-15 13:09:57 +02:00
|
|
|
CalamaresUtils::unmarginLayout( iconLayout );
|
2014-08-26 18:23:55 +02:00
|
|
|
textLabel->setWordWrap( true );
|
2015-05-15 13:09:57 +02:00
|
|
|
m_entriesLayout->insertLayout( 0, iconLayout );
|
|
|
|
m_entriesLayout->insertWidget( 1, textLabel );
|
|
|
|
m_entriesLayout->insertSpacing( 2, CalamaresUtils::defaultFontHeight() / 2 );
|
2014-08-26 18:23:55 +02:00
|
|
|
textLabel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
|
|
|
|
|
|
|
|
if ( !requirementsSatisfied )
|
|
|
|
{
|
|
|
|
iconLabel->setPixmap( CalamaresUtils::defaultPixmap( CalamaresUtils::Fail,
|
|
|
|
CalamaresUtils::Original,
|
|
|
|
iconLabel->size() ) );
|
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>" )
|
2014-10-16 16:59:29 +02:00
|
|
|
.arg( Calamares::Branding::instance()->
|
|
|
|
string( 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
|
|
|
|
{
|
|
|
|
iconLabel->setPixmap( CalamaresUtils::defaultPixmap( CalamaresUtils::Information,
|
|
|
|
CalamaresUtils::Original,
|
|
|
|
iconLabel->size() ) );
|
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." )
|
2014-10-16 16:59:29 +02:00
|
|
|
.arg( Calamares::Branding::instance()->
|
|
|
|
string( 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
|
|
|
}
|
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 )
|
|
|
|
{
|
|
|
|
CheckItemWidget* ciw = new CheckItemWidget( entry.checked );
|
|
|
|
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();
|
|
|
|
}
|