diff --git a/src/modules/packagechooser/PackageChooserPage.cpp b/src/modules/packagechooser/PackageChooserPage.cpp index 020365a7f..246f59ec9 100644 --- a/src/modules/packagechooser/PackageChooserPage.cpp +++ b/src/modules/packagechooser/PackageChooserPage.cpp @@ -74,7 +74,7 @@ smartClip( const QPixmap& pixmap, QSize size ) return pixmap.copy( x, y, new_width, new_height ); } - return pixmap.scaled( size, Qt::KeepAspectRatio ); + return pixmap.scaled( size, Qt::KeepAspectRatio, Qt::SmoothTransformation ); } void @@ -83,7 +83,7 @@ PackageChooserPage::currentChanged( const QModelIndex& index ) if ( !index.isValid() || !ui->products->selectionModel()->hasSelection() ) { ui->productName->setText( m_introduction.name.get() ); - ui->productScreenshot->setPixmap( m_introduction.screenshot ); + ui->productScreenshot->setPixmap( smartClip( m_introduction.screenshot, ui->productScreenshot->size() ) ); ui->productDescription->setText( m_introduction.description.get() ); } else @@ -96,7 +96,7 @@ PackageChooserPage::currentChanged( const QModelIndex& index ) QPixmap currentScreenshot = model->data( index, PackageListModel::ScreenshotRole ).value< QPixmap >(); if ( currentScreenshot.isNull() ) { - ui->productScreenshot->setPixmap( m_introduction.screenshot ); + ui->productScreenshot->setPixmap( smartClip( m_introduction.screenshot, ui->productScreenshot->size() ) ); } else { @@ -136,8 +136,8 @@ PackageChooserPage::setSelection( const QModelIndex& index ) if ( index.isValid() ) { ui->products->selectionModel()->select( index, QItemSelectionModel::Select ); - currentChanged( index ); } + currentChanged( index ); } bool diff --git a/src/modules/packagechooser/PackageModel.cpp b/src/modules/packagechooser/PackageModel.cpp index 239705490..8a0b13e51 100644 --- a/src/modules/packagechooser/PackageModel.cpp +++ b/src/modules/packagechooser/PackageModel.cpp @@ -9,9 +9,28 @@ #include "PackageModel.h" +#include "Branding.h" #include "utils/Logger.h" #include "utils/Variant.h" +#include + +static QPixmap +loadScreenshot( const QString& path ) +{ + if ( QFileInfo::exists( path ) ) + { + return QPixmap( path ); + } + + const auto* branding = Calamares::Branding::instance(); + if ( !branding ) + { + return QPixmap(); + } + return QPixmap( branding->componentDirectory() + QStringLiteral( "/" ) + path ); +} + PackageItem::PackageItem() {} PackageItem::PackageItem( const QString& a_id, const QString& a_name, const QString& a_description ) @@ -36,7 +55,7 @@ PackageItem::PackageItem::PackageItem( const QVariantMap& item_map ) : id( CalamaresUtils::getString( item_map, "id" ) ) , name( CalamaresUtils::Locale::TranslatedString( item_map, "name" ) ) , description( CalamaresUtils::Locale::TranslatedString( item_map, "description" ) ) - , screenshot( CalamaresUtils::getString( item_map, "screenshot" ) ) + , screenshot( loadScreenshot( CalamaresUtils::getString( item_map, "screenshot" ) ) ) , packageNames( CalamaresUtils::getStringList( item_map, "packages" ) ) { if ( name.isEmpty() && id.isEmpty() ) diff --git a/src/modules/packagechooser/packagechooser.conf b/src/modules/packagechooser/packagechooser.conf index 231826cd3..bb982916e 100644 --- a/src/modules/packagechooser/packagechooser.conf +++ b/src/modules/packagechooser/packagechooser.conf @@ -95,7 +95,11 @@ labels: # Human-readable description. These can be translated as well. # - *screenshot* # Path to a single screenshot of the product. May be a filesystem -# path or a QRC path, e.g. ":/images/no-selection.png". +# path or a QRC path, e.g. ":/images/no-selection.png". If the path +# is not found (e.g. is a non-existent absolute path, or is a relative +# path that does not exist in the current working directory) then +# an additional attempt is made to load the image from the **branding** +# directory. # # The following field is **optional** for an item: #