From 5aafa0f4c43b76dc77d561ad7d02352c763aed04 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 13 May 2020 17:19:46 +0200 Subject: [PATCH] [libcalamaresui] Expose slideshow image names for API -1 - Branding shows the slide pathnames or the slide QML, depending on selected API (which depends on the config-file). - Use one slideshow or the other. --- src/libcalamaresui/Branding.cpp | 18 +++++++++-------- src/libcalamaresui/Branding.h | 10 +++++++++- .../viewpages/ExecutionViewStep.cpp | 20 ++++++++++++++++++- src/libcalamaresui/viewpages/Slideshow.cpp | 2 +- 4 files changed, 39 insertions(+), 11 deletions(-) diff --git a/src/libcalamaresui/Branding.cpp b/src/libcalamaresui/Branding.cpp index 87cfda080..0ec691904 100644 --- a/src/libcalamaresui/Branding.cpp +++ b/src/libcalamaresui/Branding.cpp @@ -249,6 +249,7 @@ Branding::Branding( const QString& brandingFilePath, QObject* parent ) } m_slideshowFilenames = slideShowPictures; + m_slideshowAPI = -1; } else if ( doc[ "slideshow" ].IsScalar() ) { @@ -259,19 +260,20 @@ Branding::Branding( const QString& brandingFilePath, QObject* parent ) QString( "Slideshow file %1 does not exist or is not a valid QML file." ) .arg( slideshowFi.absoluteFilePath() ) ); m_slideshowPath = slideshowFi.absoluteFilePath(); + + // API choice is relevant for QML slideshow + int api = doc[ "slideshowAPI" ].IsScalar() ? doc[ "slideshowAPI" ].as< int >() : -1; + if ( ( api < 1 ) || ( api > 2 ) ) + { + cWarning() << "Invalid or missing *slideshowAPI* in branding file."; + api = 1; + } + m_slideshowAPI = api; } else { bail( m_descriptorPath, "Syntax error in slideshow sequence." ); } - - int api = doc[ "slideshowAPI" ].IsScalar() ? doc[ "slideshowAPI" ].as< int >() : -1; - if ( ( api < 1 ) || ( api > 2 ) ) - { - cWarning() << "Invalid or missing *slideshowAPI* in branding file."; - api = 1; - } - m_slideshowAPI = api; } catch ( YAML::Exception& e ) { diff --git a/src/libcalamaresui/Branding.h b/src/libcalamaresui/Branding.h index 87cb9fffa..1244ede7d 100644 --- a/src/libcalamaresui/Branding.h +++ b/src/libcalamaresui/Branding.h @@ -165,8 +165,16 @@ public: */ QString translationsDirectory() const { return m_translationsPathPrefix; } - /** @brief Path to the slideshow QML file, if any. */ + /** @brief Path to the slideshow QML file, if any. (API == 1 or 2)*/ QString slideshowPath() const { return m_slideshowPath; } + /// @brief List of pathnames of slideshow images, if any. (API == -1) + QStringList slideshowImages() const { return m_slideshowFilenames; } + /** @brief Which slideshow API to use for the slideshow? + * + * - 2 For QML-based slideshows loaded asynchronously (current) + * - 1 For QML-based slideshows, loaded when shown (legacy) + * - -1 For oldschool image-slideshows. + */ int slideshowAPI() const { return m_slideshowAPI; } QPixmap image( Branding::ImageEntry imageEntry, const QSize& size ) const; diff --git a/src/libcalamaresui/viewpages/ExecutionViewStep.cpp b/src/libcalamaresui/viewpages/ExecutionViewStep.cpp index db73d16b1..b4c07bff5 100644 --- a/src/libcalamaresui/viewpages/ExecutionViewStep.cpp +++ b/src/libcalamaresui/viewpages/ExecutionViewStep.cpp @@ -41,6 +41,24 @@ #include #include +static Calamares::Slideshow* +makeSlideshow( QWidget* parent ) +{ + const int api = Calamares::Branding::instance()->slideshowAPI(); + switch ( api ) + { + case -1: + return new Calamares::SlideshowPictures( parent ); + case 1: + FALLTHRU; + case 2: + return new Calamares::SlideshowQML( parent ); + default: + cWarning() << "Unknown Branding slideshow API" << api; + return new Calamares::SlideshowPictures( parent ); + } +} + namespace Calamares { @@ -49,7 +67,7 @@ ExecutionViewStep::ExecutionViewStep( QObject* parent ) , m_widget( new QWidget ) , m_progressBar( new QProgressBar ) , m_label( new QLabel ) - , m_slideshow( new SlideshowQML( m_widget ) ) + , m_slideshow( makeSlideshow( m_widget ) ) { QVBoxLayout* layout = new QVBoxLayout( m_widget ); QVBoxLayout* innerLayout = new QVBoxLayout; diff --git a/src/libcalamaresui/viewpages/Slideshow.cpp b/src/libcalamaresui/viewpages/Slideshow.cpp index a6c4c952c..497d7dae8 100644 --- a/src/libcalamaresui/viewpages/Slideshow.cpp +++ b/src/libcalamaresui/viewpages/Slideshow.cpp @@ -179,7 +179,7 @@ SlideshowPictures::SlideshowPictures( QWidget* parent ) , m_label( new QLabel( parent ) ) , m_timer( new QTimer( this ) ) , m_imageIndex( 0 ) - , m_images { QStringLiteral( ":/data/images/yes.svgz" ), QStringLiteral( ":/data/images/no.svgz" ) } + , m_images( Branding::instance()->slideshowImages() ) { m_timer->setInterval( std::chrono::milliseconds( 2000 ) ); connect( m_timer, &QTimer::timeout, this, &SlideshowPictures::next );