diff --git a/src/modules/license/LicensePage.cpp b/src/modules/license/LicensePage.cpp index 97bb9a9ab..3f16a6698 100644 --- a/src/modules/license/LicensePage.cpp +++ b/src/modules/license/LicensePage.cpp @@ -121,6 +121,8 @@ void LicensePage::setEntries( const QList< LicenseEntry >& entriesList ) { CalamaresUtils::clearLayout( ui->licenseEntriesLayout ); + m_entries.clear(); + m_entries.reserve( entriesList.count() ); const bool required = std::any_of( entriesList.cbegin(), entriesList.cend(), []( const LicenseEntry& e ){ return e.m_required; }); if ( entriesList.isEmpty() ) @@ -153,11 +155,16 @@ LicensePage::setEntries( const QList< LicenseEntry >& entriesList ) "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 ) { - ui->licenseEntriesLayout->addWidget( new LicenseWidget( entry ) ); + LicenseWidget* w = new LicenseWidget( entry ); + ui->licenseEntriesLayout->addWidget( w ); + m_entries.append( w ); } ui->licenseEntriesLayout->addStretch(); } diff --git a/src/modules/license/LicensePage.h b/src/modules/license/LicensePage.h index 1af83269a..e9bd0f696 100644 --- a/src/modules/license/LicensePage.h +++ b/src/modules/license/LicensePage.h @@ -32,6 +32,8 @@ namespace Ui class LicensePage; } +class LicenseWidget; + struct LicenseEntry { enum class Type @@ -94,7 +96,7 @@ private: bool m_allLicensesOptional; //< all the licenses passed to setEntries are not-required Ui::LicensePage* ui; - + QList< LicenseWidget* > m_entries; }; #endif //LICENSEPAGE_H diff --git a/src/modules/license/LicenseWidget.cpp b/src/modules/license/LicenseWidget.cpp index c944f973b..4030cbd6c 100644 --- a/src/modules/license/LicenseWidget.cpp +++ b/src/modules/license/LicenseWidget.cpp @@ -28,6 +28,8 @@ LicenseWidget::LicenseWidget( LicenseEntry entry, QWidget* parent ) : QWidget( parent ) , m_entry( std::move( entry ) ) + , m_label( new QLabel( this ) ) + , m_viewLicenseLabel( new QLabel( this ) ) { QPalette pal( palette() ); pal.setColor( QPalette::Background, palette().background().color().lighter( 108 ) ); @@ -39,63 +41,68 @@ LicenseWidget::LicenseWidget( LicenseEntry entry, QWidget* parent ) QHBoxLayout* wiLayout = new QHBoxLayout; setLayout( wiLayout ); - QLabel* label = new QLabel( this ); - label->setWordWrap( true ); - wiLayout->addWidget( label ); - label->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Minimum ); - QString productDescription; - switch ( entry.m_type ) - { - case LicenseEntry::Type::Driver: - //: %1 is an untranslatable product name, example: Creative Audigy driver - productDescription = tr( "%1 driver
" - "by %2" ) - .arg( entry.m_prettyName ) - .arg( entry.m_prettyVendor ); - break; - case LicenseEntry::Type::GpuDriver: - //: %1 is usually a vendor name, example: Nvidia graphics driver - productDescription = tr( "%1 graphics driver
" - "by %2" ) - .arg( entry.m_prettyName ) - .arg( entry.m_prettyVendor ); - break; - case LicenseEntry::Type::BrowserPlugin: - productDescription = tr( "%1 browser plugin
" - "by %2" ) - .arg( entry.m_prettyName ) - .arg( entry.m_prettyVendor ); - break; - case LicenseEntry::Type::Codec: - productDescription = tr( "%1 codec
" - "by %2" ) - .arg( entry.m_prettyName ) - .arg( entry.m_prettyVendor ); - break; - case LicenseEntry::Type::Package: - productDescription = tr( "%1 package
" - "by %2" ) - .arg( entry.m_prettyName ) - .arg( entry.m_prettyVendor ); - break; - case LicenseEntry::Type::Software: - productDescription = tr( "%1
" - "by %2" ) - .arg( entry.m_prettyName ) - .arg( entry.m_prettyVendor ); - } - label->setText( productDescription ); + m_label->setWordWrap( true ); + m_label->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Minimum ); + wiLayout->addWidget( m_label ); - QLabel* viewLicenseLabel = new QLabel( this ); - wiLayout->addWidget( viewLicenseLabel ); - viewLicenseLabel->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); - viewLicenseLabel->setOpenExternalLinks( true ); - viewLicenseLabel->setAlignment( Qt::AlignVCenter | Qt::AlignRight ); - viewLicenseLabel->setText( tr( "view license agreement" ) - .arg( entry.m_url.toString() ) ); + m_viewLicenseLabel->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); + m_viewLicenseLabel->setOpenExternalLinks( true ); + m_viewLicenseLabel->setAlignment( Qt::AlignVCenter | Qt::AlignRight ); + wiLayout->addWidget( m_viewLicenseLabel ); + + retranslateUi(); } LicenseWidget::~LicenseWidget() { } + +void LicenseWidget::retranslateUi() +{ + QString productDescription; + switch ( m_entry.m_type ) + { + case LicenseEntry::Type::Driver: + //: %1 is an untranslatable product name, example: Creative Audigy driver + productDescription = tr( "%1 driver
" + "by %2" ) + .arg( m_entry.m_prettyName ) + .arg( m_entry.m_prettyVendor ); + break; + case LicenseEntry::Type::GpuDriver: + //: %1 is usually a vendor name, example: Nvidia graphics driver + productDescription = tr( "%1 graphics driver
" + "by %2" ) + .arg( m_entry.m_prettyName ) + .arg( m_entry.m_prettyVendor ); + break; + case LicenseEntry::Type::BrowserPlugin: + productDescription = tr( "%1 browser plugin
" + "by %2" ) + .arg( m_entry.m_prettyName ) + .arg( m_entry.m_prettyVendor ); + break; + case LicenseEntry::Type::Codec: + productDescription = tr( "%1 codec
" + "by %2" ) + .arg( m_entry.m_prettyName ) + .arg( m_entry.m_prettyVendor ); + break; + case LicenseEntry::Type::Package: + productDescription = tr( "%1 package
" + "by %2" ) + .arg( m_entry.m_prettyName ) + .arg( m_entry.m_prettyVendor ); + break; + case LicenseEntry::Type::Software: + productDescription = tr( "%1
" + "by %2" ) + .arg( m_entry.m_prettyName ) + .arg( m_entry.m_prettyVendor ); + } + m_label->setText( productDescription ); + + m_viewLicenseLabel->setText( tr( "view license agreement" ) + .arg( m_entry.m_url.toString() ) ); +} diff --git a/src/modules/license/LicenseWidget.h b/src/modules/license/LicenseWidget.h index 861c4ec34..e91ea23c1 100644 --- a/src/modules/license/LicenseWidget.h +++ b/src/modules/license/LicenseWidget.h @@ -33,7 +33,11 @@ public: LicenseWidget( LicenseEntry e, QWidget* parent = nullptr ); virtual ~LicenseWidget() override; + void retranslateUi(); + private: LicenseEntry m_entry; + QLabel *m_label; + QLabel *m_viewLicenseLabel; } ; #endif