[license] Handle the case where all the licenses are optional
- If all of the licenses are optional, you should be able to continue without accepting. Refactor to a single visible slot to check the conditions. - Always set the globalsettings value; to "false" on entry to make sure it's there. - When setting the list of entries, check the conditions (because if the list is empty, or all of them are optional, then it's ok to continue). FIXES #1124 FIXES #1125
This commit is contained in:
parent
c245238b89
commit
d2957fbad3
@ -106,24 +106,9 @@ LicensePage::LicensePage(QWidget *parent)
|
||||
"padding: 2px; }" );
|
||||
ui->acceptFrame->layout()->setMargin( CalamaresUtils::defaultFontHeight() / 2 );
|
||||
|
||||
connect( ui->acceptCheckBox, &QCheckBox::toggled,
|
||||
this, [ this ]( bool checked )
|
||||
{
|
||||
Calamares::JobQueue::instance()->globalStorage()->insert( "licenseAgree", checked );
|
||||
m_isNextEnabled = checked;
|
||||
if ( !checked )
|
||||
{
|
||||
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 );
|
||||
} );
|
||||
updateGlobalStorage( false ); // Have not agreed yet
|
||||
|
||||
connect( ui->acceptCheckBox, &QCheckBox::toggled, this, &LicensePage::checkAcceptance );
|
||||
|
||||
CALAMARES_RETRANSLATE(
|
||||
ui->acceptCheckBox->setText( tr( "I accept the terms and conditions above." ) );
|
||||
@ -137,9 +122,12 @@ LicensePage::setEntries( const QList< LicenseEntry >& entriesList )
|
||||
CalamaresUtils::clearLayout( ui->licenseEntriesLayout );
|
||||
|
||||
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;
|
||||
|
||||
m_isNextEnabled = !required;
|
||||
nextStatusChanged( m_isNextEnabled );
|
||||
checkAcceptance( false );
|
||||
|
||||
CALAMARES_RETRANSLATE(
|
||||
if ( required )
|
||||
@ -245,3 +233,28 @@ LicensePage::isNextEnabled() const
|
||||
{
|
||||
return m_isNextEnabled;
|
||||
}
|
||||
|
||||
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 );
|
||||
}
|
||||
|
@ -70,13 +70,31 @@ public:
|
||||
void setEntries( const QList< LicenseEntry >& entriesList );
|
||||
|
||||
bool isNextEnabled() const;
|
||||
|
||||
public slots:
|
||||
/** @brief Check if the user can continue
|
||||
*
|
||||
* The user can continue if
|
||||
* - none of the licenses are required, or
|
||||
* - the user has ticked the "OK" box.
|
||||
* This function calls updateGlobalStorage() as needed, and updates
|
||||
* the appearance of the page as needed. @p checked indicates whether
|
||||
* the checkbox has been ticked or not.
|
||||
*/
|
||||
void checkAcceptance( bool checked );
|
||||
|
||||
signals:
|
||||
void nextStatusChanged( bool status );
|
||||
|
||||
private:
|
||||
Ui::LicensePage* ui;
|
||||
/** @brief Update the global storage "licenseAgree" key. */
|
||||
void updateGlobalStorage( bool v );
|
||||
|
||||
bool m_isNextEnabled;
|
||||
bool m_allLicensesOptional; //< all the licenses passed to setEntries are not-required
|
||||
|
||||
Ui::LicensePage* ui;
|
||||
|
||||
};
|
||||
|
||||
#endif //LICENSEPAGE_H
|
||||
|
Loading…
Reference in New Issue
Block a user