[license] Apply current coding style

This commit is contained in:
Adriaan de Groot 2019-08-03 14:52:38 +02:00
parent 05daa22542
commit 042852218f
6 changed files with 89 additions and 86 deletions

View File

@ -21,11 +21,11 @@
#include "LicensePage.h"
#include "ui_LicensePage.h"
#include "LicenseWidget.h"
#include "ui_LicensePage.h"
#include "JobQueue.h"
#include "GlobalStorage.h"
#include "JobQueue.h"
#include "ViewManager.h"
#include "utils/CalamaresUtilsGui.h"
@ -36,10 +36,10 @@
#include <QApplication>
#include <QBoxLayout>
#include <QComboBox>
#include <QDesktopServices>
#include <QFocusEvent>
#include <QLabel>
#include <QComboBox>
#include <QMessageBox>
#include <algorithm>
@ -62,7 +62,9 @@ LicenseEntry::typeNames()
LicenseEntry::LicenseEntry( const QVariantMap& conf )
{
if ( !conf.contains( "id" ) || !conf.contains( "name" ) || !conf.contains( "url" ) )
{
return;
}
m_id = conf[ "id" ].toString();
m_prettyName = conf[ "name" ].toString();
@ -75,8 +77,10 @@ LicenseEntry::LicenseEntry(const QVariantMap& conf)
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')";
}
}
bool
LicenseEntry::isLocal() const
@ -119,9 +123,7 @@ LicensePage::LicensePage(QWidget *parent)
connect( ui->acceptCheckBox, &QCheckBox::toggled, this, &LicensePage::checkAcceptance );
CALAMARES_RETRANSLATE(
ui->acceptCheckBox->setText( tr( "I accept the terms and conditions above." ) );
)
CALAMARES_RETRANSLATE( ui->acceptCheckBox->setText( tr( "I accept the terms and conditions above." ) ); )
}
@ -132,26 +134,27 @@ LicensePage::setEntries( const QList< LicenseEntry >& entriesList )
m_entries.clear();
m_entries.reserve( entriesList.count() );
const bool required = std::any_of( entriesList.cbegin(), entriesList.cend(), []( const LicenseEntry& e ){ return e.m_required; });
const bool required
= std::any_of( entriesList.cbegin(), entriesList.cend(), []( const LicenseEntry& e ) { return e.m_required; } );
if ( entriesList.isEmpty() )
{
m_allLicensesOptional = true;
}
else
{
m_allLicensesOptional = !required;
}
checkAcceptance( false );
CALAMARES_RETRANSLATE(
if ( required )
{
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
{
} else {
ui->mainText->setText( tr( "<h1>License Agreement</h1>"
"This setup procedure can install proprietary "
"software that is subject to licensing terms "
@ -161,12 +164,10 @@ LicensePage::setEntries( const QList< LicenseEntry >& entriesList )
"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 );
} ui->retranslateUi( this );
for ( const auto& w : m_entries )
w->retranslateUi();
)
for ( const auto& w
: m_entries ) w->retranslateUi(); )
for ( const LicenseEntry& entry : entriesList )
{
@ -190,7 +191,8 @@ LicensePage::updateGlobalStorage( bool v )
Calamares::JobQueue::instance()->globalStorage()->insert( "licenseAgree", v );
}
void LicensePage::checkAcceptance( bool checked )
void
LicensePage::checkAcceptance( bool checked )
{
updateGlobalStorage( checked );

View File

@ -24,8 +24,8 @@
#include "utils/NamedEnum.h"
#include <QWidget>
#include <QUrl>
#include <QWidget>
namespace Ui
{

View File

@ -19,9 +19,9 @@
#include "LicenseViewStep.h"
#include "LicensePage.h"
#include "JobQueue.h"
#include "GlobalStorage.h"
#include "JobQueue.h"
#include "LicensePage.h"
#include "utils/Logger.h"
#include <QVariantMap>
@ -33,16 +33,17 @@ LicenseViewStep::LicenseViewStep( QObject* parent )
, m_widget( new LicensePage )
{
emit nextStatusChanged( false );
connect( m_widget, &LicensePage::nextStatusChanged,
this, &LicenseViewStep::nextStatusChanged );
connect( m_widget, &LicensePage::nextStatusChanged, this, &LicenseViewStep::nextStatusChanged );
}
LicenseViewStep::~LicenseViewStep()
{
if ( m_widget && m_widget->parent() == nullptr )
{
m_widget->deleteLater();
}
}
QString
@ -97,20 +98,23 @@ void
LicenseViewStep::setConfigurationMap( const QVariantMap& configurationMap )
{
QList< LicenseEntry > entriesList;
if ( configurationMap.contains( "entries" ) &&
configurationMap.value( "entries" ).type() == QVariant::List )
if ( configurationMap.contains( "entries" ) && configurationMap.value( "entries" ).type() == QVariant::List )
{
const auto entries = configurationMap.value( "entries" ).toList();
for ( const QVariant& entryV : entries )
{
if ( entryV.type() != QVariant::Map )
{
continue;
}
LicenseEntry entry( entryV.toMap() );
if ( entry.isValid() )
{
entriesList.append( entry );
}
}
}
m_widget->setEntries( entriesList );
}

View File

@ -20,9 +20,9 @@
#ifndef LICENSEPAGEPLUGIN_H
#define LICENSEPAGEPLUGIN_H
#include <PluginDllMacro.h>
#include <utils/PluginFactory.h>
#include <viewpages/ViewStep.h>
#include <PluginDllMacro.h>
#include <QObject>
#include <QUrl>

View File

@ -34,7 +34,9 @@ static QString
loadLocalFile( const QUrl& u )
{
if ( !u.isLocalFile() )
{
return QString();
}
QFile file( u.path() );
if ( !file.open( QIODevice::ReadOnly | QIODevice::Text ) )
@ -108,11 +110,10 @@ LicenseWidget::LicenseWidget( LicenseEntry entry, QWidget* parent )
retranslateUi();
}
LicenseWidget::~LicenseWidget()
{
}
LicenseWidget::~LicenseWidget() {}
void LicenseWidget::retranslateUi()
void
LicenseWidget::retranslateUi()
{
QString productDescription;
switch ( m_entry.m_type )
@ -173,7 +174,9 @@ LicenseWidget::expandClicked()
// Show/hide based on the new arrow direction.
if ( m_fullText )
{
m_fullText->setHidden( m_expandLicenseButton->arrowType() == Qt::UpArrow );
}
updateExpandToolTip();
}
@ -186,21 +189,15 @@ LicenseWidget::updateExpandToolTip()
{
const bool isNowCollapsed = m_expandLicenseButton->arrowType() == Qt::UpArrow;
m_expandLicenseButton->setToolTip(
isNowCollapsed
? tr( "Shows the complete license text" )
: tr( "Hide license text" )
) ;
m_viewLicenseLabel->setText(
isNowCollapsed
? tr( "Show license agreement" )
: tr( "Hide license agreement" ) );
m_expandLicenseButton->setToolTip( isNowCollapsed ? tr( "Shows the complete license text" )
: tr( "Hide license text" ) );
m_viewLicenseLabel->setText( isNowCollapsed ? tr( "Show license agreement" ) : tr( "Hide license agreement" ) );
}
else
{
m_expandLicenseButton->setToolTip( tr( "Opens the license agreement in a browser window." ) );
m_viewLicenseLabel->setText( tr( "<a href=\"%1\">View license agreement</a>" )
.arg( m_entry.m_url.toString() ) );
m_viewLicenseLabel->setText(
tr( "<a href=\"%1\">View license agreement</a>" ).arg( m_entry.m_url.toString() ) );
}
}