[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.
main
Adriaan de Groot 5 years ago
parent df74604755
commit 5aafa0f4c4

@ -249,6 +249,7 @@ Branding::Branding( const QString& brandingFilePath, QObject* parent )
}
m_slideshowFilenames = slideShowPictures;
m_slideshowAPI = -1;
}
else if ( doc[ "slideshow" ].IsScalar() )
{
@ -259,12 +260,8 @@ 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();
}
else
{
bail( m_descriptorPath, "Syntax error in slideshow sequence." );
}
// API choice is relevant for QML slideshow
int api = doc[ "slideshowAPI" ].IsScalar() ? doc[ "slideshowAPI" ].as< int >() : -1;
if ( ( api < 1 ) || ( api > 2 ) )
{
@ -273,6 +270,11 @@ Branding::Branding( const QString& brandingFilePath, QObject* parent )
}
m_slideshowAPI = api;
}
else
{
bail( m_descriptorPath, "Syntax error in slideshow sequence." );
}
}
catch ( YAML::Exception& e )
{
CalamaresUtils::explainYamlException( e, ba, file.fileName() );

@ -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;

@ -41,6 +41,24 @@
#include <QProgressBar>
#include <QVBoxLayout>
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;

@ -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 );

Loading…
Cancel
Save