commit
2d02290b91
@ -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( "<br/>" );
|
||||
|
||||
if ( !m_allLicensesOptional )
|
||||
{
|
||||
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." ) );
|
||||
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( "<h1>License Agreement</h1>"
|
||||
"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.<br/>"
|
||||
"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 );
|
||||
|
@ -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
|
||||
|
@ -15,7 +15,17 @@
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,0,0,0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,0,0,0,0">
|
||||
<item>
|
||||
<widget class="QLabel" name="titleLabel">
|
||||
<property name="text">
|
||||
<string><h1>License Agreement</h1></string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="mainText">
|
||||
<property name="sizePolicy">
|
||||
@ -30,6 +40,12 @@
|
||||
<property name="text">
|
||||
<string notr="true"><Calamares license text></string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@ -47,6 +63,12 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
@ -65,7 +87,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>765</width>
|
||||
<height>94</height>
|
||||
<height>81</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="licenseEntriesLayout"/>
|
||||
|
@ -30,6 +30,10 @@
|
||||
#include <QToolButton>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
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" ) );
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user