diff --git a/src/modules/license/LicensePage.cpp b/src/modules/license/LicensePage.cpp
index c5ba38133..fc90d843c 100644
--- a/src/modules/license/LicensePage.cpp
+++ b/src/modules/license/LicensePage.cpp
@@ -72,6 +72,7 @@ LicenseEntry::LicenseEntry( const QVariantMap& conf )
m_url = QUrl( conf[ "url" ].toString() );
m_required = CalamaresUtils::getBool( conf, "required", false );
+ m_expand = CalamaresUtils::getBool( conf, "expand", false );
bool ok = false;
QString typeString = conf.value( "type", "software" ).toString();
@@ -97,21 +98,14 @@ LicensePage::LicensePage( QWidget* parent )
{
ui->setupUi( this );
- ui->verticalLayout->insertSpacing( 1, CalamaresUtils::defaultFontHeight() );
+ // ui->verticalLayout->insertSpacing( 1, CalamaresUtils::defaultFontHeight() );
+ CalamaresUtils::unmarginLayout( ui->verticalLayout );
- 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() );
-
ui->acceptFrame->setFrameStyle( QFrame::NoFrame | QFrame::Plain );
ui->acceptFrame->setStyleSheet( "#acceptFrame { border: 1px solid red;"
"background-color: #fff6f6;"
@@ -123,54 +117,53 @@ 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_SLOT( &LicensePage::retranslate )
}
void
LicensePage::setEntries( const QList< LicenseEntry >& entriesList )
{
CalamaresUtils::clearLayout( ui->licenseEntriesLayout );
+
+ m_allLicensesOptional = true;
+
m_entries.clear();
m_entries.reserve( entriesList.count() );
-
- auto isRequired = []( const LicenseEntry& e ) { return e.m_required; };
- m_allLicensesOptional = std::none_of( entriesList.cbegin(), entriesList.cend(), isRequired );
-
- checkAcceptance( false );
-
for ( const LicenseEntry& entry : entriesList )
{
LicenseWidget* w = new LicenseWidget( entry );
ui->licenseEntriesLayout->addWidget( w );
m_entries.append( w );
+ m_allLicensesOptional &= !entry.isRequired();
}
- ui->licenseEntriesLayout->addStretch();
- CALAMARES_RETRANSLATE_SLOT( &LicensePage::retranslate )
+ ui->acceptCheckBox->setChecked( false );
+ checkAcceptance( false );
}
void
LicensePage::retranslate()
{
+ ui->acceptCheckBox->setText( tr( "I accept the terms and conditions above." ) );
+
+ QString review = tr( "Please review the End User License Agreements (EULAs)." );
+ const auto br = QStringLiteral( "
" );
+
if ( !m_allLicensesOptional )
{
- ui->mainText->setText( tr( "
License Agreement
"
- "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.
"
- "If you do not agree with the terms, the setup procedure cannot continue." ) );
+ ui->mainText->setText( tr( "This setup procedure will install proprietary "
+ "software that is subject to licensing terms." )
+ + br + review );
+ ui->additionalText->setText( tr( "If you do not agree with the terms, the setup procedure cannot continue." ) );
}
else
{
- ui->mainText->setText( tr( "License Agreement
"
- "This setup procedure can install proprietary "
+ ui->mainText->setText( tr( "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.
"
- "If you do not agree with the terms, proprietary software will not "
+ "experience." )
+ + br + review );
+ ui->additionalText->setText( tr( "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 );
diff --git a/src/modules/license/LicensePage.h b/src/modules/license/LicensePage.h
index 65f26b543..dcd3ea7b4 100644
--- a/src/modules/license/LicensePage.h
+++ b/src/modules/license/LicensePage.h
@@ -56,13 +56,15 @@ struct LicenseEntry
bool isValid() const { return !m_id.isEmpty(); }
bool isRequired() const { return m_required; }
bool isLocal() const;
+ bool expandByDefault() const { return m_expand; }
QString m_id;
QString m_prettyName;
QString m_prettyVendor;
- Type m_type;
+ Type m_type = Type::Software;
QUrl m_url;
- bool m_required;
+ bool m_required = false;
+ bool m_expand = false;
};
class LicensePage : public QWidget
diff --git a/src/modules/license/LicensePage.ui b/src/modules/license/LicensePage.ui
index 767b392a0..a81fae2b8 100644
--- a/src/modules/license/LicensePage.ui
+++ b/src/modules/license/LicensePage.ui
@@ -15,7 +15,17 @@
-
-
+
+
-
+
+
+ <h1>License Agreement</h1>
+
+
+ Qt::AlignCenter
+
+
+
-
@@ -30,6 +40,12 @@
<Calamares license text>
+
+ Qt::AlignCenter
+
+
+ true
+
-
@@ -47,6 +63,12 @@
-
+
+
+ 0
+ 0
+
+
QFrame::NoFrame
@@ -65,7 +87,7 @@
0
0
765
- 94
+ 81
diff --git a/src/modules/license/LicenseWidget.cpp b/src/modules/license/LicenseWidget.cpp
index 25509be95..a4c1dfaaa 100644
--- a/src/modules/license/LicenseWidget.cpp
+++ b/src/modules/license/LicenseWidget.cpp
@@ -30,6 +30,10 @@
#include
#include
+static constexpr const auto ArrowOpenExternalLink = Qt::RightArrow;
+static constexpr const auto ArrowLocalLicenseIsCollapsed = Qt::UpArrow;
+static constexpr const auto ArrowLocalLicenseIsExpanded = Qt::DownArrow;
+
static QString
loadLocalFile( const QUrl& u )
{
@@ -57,7 +61,7 @@ LicenseWidget::LicenseWidget( LicenseEntry entry, QWidget* parent )
, m_fullText( nullptr )
{
QPalette pal( palette() );
- pal.setColor( QPalette::Background, palette().background().color().lighter( 108 ) );
+ pal.setColor( QPalette::Background, palette().window().color().lighter( 108 ) );
setObjectName( "licenseItem" );
@@ -82,7 +86,7 @@ LicenseWidget::LicenseWidget( LicenseEntry entry, QWidget* parent )
{
QVBoxLayout* vLayout = new QVBoxLayout;
- m_expandLicenseButton->setArrowType( Qt::UpArrow );
+ m_expandLicenseButton->setArrowType( ArrowLocalLicenseIsCollapsed );
connect( m_expandLicenseButton, &QAbstractButton::clicked, this, &LicenseWidget::expandClicked );
vLayout->addLayout( wiLayout );
@@ -94,10 +98,17 @@ LicenseWidget::LicenseWidget( LicenseEntry entry, QWidget* parent )
vLayout->addWidget( m_fullText );
setLayout( vLayout );
+
+ if ( m_entry.expandByDefault() )
+ {
+ // Since we started in a collapsed state, toggle it to expand.
+ // This can only be done once the full text has been added.
+ expandClicked();
+ }
}
else
{
- m_expandLicenseButton->setArrowType( Qt::RightArrow );
+ m_expandLicenseButton->setArrowType( ArrowOpenExternalLink );
connect( m_expandLicenseButton, &QAbstractButton::clicked, this, &LicenseWidget::viewClicked );
// Normally setOpenExternalLinks( true ) would do, but we need the
@@ -163,19 +174,19 @@ LicenseWidget::retranslateUi()
void
LicenseWidget::expandClicked()
{
- if ( m_expandLicenseButton->arrowType() == Qt::DownArrow )
+ if ( m_expandLicenseButton->arrowType() == ArrowLocalLicenseIsExpanded )
{
- m_expandLicenseButton->setArrowType( Qt::UpArrow );
+ m_expandLicenseButton->setArrowType( ArrowLocalLicenseIsCollapsed );
}
else
{
- m_expandLicenseButton->setArrowType( Qt::DownArrow );
+ m_expandLicenseButton->setArrowType( ArrowLocalLicenseIsExpanded );
}
// Show/hide based on the new arrow direction.
if ( m_fullText )
{
- m_fullText->setHidden( m_expandLicenseButton->arrowType() == Qt::UpArrow );
+ m_fullText->setHidden( m_expandLicenseButton->arrowType() == ArrowLocalLicenseIsCollapsed );
}
updateExpandToolTip();
@@ -187,7 +198,7 @@ LicenseWidget::updateExpandToolTip()
{
if ( m_entry.isLocal() )
{
- const bool isNowCollapsed = m_expandLicenseButton->arrowType() == Qt::UpArrow;
+ const bool isNowCollapsed = m_expandLicenseButton->arrowType() == ArrowLocalLicenseIsCollapsed;
m_expandLicenseButton->setToolTip( isNowCollapsed ? tr( "Shows the complete license text" )
: tr( "Hide license text" ) );
diff --git a/src/modules/license/license.conf b/src/modules/license/license.conf
index 9057f8a51..8a1672887 100644
--- a/src/modules/license/license.conf
+++ b/src/modules/license/license.conf
@@ -14,6 +14,10 @@
# to the URL is provided, which opens in the default web browser. A local
# URL (i.e. file:///) assumes that the contents are HTML or plain text, and
# displays the license in-line. YAML: string, mandatory.
+# - expand A boolean value only relevant for **local** URLs. If true,
+# the license text is displayed in "expanded" form by
+# default, rather than requiring the user to first open it up.
+# YAML: boolean, optional, default is false.
entries:
- id: nvidia
name: Nvidia
@@ -43,3 +47,4 @@ entries:
type: software
required: true
url: file:../LICENSE
+ expand: true