mirror of
https://github.com/parchlinux/calamares.git
synced 2025-02-24 19:05:46 -05:00
[license] Apply current coding style
This commit is contained in:
parent
05daa22542
commit
042852218f
6 changed files with 89 additions and 86 deletions
|
@ -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>
|
||||
|
@ -47,11 +47,11 @@
|
|||
const NamedEnumTable< LicenseEntry::Type >&
|
||||
LicenseEntry::typeNames()
|
||||
{
|
||||
static const NamedEnumTable< LicenseEntry::Type > names{
|
||||
{ QStringLiteral( "software" ), LicenseEntry::Type::Software},
|
||||
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( "browserplugin" ), LicenseEntry::Type::BrowserPlugin },
|
||||
{ QStringLiteral( "codec" ), LicenseEntry::Type::Codec },
|
||||
{ QStringLiteral( "package" ), LicenseEntry::Type::Package }
|
||||
};
|
||||
|
@ -59,10 +59,12 @@ LicenseEntry::typeNames()
|
|||
return names;
|
||||
}
|
||||
|
||||
LicenseEntry::LicenseEntry(const QVariantMap& conf)
|
||||
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,7 +77,9 @@ 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
|
||||
|
@ -85,7 +89,7 @@ LicenseEntry::isLocal() const
|
|||
}
|
||||
|
||||
|
||||
LicensePage::LicensePage(QWidget *parent)
|
||||
LicensePage::LicensePage( QWidget* parent )
|
||||
: QWidget( parent )
|
||||
, m_isNextEnabled( false )
|
||||
, m_allLicensesOptional( false )
|
||||
|
@ -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,41 +134,40 @@ 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 )
|
||||
{
|
||||
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 );
|
||||
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 );
|
||||
|
||||
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 );
|
||||
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
|
||||
#include "utils/NamedEnum.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include <QUrl>
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
|
@ -101,4 +101,4 @@ private:
|
|||
QList< LicenseWidget* > m_entries;
|
||||
};
|
||||
|
||||
#endif //LICENSEPAGE_H
|
||||
#endif //LICENSEPAGE_H
|
||||
|
|
|
@ -19,29 +19,30 @@
|
|||
|
||||
#include "LicenseViewStep.h"
|
||||
|
||||
#include "LicensePage.h"
|
||||
#include "JobQueue.h"
|
||||
#include "GlobalStorage.h"
|
||||
#include "JobQueue.h"
|
||||
#include "LicensePage.h"
|
||||
#include "utils/Logger.h"
|
||||
|
||||
#include <QVariantMap>
|
||||
|
||||
CALAMARES_PLUGIN_FACTORY_DEFINITION( LicenseViewStepFactory, registerPlugin<LicenseViewStep>(); )
|
||||
CALAMARES_PLUGIN_FACTORY_DEFINITION( LicenseViewStepFactory, registerPlugin< LicenseViewStep >(); )
|
||||
|
||||
LicenseViewStep::LicenseViewStep( QObject* parent )
|
||||
: Calamares::ViewStep( 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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -97,18 +98,21 @@ 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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
@ -58,4 +58,4 @@ private:
|
|||
|
||||
CALAMARES_PLUGIN_FACTORY_DECLARATION( LicenseViewStepFactory )
|
||||
|
||||
#endif // LICENSEPAGEPLUGIN_H
|
||||
#endif // LICENSEPAGEPLUGIN_H
|
||||
|
|
|
@ -34,10 +34,12 @@ static QString
|
|||
loadLocalFile( const QUrl& u )
|
||||
{
|
||||
if ( !u.isLocalFile() )
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
|
||||
QFile file( u.path() );
|
||||
if ( !file.open(QIODevice::ReadOnly | QIODevice::Text) )
|
||||
if ( !file.open( QIODevice::ReadOnly | QIODevice::Text ) )
|
||||
{
|
||||
cWarning() << "Could not load license file" << u.path();
|
||||
return QString();
|
||||
|
@ -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 )
|
||||
|
@ -120,40 +121,40 @@ void LicenseWidget::retranslateUi()
|
|||
case LicenseEntry::Type::Driver:
|
||||
//: %1 is an untranslatable product name, example: Creative Audigy driver
|
||||
productDescription = tr( "<strong>%1 driver</strong><br/>"
|
||||
"by %2" )
|
||||
.arg( m_entry.m_prettyName )
|
||||
.arg( m_entry.m_prettyVendor );
|
||||
"by %2" )
|
||||
.arg( m_entry.m_prettyName )
|
||||
.arg( m_entry.m_prettyVendor );
|
||||
break;
|
||||
case LicenseEntry::Type::GpuDriver:
|
||||
//: %1 is usually a vendor name, example: Nvidia graphics driver
|
||||
productDescription = tr( "<strong>%1 graphics driver</strong><br/>"
|
||||
"<font color=\"Grey\">by %2</font>" )
|
||||
.arg( m_entry.m_prettyName )
|
||||
.arg( m_entry.m_prettyVendor );
|
||||
"<font color=\"Grey\">by %2</font>" )
|
||||
.arg( m_entry.m_prettyName )
|
||||
.arg( m_entry.m_prettyVendor );
|
||||
break;
|
||||
case LicenseEntry::Type::BrowserPlugin:
|
||||
productDescription = tr( "<strong>%1 browser plugin</strong><br/>"
|
||||
"<font color=\"Grey\">by %2</font>" )
|
||||
.arg( m_entry.m_prettyName )
|
||||
.arg( m_entry.m_prettyVendor );
|
||||
"<font color=\"Grey\">by %2</font>" )
|
||||
.arg( m_entry.m_prettyName )
|
||||
.arg( m_entry.m_prettyVendor );
|
||||
break;
|
||||
case LicenseEntry::Type::Codec:
|
||||
productDescription = tr( "<strong>%1 codec</strong><br/>"
|
||||
"<font color=\"Grey\">by %2</font>" )
|
||||
.arg( m_entry.m_prettyName )
|
||||
.arg( m_entry.m_prettyVendor );
|
||||
"<font color=\"Grey\">by %2</font>" )
|
||||
.arg( m_entry.m_prettyName )
|
||||
.arg( m_entry.m_prettyVendor );
|
||||
break;
|
||||
case LicenseEntry::Type::Package:
|
||||
productDescription = tr( "<strong>%1 package</strong><br/>"
|
||||
"<font color=\"Grey\">by %2</font>" )
|
||||
.arg( m_entry.m_prettyName )
|
||||
.arg( m_entry.m_prettyVendor );
|
||||
"<font color=\"Grey\">by %2</font>" )
|
||||
.arg( m_entry.m_prettyName )
|
||||
.arg( m_entry.m_prettyVendor );
|
||||
break;
|
||||
case LicenseEntry::Type::Software:
|
||||
productDescription = tr( "<strong>%1</strong><br/>"
|
||||
"<font color=\"Grey\">by %2</font>" )
|
||||
.arg( m_entry.m_prettyName )
|
||||
.arg( m_entry.m_prettyVendor );
|
||||
"<font color=\"Grey\">by %2</font>" )
|
||||
.arg( m_entry.m_prettyName )
|
||||
.arg( m_entry.m_prettyVendor );
|
||||
}
|
||||
m_label->setText( productDescription );
|
||||
updateExpandToolTip();
|
||||
|
@ -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() ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ public:
|
|||
|
||||
private:
|
||||
void expandClicked(); // "slot" to toggle show/hide of local license text
|
||||
void viewClicked(); // "slot" to open link
|
||||
void viewClicked(); // "slot" to open link
|
||||
void updateExpandToolTip();
|
||||
|
||||
LicenseEntry m_entry;
|
||||
|
@ -47,5 +47,5 @@ private:
|
|||
QLabel* m_viewLicenseLabel;
|
||||
QToolButton* m_expandLicenseButton;
|
||||
QLabel* m_fullText;
|
||||
} ;
|
||||
};
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue