[license] Tidy code
- Move retranslation to a separate slot to allow it to be formatted nicely. - Use calculated m_allLicensesOptional in retranslation. - Untangle determining if all licenses are optional; std::none_of returns true on an empty list.
This commit is contained in:
parent
fae1fdae1c
commit
ec605adf3f
@ -126,7 +126,6 @@ LicensePage::LicensePage( QWidget* parent )
|
|||||||
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." ) ); )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
LicensePage::setEntries( const QList< LicenseEntry >& entriesList )
|
LicensePage::setEntries( const QList< LicenseEntry >& entriesList )
|
||||||
{
|
{
|
||||||
@ -134,27 +133,36 @@ LicensePage::setEntries( const QList< LicenseEntry >& entriesList )
|
|||||||
m_entries.clear();
|
m_entries.clear();
|
||||||
m_entries.reserve( entriesList.count() );
|
m_entries.reserve( entriesList.count() );
|
||||||
|
|
||||||
const bool required
|
auto isRequired = []( const LicenseEntry& e ) { return e.m_required; };
|
||||||
= std::any_of( entriesList.cbegin(), entriesList.cend(), []( const LicenseEntry& e ) { return e.m_required; } );
|
m_allLicensesOptional = std::none_of( entriesList.cbegin(), entriesList.cend(), isRequired );
|
||||||
if ( entriesList.isEmpty() )
|
|
||||||
{
|
|
||||||
m_allLicensesOptional = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_allLicensesOptional = !required;
|
|
||||||
}
|
|
||||||
|
|
||||||
checkAcceptance( false );
|
checkAcceptance( false );
|
||||||
|
|
||||||
CALAMARES_RETRANSLATE( if ( required ) {
|
for ( const LicenseEntry& entry : entriesList )
|
||||||
|
{
|
||||||
|
LicenseWidget* w = new LicenseWidget( entry );
|
||||||
|
ui->licenseEntriesLayout->addWidget( w );
|
||||||
|
m_entries.append( w );
|
||||||
|
}
|
||||||
|
ui->licenseEntriesLayout->addStretch();
|
||||||
|
|
||||||
|
CALAMARES_RETRANSLATE_SLOT( &LicensePage::retranslate )
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
LicensePage::retranslate()
|
||||||
|
{
|
||||||
|
if ( !m_allLicensesOptional )
|
||||||
|
{
|
||||||
ui->mainText->setText( tr( "<h1>License Agreement</h1>"
|
ui->mainText->setText( tr( "<h1>License Agreement</h1>"
|
||||||
"This setup procedure will install proprietary "
|
"This setup procedure will install proprietary "
|
||||||
"software that is subject to licensing terms." ) );
|
"software that is subject to licensing terms." ) );
|
||||||
ui->additionalText->setText( tr( "Please review the End User License "
|
ui->additionalText->setText( tr( "Please review the End User License "
|
||||||
"Agreements (EULAs) above.<br/>"
|
"Agreements (EULAs) above.<br/>"
|
||||||
"If you do not agree with the terms, the setup procedure cannot continue." ) );
|
"If you do not agree with the terms, the setup procedure cannot continue." ) );
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
ui->mainText->setText( tr( "<h1>License Agreement</h1>"
|
ui->mainText->setText( tr( "<h1>License Agreement</h1>"
|
||||||
"This setup procedure can install proprietary "
|
"This setup procedure can install proprietary "
|
||||||
"software that is subject to licensing terms "
|
"software that is subject to licensing terms "
|
||||||
@ -164,18 +172,13 @@ LicensePage::setEntries( const QList< LicenseEntry >& entriesList )
|
|||||||
"Agreements (EULAs) above.<br/>"
|
"Agreements (EULAs) above.<br/>"
|
||||||
"If you do not agree with the terms, proprietary software will not "
|
"If you do not agree with the terms, proprietary software will not "
|
||||||
"be installed, and open source alternatives will be used instead." ) );
|
"be installed, and open source alternatives will be used instead." ) );
|
||||||
} ui->retranslateUi( this );
|
|
||||||
|
|
||||||
for ( const auto& w
|
|
||||||
: m_entries ) w->retranslateUi(); )
|
|
||||||
|
|
||||||
for ( const LicenseEntry& entry : entriesList )
|
|
||||||
{
|
|
||||||
LicenseWidget* w = new LicenseWidget( entry );
|
|
||||||
ui->licenseEntriesLayout->addWidget( w );
|
|
||||||
m_entries.append( w );
|
|
||||||
}
|
}
|
||||||
ui->licenseEntriesLayout->addStretch();
|
ui->retranslateUi( this );
|
||||||
|
|
||||||
|
for ( const auto& w : m_entries )
|
||||||
|
{
|
||||||
|
w->retranslateUi();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -83,10 +83,13 @@ public slots:
|
|||||||
* - the user has ticked the "OK" box.
|
* - the user has ticked the "OK" box.
|
||||||
* This function calls updateGlobalStorage() as needed, and updates
|
* This function calls updateGlobalStorage() as needed, and updates
|
||||||
* the appearance of the page as needed. @p checked indicates whether
|
* the appearance of the page as needed. @p checked indicates whether
|
||||||
* the checkbox has been ticked or not.
|
* the checkbox has been ticked or not. (e.g. when @p checked is true,
|
||||||
|
* you can continue regardless)
|
||||||
*/
|
*/
|
||||||
void checkAcceptance( bool checked );
|
void checkAcceptance( bool checked );
|
||||||
|
|
||||||
|
void retranslate();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void nextStatusChanged( bool status );
|
void nextStatusChanged( bool status );
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user