2017-12-20 14:39:09 +01:00
|
|
|
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
2015-09-10 18:21:51 +02:00
|
|
|
*
|
|
|
|
* Copyright 2015, Anke Boersma <demm@kaosx.us>
|
|
|
|
* Copyright 2015, Alexandre Arnt <qtgzmanager@gmail.com>
|
|
|
|
* Copyright 2015, Teo Mrnjavac <teo@kde.org>
|
2018-06-15 11:59:11 +02:00
|
|
|
* Copyright 2018, Adriaan de Groot <groot@kde.org>
|
2015-09-10 18:21:51 +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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "LicensePage.h"
|
|
|
|
|
|
|
|
#include "ui_LicensePage.h"
|
2019-04-21 13:36:28 +02:00
|
|
|
#include "LicenseWidget.h"
|
2019-04-20 17:43:19 +02:00
|
|
|
|
2015-09-10 18:21:51 +02:00
|
|
|
#include "JobQueue.h"
|
|
|
|
#include "GlobalStorage.h"
|
2019-04-20 17:43:19 +02:00
|
|
|
#include "ViewManager.h"
|
|
|
|
|
2019-03-22 19:31:39 +01:00
|
|
|
#include "utils/CalamaresUtils.h"
|
2015-09-10 18:21:51 +02:00
|
|
|
#include "utils/CalamaresUtilsGui.h"
|
2019-04-20 17:43:19 +02:00
|
|
|
#include "utils/Logger.h"
|
|
|
|
#include "utils/NamedEnum.h"
|
2015-09-10 18:21:51 +02:00
|
|
|
#include "utils/Retranslator.h"
|
|
|
|
|
|
|
|
#include <QApplication>
|
|
|
|
#include <QBoxLayout>
|
|
|
|
#include <QDesktopServices>
|
|
|
|
#include <QFocusEvent>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QComboBox>
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
2019-04-20 17:58:01 +02:00
|
|
|
#include <algorithm>
|
|
|
|
|
2019-04-20 17:52:22 +02:00
|
|
|
const NamedEnumTable< LicenseEntry::Type >&
|
|
|
|
LicenseEntry::typeNames()
|
2019-04-20 17:43:19 +02:00
|
|
|
{
|
|
|
|
static const NamedEnumTable< LicenseEntry::Type > names{
|
|
|
|
{ QStringLiteral( "software" ), LicenseEntry::Type::Software},
|
|
|
|
{ QStringLiteral( "driver" ), LicenseEntry::Type::Driver },
|
|
|
|
{ QStringLiteral( "gpudriver" ), LicenseEntry::Type::GpuDriver },
|
|
|
|
{ QStringLiteral( "browserplugin" ), LicenseEntry::Type::BrowserPlugin},
|
|
|
|
{ QStringLiteral( "codec" ), LicenseEntry::Type::Codec },
|
|
|
|
{ QStringLiteral( "package" ), LicenseEntry::Type::Package }
|
|
|
|
};
|
|
|
|
|
|
|
|
return names;
|
|
|
|
}
|
|
|
|
|
2019-03-22 19:31:39 +01:00
|
|
|
LicenseEntry::LicenseEntry(const QVariantMap& conf)
|
|
|
|
{
|
|
|
|
if ( !conf.contains( "id" ) || !conf.contains( "name" ) || !conf.contains( "url" ) )
|
|
|
|
return;
|
|
|
|
|
2019-04-20 17:52:22 +02:00
|
|
|
m_id = conf[ "id" ].toString();
|
|
|
|
m_prettyName = conf[ "name" ].toString();
|
|
|
|
m_prettyVendor = conf.value( "vendor" ).toString();
|
|
|
|
m_url = QUrl( conf[ "url" ].toString() );
|
2019-03-22 19:31:39 +01:00
|
|
|
|
2019-04-20 17:52:22 +02:00
|
|
|
m_required = CalamaresUtils::getBool( conf, "required", false );
|
2019-03-22 19:31:39 +01:00
|
|
|
|
2019-04-20 17:43:19 +02:00
|
|
|
bool ok = false;
|
2019-04-20 17:52:22 +02:00
|
|
|
QString typeString = conf.value( "type", "software" ).toString();
|
|
|
|
m_type = typeNames().find( typeString, ok );
|
|
|
|
if ( !ok )
|
|
|
|
cWarning() << "License entry" << m_id << "has unknown type" << typeString << "(using 'software')";
|
2019-03-22 19:31:39 +01:00
|
|
|
}
|
|
|
|
|
2015-09-10 18:21:51 +02:00
|
|
|
LicensePage::LicensePage(QWidget *parent)
|
|
|
|
: QWidget( parent )
|
|
|
|
, ui( new Ui::LicensePage )
|
|
|
|
, m_isNextEnabled( false )
|
|
|
|
{
|
|
|
|
ui->setupUi( this );
|
|
|
|
|
|
|
|
ui->verticalLayout->insertSpacing( 1, CalamaresUtils::defaultFontHeight() );
|
|
|
|
|
|
|
|
ui->mainText->setAlignment( Qt::AlignCenter );
|
|
|
|
ui->mainText->setWordWrap( true );
|
|
|
|
ui->mainText->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum );
|
|
|
|
|
|
|
|
ui->additionalText->setWordWrap( true );
|
|
|
|
|
|
|
|
ui->verticalLayout->insertSpacing( 4, CalamaresUtils::defaultFontHeight() / 2 );
|
|
|
|
|
|
|
|
ui->verticalLayout->setContentsMargins( CalamaresUtils::defaultFontHeight(),
|
|
|
|
CalamaresUtils::defaultFontHeight() * 3,
|
|
|
|
CalamaresUtils::defaultFontHeight(),
|
|
|
|
CalamaresUtils::defaultFontHeight() );
|
2018-06-15 11:59:11 +02:00
|
|
|
|
2015-09-10 18:21:51 +02:00
|
|
|
ui->acceptFrame->setFrameStyle( QFrame::NoFrame | QFrame::Plain );
|
|
|
|
ui->acceptFrame->setStyleSheet( "#acceptFrame { border: 1px solid red;"
|
|
|
|
"background-color: #fff6f6;"
|
|
|
|
"border-radius: 4px;"
|
|
|
|
"padding: 2px; }" );
|
|
|
|
ui->acceptFrame->layout()->setMargin( CalamaresUtils::defaultFontHeight() / 2 );
|
|
|
|
|
2019-04-20 21:21:15 +02:00
|
|
|
updateGlobalStorage( false ); // Have not agreed yet
|
|
|
|
|
|
|
|
connect( ui->acceptCheckBox, &QCheckBox::toggled, this, &LicensePage::checkAcceptance );
|
2015-09-10 18:21:51 +02:00
|
|
|
|
|
|
|
CALAMARES_RETRANSLATE(
|
|
|
|
ui->acceptCheckBox->setText( tr( "I accept the terms and conditions above." ) );
|
2019-04-17 11:57:46 +02:00
|
|
|
)
|
2015-09-10 18:21:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
LicensePage::setEntries( const QList< LicenseEntry >& entriesList )
|
|
|
|
{
|
|
|
|
CalamaresUtils::clearLayout( ui->licenseEntriesLayout );
|
|
|
|
|
2019-04-20 17:58:01 +02:00
|
|
|
const bool required = std::any_of( entriesList.cbegin(), entriesList.cend(), []( const LicenseEntry& e ){ return e.m_required; });
|
2019-04-20 21:21:15 +02:00
|
|
|
if ( entriesList.isEmpty() )
|
|
|
|
m_allLicensesOptional = true;
|
|
|
|
else
|
|
|
|
m_allLicensesOptional = !required;
|
2015-09-10 18:21:51 +02:00
|
|
|
|
2019-04-20 21:21:15 +02:00
|
|
|
checkAcceptance( false );
|
2015-09-10 18:21:51 +02:00
|
|
|
|
|
|
|
CALAMARES_RETRANSLATE(
|
|
|
|
if ( required )
|
|
|
|
{
|
|
|
|
ui->mainText->setText( tr( "<h1>License Agreement</h1>"
|
|
|
|
"This setup procedure will install proprietary "
|
|
|
|
"software that is subject to licensing terms." ) );
|
|
|
|
ui->additionalText->setText( tr( "Please review the End User License "
|
|
|
|
"Agreements (EULAs) above.<br/>"
|
|
|
|
"If you do not agree with the terms, the setup procedure cannot continue." ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui->mainText->setText( tr( "<h1>License Agreement</h1>"
|
|
|
|
"This setup procedure can install proprietary "
|
|
|
|
"software that is subject to licensing terms "
|
|
|
|
"in order to provide additional features and enhance the user "
|
|
|
|
"experience." ) );
|
|
|
|
ui->additionalText->setText( tr( "Please review the End User License "
|
|
|
|
"Agreements (EULAs) above.<br/>"
|
|
|
|
"If you do not agree with the terms, proprietary software will not "
|
|
|
|
"be installed, and open source alternatives will be used instead." ) );
|
|
|
|
}
|
|
|
|
ui->retranslateUi( this );
|
|
|
|
)
|
|
|
|
|
2016-09-01 14:21:05 +02:00
|
|
|
for ( const LicenseEntry& entry : entriesList )
|
2015-09-10 18:21:51 +02:00
|
|
|
{
|
2019-04-21 13:36:28 +02:00
|
|
|
ui->licenseEntriesLayout->addWidget( new LicenseWidget( entry ) );
|
2015-09-10 18:21:51 +02:00
|
|
|
}
|
|
|
|
ui->licenseEntriesLayout->addStretch();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
LicensePage::isNextEnabled() const
|
|
|
|
{
|
|
|
|
return m_isNextEnabled;
|
|
|
|
}
|
2019-04-20 21:21:15 +02:00
|
|
|
|
|
|
|
void
|
|
|
|
LicensePage::updateGlobalStorage( bool v )
|
|
|
|
{
|
|
|
|
Calamares::JobQueue::instance()->globalStorage()->insert( "licenseAgree", v );
|
|
|
|
}
|
|
|
|
|
|
|
|
void LicensePage::checkAcceptance( bool checked )
|
|
|
|
{
|
|
|
|
updateGlobalStorage( checked );
|
|
|
|
|
|
|
|
m_isNextEnabled = checked || m_allLicensesOptional;
|
|
|
|
if ( !m_isNextEnabled )
|
|
|
|
{
|
|
|
|
ui->acceptFrame->setStyleSheet( "#acceptFrame { border: 1px solid red;"
|
|
|
|
"background-color: #fff8f8;"
|
|
|
|
"border-radius: 4px;"
|
|
|
|
"padding: 2px; }" );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui->acceptFrame->setStyleSheet( "#acceptFrame { padding: 3px }" );
|
|
|
|
}
|
|
|
|
emit nextStatusChanged( checked );
|
|
|
|
}
|