From 5f55784137180db734569e81934f90888e3bf0ec Mon Sep 17 00:00:00 2001 From: dalto Date: Sat, 23 Oct 2021 14:02:47 -0500 Subject: [PATCH 1/7] Add getList function to Variant --- src/libcalamares/utils/Variant.cpp | 14 ++++++++++++++ src/libcalamares/utils/Variant.h | 7 +++++++ 2 files changed, 21 insertions(+) diff --git a/src/libcalamares/utils/Variant.cpp b/src/libcalamares/utils/Variant.cpp index a484ac8f7..0aba07f33 100644 --- a/src/libcalamares/utils/Variant.cpp +++ b/src/libcalamares/utils/Variant.cpp @@ -65,6 +65,20 @@ getStringList( const QVariantMap& map, const QString& key, const QStringList& d return d; } +QList< QVariant > +getList( const QVariantMap& map, const QString& key, const QList< QVariant >& d ) +{ + if ( map.contains( key ) ) + { + auto v = map.value( key ); + if ( v.canConvert( QVariant::List ) ) + { + return v.toList(); + } + } + return d; +} + qint64 getInteger( const QVariantMap& map, const QString& key, qint64 d ) { diff --git a/src/libcalamares/utils/Variant.h b/src/libcalamares/utils/Variant.h index d0d893dc3..6bd7b8def 100644 --- a/src/libcalamares/utils/Variant.h +++ b/src/libcalamares/utils/Variant.h @@ -15,6 +15,7 @@ #include "DllMacro.h" +#include #include #include @@ -39,6 +40,12 @@ DLLEXPORT QString getString( const QVariantMap& map, const QString& key, const Q */ DLLEXPORT QStringList getStringList( const QVariantMap& map, const QString& key, const QStringList& d = QStringList() ); +/** + * Get a list from a mapping with a given key; returns @p d if no value. + */ +DLLEXPORT QList< QVariant > +getList( const QVariantMap& map, const QString& key, const QList< QVariant >& d = QList< QVariant >() ); + /** * Get an integer value from a mapping with a given key; returns @p d if no value. */ From 97ebaad81e1827b05b720c2660a30ed05260334d Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 26 Oct 2021 14:51:47 +0200 Subject: [PATCH 2/7] Changes: post-release housekeeping --- CHANGES | 12 ++++++++++++ CMakeLists.txt | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 8b86bf636..a1eed622c 100644 --- a/CHANGES +++ b/CHANGES @@ -7,6 +7,18 @@ contributors are listed. Note that Calamares does not have a historical changelog -- this log starts with version 3.2.0. The release notes on the website will have to do for older versions. +# 3.2.45 (unreleased) # + +This release contains contributions from (alphabetically by first name): + - Dalto (new contributor, welcome!) + +## Core ## + - No core changes yet + +## Modules ## + - No module changes yet + + # 3.2.44.3 (2021-10-04) # This is not a hotfix release, but a tiny-tiny incremental improvement diff --git a/CMakeLists.txt b/CMakeLists.txt index f75b1caf5..1e5f5ea37 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,7 +41,7 @@ # TODO:3.3: Require CMake 3.12 cmake_minimum_required( VERSION 3.3 FATAL_ERROR ) project( CALAMARES - VERSION 3.2.44.3 + VERSION 3.2.45 LANGUAGES C CXX ) From d10a952065dd38093ba294715a09c78bbb941684 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 26 Oct 2021 15:19:02 +0200 Subject: [PATCH 3/7] [keyboard] Make debug output more readable --- src/modules/keyboard/KeyboardPage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/keyboard/KeyboardPage.cpp b/src/modules/keyboard/KeyboardPage.cpp index 902f65f9e..e173de3ce 100644 --- a/src/modules/keyboard/KeyboardPage.cpp +++ b/src/modules/keyboard/KeyboardPage.cpp @@ -67,7 +67,7 @@ KeyboardPage::KeyboardPage( Config* config, QWidget* parent ) auto* model = config->keyboardVariants(); ui->variantSelector->setModel( model ); ui->variantSelector->setCurrentIndex( model->index( model->currentIndex() ) ); - cDebug() << "Variants now" << model->rowCount() << model->currentIndex(); + cDebug() << "Variants now total=" << model->rowCount() << "selected=" << model->currentIndex(); } connect( From be398d7edb161629a1ad2a79736684a83c3d7332 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 26 Oct 2021 15:23:14 +0200 Subject: [PATCH 4/7] [packagechooser] Log loading of screenshots - start of indirection in loading, so that we can do a little more work searching for the screenshot. --- src/modules/packagechooser/PackageModel.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/modules/packagechooser/PackageModel.cpp b/src/modules/packagechooser/PackageModel.cpp index 239705490..4fe914915 100644 --- a/src/modules/packagechooser/PackageModel.cpp +++ b/src/modules/packagechooser/PackageModel.cpp @@ -12,6 +12,12 @@ #include "utils/Logger.h" #include "utils/Variant.h" +static QPixmap loadScreenshot( const QString& path ) +{ + cDebug() << path; + return QPixmap( path ); +} + PackageItem::PackageItem() {} PackageItem::PackageItem( const QString& a_id, const QString& a_name, const QString& a_description ) @@ -36,7 +42,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() ) From 748b16ba7f1e3edbae0654b6c483774b1a2e96c1 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 26 Oct 2021 16:03:12 +0200 Subject: [PATCH 5/7] [packagechooser] Look for screenshots in more places. It is easier to put screenshots somewhere where they can be searched-for, rather than requiring either absolute paths (inconvenient to try out someone's settings) or relative paths (because who knows where Calamares will be run during testing). --- src/modules/packagechooser/PackageModel.cpp | 19 ++++++++++++++++--- .../packagechooser/packagechooser.conf | 6 +++++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/modules/packagechooser/PackageModel.cpp b/src/modules/packagechooser/PackageModel.cpp index 4fe914915..8a0b13e51 100644 --- a/src/modules/packagechooser/PackageModel.cpp +++ b/src/modules/packagechooser/PackageModel.cpp @@ -9,13 +9,26 @@ #include "PackageModel.h" +#include "Branding.h" #include "utils/Logger.h" #include "utils/Variant.h" -static QPixmap loadScreenshot( const QString& path ) +#include + +static QPixmap +loadScreenshot( const QString& path ) { - cDebug() << path; - return QPixmap( 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() {} 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: # From b9a243028bdd9268ef8723ac9d391ca2b1c6f525 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 26 Oct 2021 15:24:44 +0200 Subject: [PATCH 6/7] [packagechooser] Make scaled screenshots nicer - patch suggested by flyingcakes85 - patch tested by killajoe FIXES #1807 --- src/modules/packagechooser/PackageChooserPage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/packagechooser/PackageChooserPage.cpp b/src/modules/packagechooser/PackageChooserPage.cpp index 020365a7f..de53244c6 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 From c90b9786c6757e13b828439ffa00c65e7e6c4606 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 26 Oct 2021 16:44:24 +0200 Subject: [PATCH 7/7] [packagechooser] Also resize the introductory image - resize the intro image - when an invalid index is selected, *still* update the images, so it shows the intro image (resized) at the right time. --- src/modules/packagechooser/PackageChooserPage.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/packagechooser/PackageChooserPage.cpp b/src/modules/packagechooser/PackageChooserPage.cpp index de53244c6..246f59ec9 100644 --- a/src/modules/packagechooser/PackageChooserPage.cpp +++ b/src/modules/packagechooser/PackageChooserPage.cpp @@ -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