diff --git a/src/modules/license/LicensePage.cpp b/src/modules/license/LicensePage.cpp index fc90d843c..237e8d0dc 100644 --- a/src/modules/license/LicensePage.cpp +++ b/src/modules/license/LicensePage.cpp @@ -44,6 +44,12 @@ #include +static const char mustAccept[] = "#acceptFrame { border: 1px solid red;" + "background-color: #fff6f6;" + "border-radius: 4px;" + "padding: 2px; }"; +static const char okAccept[] = "#acceptFrame { padding: 3px }"; + const NamedEnumTable< LicenseEntry::Type >& LicenseEntry::typeNames() { @@ -104,13 +110,8 @@ LicensePage::LicensePage( QWidget* parent ) ui->mainText->setWordWrap( true ); ui->mainText->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ); - ui->additionalText->setWordWrap( true ); - ui->acceptFrame->setFrameStyle( QFrame::NoFrame | QFrame::Plain ); - ui->acceptFrame->setStyleSheet( "#acceptFrame { border: 1px solid red;" - "background-color: #fff6f6;" - "border-radius: 4px;" - "padding: 2px; }" ); + ui->acceptFrame->setStyleSheet( mustAccept ); ui->acceptFrame->layout()->setMargin( CalamaresUtils::defaultFontHeight() / 2 ); updateGlobalStorage( false ); // Have not agreed yet @@ -136,6 +137,7 @@ LicensePage::setEntries( const QList< LicenseEntry >& entriesList ) m_entries.append( w ); m_allLicensesOptional &= !entry.isRequired(); } + ui->licenseEntriesLayout->addSpacerItem( new QSpacerItem( 10, 10, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); ui->acceptCheckBox->setChecked( false ); checkAcceptance( false ); @@ -154,7 +156,8 @@ LicensePage::retranslate() 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." ) ); + QString mustAcceptText( tr( "If you do not agree with the terms, the setup procedure cannot continue." ) ); + ui->acceptCheckBox->setToolTip( mustAcceptText ); } else { @@ -163,8 +166,9 @@ LicensePage::retranslate() "in order to provide additional features and enhance the user " "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." ) ); + QString okAcceptText( tr( "If you do not agree with the terms, proprietary software will not " + "be installed, and open source alternatives will be used instead." ) ); + ui->acceptCheckBox->setToolTip( okAcceptText ); } ui->retranslateUi( this ); @@ -195,14 +199,11 @@ LicensePage::checkAcceptance( bool 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; }" ); + ui->acceptFrame->setStyleSheet( mustAccept ); } else { - ui->acceptFrame->setStyleSheet( "#acceptFrame { padding: 3px }" ); + ui->acceptFrame->setStyleSheet( okAccept ); } emit nextStatusChanged( m_isNextEnabled ); } diff --git a/src/modules/license/LicensePage.ui b/src/modules/license/LicensePage.ui index a81fae2b8..b5936d5de 100644 --- a/src/modules/license/LicensePage.ui +++ b/src/modules/license/LicensePage.ui @@ -15,7 +15,7 @@ - + @@ -87,7 +87,7 @@ 0 0 765 - 81 + 89 @@ -107,22 +107,6 @@ - - - - - 0 - 0 - - - - - - - <additionalText> - - - diff --git a/src/modules/license/LicenseWidget.cpp b/src/modules/license/LicenseWidget.cpp index a4c1dfaaa..b78972c00 100644 --- a/src/modules/license/LicenseWidget.cpp +++ b/src/modules/license/LicenseWidget.cpp @@ -27,13 +27,9 @@ #include #include #include -#include +#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 ) { @@ -56,9 +52,9 @@ LicenseWidget::LicenseWidget( LicenseEntry entry, QWidget* parent ) : QWidget( parent ) , m_entry( std::move( entry ) ) , m_label( new QLabel( this ) ) - , m_viewLicenseLabel( new QLabel( this ) ) - , m_expandLicenseButton( nullptr ) - , m_fullText( nullptr ) + , m_viewLicenseButton( new QPushButton( this ) ) + , m_licenceTextLabel( new QLabel( this ) ) + , m_isExpanded( m_entry.expandByDefault() ) { QPalette pal( palette() ); pal.setColor( QPalette::Background, palette().window().color().lighter( 108 ) ); @@ -70,53 +66,47 @@ LicenseWidget::LicenseWidget( LicenseEntry entry, QWidget* parent ) setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ); setContentsMargins( 4, 4, 4, 4 ); + QVBoxLayout* vLayout = new QVBoxLayout; + QWidget* topPart = new QWidget( this ); + topPart->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ); + vLayout->addWidget( topPart ); + QHBoxLayout* wiLayout = new QHBoxLayout; + topPart->setLayout( wiLayout ); m_label->setWordWrap( true ); - m_label->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Minimum ); + m_label->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ); wiLayout->addWidget( m_label ); - m_viewLicenseLabel->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); - m_viewLicenseLabel->setAlignment( Qt::AlignVCenter | Qt::AlignRight ); - wiLayout->addWidget( m_viewLicenseLabel ); + wiLayout->addSpacing( 10 ); + m_viewLicenseButton->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed ); + wiLayout->addWidget( m_viewLicenseButton ); + + m_licenceTextLabel->setStyleSheet( "border-top: 1px solid black; margin-top: 0px; padding-top: 1em;" ); + m_licenceTextLabel->setObjectName( "licenseItemFullText" ); - m_expandLicenseButton = new QToolButton( this ); - wiLayout->addWidget( m_expandLicenseButton ); if ( m_entry.isLocal() ) { - QVBoxLayout* vLayout = new QVBoxLayout; - - m_expandLicenseButton->setArrowType( ArrowLocalLicenseIsCollapsed ); - connect( m_expandLicenseButton, &QAbstractButton::clicked, this, &LicenseWidget::expandClicked ); - - vLayout->addLayout( wiLayout ); - m_fullText = new QLabel( this ); - m_fullText->setText( loadLocalFile( m_entry.m_url ) ); - m_fullText->hide(); - m_fullText->setStyleSheet( "border-top: 1px solid black; margin-top: 1em; padding-top: 1em;" ); - m_fullText->setObjectName( "licenseItemFullText" ); - - vLayout->addWidget( m_fullText ); - setLayout( vLayout ); - - if ( m_entry.expandByDefault() ) + m_fullTextContents = loadLocalFile( m_entry.m_url ); + if ( m_isExpanded ) { - // Since we started in a collapsed state, toggle it to expand. - // This can only be done once the full text has been added. - expandClicked(); + m_licenceTextLabel->setText( m_fullTextContents ); } + else + { + m_licenceTextLabel->setText( tr( "URL: %1" ).arg( m_entry.m_url.toDisplayString() ) ); + } + connect( m_viewLicenseButton, &QAbstractButton::clicked, this, &LicenseWidget::expandClicked ); } else { - m_expandLicenseButton->setArrowType( ArrowOpenExternalLink ); - connect( m_expandLicenseButton, &QAbstractButton::clicked, this, &LicenseWidget::viewClicked ); - - // Normally setOpenExternalLinks( true ) would do, but we need the - // open code anyway for the toolbutton, let's share it. - connect( m_viewLicenseLabel, &QLabel::linkActivated, this, &LicenseWidget::viewClicked ); - - setLayout( wiLayout ); // Only the horizontal layout needed + m_licenceTextLabel->setText( tr( "URL: %1" ).arg( m_entry.m_url.toDisplayString() ) ); + connect( m_viewLicenseButton, &QAbstractButton::clicked, this, &LicenseWidget::viewClicked ); } + m_licenceTextLabel->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ); + + vLayout->addWidget( m_licenceTextLabel ); + setLayout( vLayout ); retranslateUi(); } @@ -174,19 +164,18 @@ LicenseWidget::retranslateUi() void LicenseWidget::expandClicked() { - if ( m_expandLicenseButton->arrowType() == ArrowLocalLicenseIsExpanded ) - { - m_expandLicenseButton->setArrowType( ArrowLocalLicenseIsCollapsed ); - } - else - { - m_expandLicenseButton->setArrowType( ArrowLocalLicenseIsExpanded ); - } - + m_isExpanded = !m_isExpanded; // Show/hide based on the new arrow direction. - if ( m_fullText ) + if ( !m_fullTextContents.isEmpty() ) { - m_fullText->setHidden( m_expandLicenseButton->arrowType() == ArrowLocalLicenseIsCollapsed ); + if ( m_isExpanded ) + { + m_licenceTextLabel->setText( m_fullTextContents ); + } + else + { + m_licenceTextLabel->setText( tr( "URL: %1" ).arg( m_entry.m_url.toDisplayString() ) ); + } } updateExpandToolTip(); @@ -198,17 +187,11 @@ LicenseWidget::updateExpandToolTip() { if ( m_entry.isLocal() ) { - const bool isNowCollapsed = m_expandLicenseButton->arrowType() == ArrowLocalLicenseIsCollapsed; - - 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_viewLicenseButton->setText( m_isExpanded ? tr( "Hide license text" ) : tr( "Show the license text" ) ); } else { - m_expandLicenseButton->setToolTip( tr( "Opens the license agreement in a browser window." ) ); - m_viewLicenseLabel->setText( - tr( "View license agreement" ).arg( m_entry.m_url.toString() ) ); + m_viewLicenseButton->setText( tr( "Open license agreement in browser." ) ); } } diff --git a/src/modules/license/LicenseWidget.h b/src/modules/license/LicenseWidget.h index e11d7a746..ffbb9d3c3 100644 --- a/src/modules/license/LicenseWidget.h +++ b/src/modules/license/LicenseWidget.h @@ -27,7 +27,7 @@ #include #include -class QToolButton; +class QPushButton; class LicenseWidget : public QWidget { @@ -44,8 +44,9 @@ private: LicenseEntry m_entry; QLabel* m_label; - QLabel* m_viewLicenseLabel; - QToolButton* m_expandLicenseButton; - QLabel* m_fullText; + QPushButton* m_viewLicenseButton; + QLabel* m_licenceTextLabel; + QString m_fullTextContents; + bool m_isExpanded; }; #endif