diff --git a/src/libcalamaresui/viewpages/ExecutionViewStep.cpp b/src/libcalamaresui/viewpages/ExecutionViewStep.cpp index c9bc4b8c3..e794d6dd4 100644 --- a/src/libcalamaresui/viewpages/ExecutionViewStep.cpp +++ b/src/libcalamaresui/viewpages/ExecutionViewStep.cpp @@ -20,6 +20,8 @@ #include "ExecutionViewStep.h" +#include "Slideshow.h" + #include "Branding.h" #include "Job.h" #include "JobQueue.h" @@ -37,10 +39,6 @@ #include #include #include -#include -#include -#include -#include #include namespace Calamares @@ -51,20 +49,14 @@ ExecutionViewStep::ExecutionViewStep( QObject* parent ) , m_widget( new QWidget ) , m_progressBar( new QProgressBar ) , m_label( new QLabel ) - , m_qmlShow( new QQuickWidget ) - , m_qmlComponent( nullptr ) - , m_qmlObject( nullptr ) + , m_slideshow( nullptr ) { QVBoxLayout* layout = new QVBoxLayout( m_widget ); QVBoxLayout* innerLayout = new QVBoxLayout; m_progressBar->setMaximum( 10000 ); - m_qmlShow->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); - m_qmlShow->setResizeMode( QQuickWidget::SizeRootObjectToView ); - m_qmlShow->engine()->addImportPath( CalamaresUtils::qmlModulesDir().absolutePath() ); - - layout->addWidget( m_qmlShow ); + layout->addWidget( m_slideshow->widget() ); CalamaresUtils::unmarginLayout( layout ); layout->addLayout( innerLayout ); @@ -72,7 +64,6 @@ ExecutionViewStep::ExecutionViewStep( QObject* parent ) innerLayout->addWidget( m_progressBar ); innerLayout->addWidget( m_label ); - cDebug() << "QML import paths:" << Logger::DebugList( m_qmlShow->engine()->importPathList() ); if ( Branding::instance()->slideshowAPI() == 2 ) { cDebug() << "QML load on startup, API 2."; @@ -80,9 +71,6 @@ ExecutionViewStep::ExecutionViewStep( QObject* parent ) } connect( JobQueue::instance(), &JobQueue::progress, this, &ExecutionViewStep::updateFromJobQueue ); -#if QT_VERSION >= QT_VERSION_CHECK( 5, 10, 0 ) - CALAMARES_RETRANSLATE( m_qmlShow->engine()->retranslate(); ) -#endif } diff --git a/src/libcalamaresui/viewpages/ExecutionViewStep.h b/src/libcalamaresui/viewpages/ExecutionViewStep.h index e797c3cb2..340f96745 100644 --- a/src/libcalamaresui/viewpages/ExecutionViewStep.h +++ b/src/libcalamaresui/viewpages/ExecutionViewStep.h @@ -27,13 +27,12 @@ class QLabel; class QObject; class QProgressBar; -class QQmlComponent; -class QQuickItem; -class QQuickWidget; namespace Calamares { +class Slideshow; + class ExecutionViewStep : public ViewStep { Q_OBJECT @@ -67,9 +66,7 @@ private: QWidget* m_widget; QProgressBar* m_progressBar; QLabel* m_label; - QQuickWidget* m_qmlShow; - QQmlComponent* m_qmlComponent; - QQuickItem* m_qmlObject; ///< The actual show + Slideshow* m_slideshow; QStringList m_jobInstanceKeys; diff --git a/src/libcalamaresui/viewpages/Slideshow.cpp b/src/libcalamaresui/viewpages/Slideshow.cpp new file mode 100644 index 000000000..f0069cd9d --- /dev/null +++ b/src/libcalamaresui/viewpages/Slideshow.cpp @@ -0,0 +1,55 @@ +/* === This file is part of Calamares - === + * + * Copyright 2014, Aurélien Gâteau + * Copyright 2014-2015, Teo Mrnjavac + * Copyright 2018, Adriaan de Groot + * + * Calamares is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Calamares is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Calamares. If not, see . + */ + +#include "Slideshow.h" + +#include "utils/Dirs.h" +#include "utils/Logger.h" + +#include +#include +#include +#include + +namespace Calamares +{ + +Slideshow::~Slideshow() +{ +} + +SlideshowQML::SlideshowQML(QWidget* parent) + : Slideshow( parent ) + , m_qmlShow( new QQuickWidget ) + , m_qmlComponent( nullptr ) + , m_qmlObject( nullptr ) +{ + m_qmlShow->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); + m_qmlShow->setResizeMode( QQuickWidget::SizeRootObjectToView ); + m_qmlShow->engine()->addImportPath( CalamaresUtils::qmlModulesDir().absolutePath() ); + + cDebug() << "QML import paths:" << Logger::DebugList( m_qmlShow->engine()->importPathList() ); +#if QT_VERSION >= QT_VERSION_CHECK( 5, 10, 0 ) + CALAMARES_RETRANSLATE( m_qmlShow->engine()->retranslate(); ) +#endif + +} + +} diff --git a/src/libcalamaresui/viewpages/Slideshow.h b/src/libcalamaresui/viewpages/Slideshow.h new file mode 100644 index 000000000..5f3612f7e --- /dev/null +++ b/src/libcalamaresui/viewpages/Slideshow.h @@ -0,0 +1,66 @@ +/* === This file is part of Calamares - === + * + * Copyright 2014, Aurélien Gâteau + * Copyright 2014-2015, Teo Mrnjavac + * Copyright 2018, Adriaan de Groot + * + * Calamares is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Calamares is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Calamares. If not, see . + */ + +#ifndef LIBCALAMARESUI_SLIDESHOW_H +#define LIBCALAMARESUI_SLIDESHOW_H + +#include + +class QQmlComponent; +class QQuickItem; +class QQuickWidget; + +namespace Calamares +{ + +class Slideshow +{ +public: + Slideshow( QWidget* parent ) {}; + virtual ~Slideshow(); + + virtual QWidget* widget() = 0; +}; + +class SlideshowQML : public Slideshow +{ +public: + SlideshowQML( QWidget* parent ); + virtual ~SlideshowQML(); + + QWidget* widget() override; + +private: + QQuickWidget* m_qmlShow; + QQmlComponent* m_qmlComponent; + QQuickItem* m_qmlObject; ///< The actual show +}; + +class SlideshowPictures : public Slideshow +{ +public: + SlideshowPictures( QWidget* parent ); + virtual ~SlideshowPictures(); + + QWidget* widget() override; +}; + +} +#endif