[libcalamaresui] Prep-work for image-slideshow

Doesn't compile (but I need to get it off this machine)

- Prepare to implement a picture-based slideshow alongside QML
- Split QML loading into the slideshow component

This might be good prep-work for moving QML loading out of the QMLViewStep as well.
This commit is contained in:
Adriaan de Groot 2020-05-09 23:07:56 +02:00
parent bb2b5fd982
commit df1f9f1b56
4 changed files with 128 additions and 22 deletions

View File

@ -20,6 +20,8 @@
#include "ExecutionViewStep.h"
#include "Slideshow.h"
#include "Branding.h"
#include "Job.h"
#include "JobQueue.h"
@ -37,10 +39,6 @@
#include <QDir>
#include <QLabel>
#include <QProgressBar>
#include <QQmlComponent>
#include <QQmlEngine>
#include <QQuickItem>
#include <QQuickWidget>
#include <QVBoxLayout>
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
}

View File

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

View File

@ -0,0 +1,55 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2014, Aurélien Gâteau <agateau@kde.org>
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
* Copyright 2018, Adriaan de Groot <groot@kde.org>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#include "Slideshow.h"
#include "utils/Dirs.h"
#include "utils/Logger.h"
#include <QQuickWidget>
#include <QQmlComponent>
#include <QQmlEngine>
#include <QQuickItem>
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
}
}

View File

@ -0,0 +1,66 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2014, Aurélien Gâteau <agateau@kde.org>
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
* Copyright 2018, Adriaan de Groot <groot@kde.org>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#ifndef LIBCALAMARESUI_SLIDESHOW_H
#define LIBCALAMARESUI_SLIDESHOW_H
#include <QWidget>
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