[libcalamaresui] Create the slideshow on activation
- Load QML on startup, compile async - Create QML component when the page is reached. - On leave, stop the slideshow (otherwise, e.g. timers will keep running) This should move some of the delay from loading a large slideshow forward as the engine is already initialized when we reach the install / slideshow page.
This commit is contained in:
parent
daf2e55246
commit
103decab68
@ -36,6 +36,7 @@
|
||||
#include <QDir>
|
||||
#include <QLabel>
|
||||
#include <QProgressBar>
|
||||
#include <QQmlComponent>
|
||||
#include <QQmlEngine>
|
||||
#include <QQuickWidget>
|
||||
#include <QVBoxLayout>
|
||||
@ -49,7 +50,8 @@ ExecutionViewStep::ExecutionViewStep( QObject* parent )
|
||||
, m_progressBar( new QProgressBar )
|
||||
, m_label( new QLabel )
|
||||
, m_qmlShow( new QQuickWidget )
|
||||
, m_qmlShowLoaded( false )
|
||||
, m_qmlComponent( nullptr )
|
||||
, m_qmlObject( nullptr )
|
||||
{
|
||||
QVBoxLayout* layout = new QVBoxLayout( m_widget );
|
||||
QVBoxLayout* innerLayout = new QVBoxLayout;
|
||||
@ -72,11 +74,6 @@ ExecutionViewStep::ExecutionViewStep( QObject* parent )
|
||||
loadQml();
|
||||
|
||||
connect( JobQueue::instance(), &JobQueue::progress, this, &ExecutionViewStep::updateFromJobQueue );
|
||||
|
||||
CALAMARES_RETRANSLATE_WIDGET( m_widget,
|
||||
if ( m_qmlShowLoaded )
|
||||
m_qmlShow->setSource( QUrl::fromLocalFile( Calamares::Branding::instance()->slideshowPath() ) );
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@ -138,10 +135,12 @@ ExecutionViewStep::isAtEnd() const
|
||||
void
|
||||
ExecutionViewStep::loadQml()
|
||||
{
|
||||
if ( !m_qmlShowLoaded && !Calamares::Branding::instance()->slideshowPath().isEmpty() )
|
||||
if ( !m_qmlComponent && !Calamares::Branding::instance()->slideshowPath().isEmpty() )
|
||||
{
|
||||
m_qmlShow->setSource( QUrl::fromLocalFile( Calamares::Branding::instance()->slideshowPath() ) );
|
||||
m_qmlShowLoaded = true;
|
||||
m_qmlComponent = new QQmlComponent( m_qmlShow->engine(),
|
||||
QUrl::fromLocalFile( Calamares::Branding::instance()->slideshowPath() ),
|
||||
QQmlComponent::CompilationMode::Asynchronous
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -149,6 +148,12 @@ void
|
||||
ExecutionViewStep::onActivate()
|
||||
{
|
||||
loadQml();
|
||||
if ( m_qmlComponent )
|
||||
{
|
||||
m_qmlObject = m_qmlComponent->create();
|
||||
cDebug() << "Created QML object" << (void *)m_qmlObject << m_qmlObject->objectName();
|
||||
cDebug() << "Show root" << m_qmlShow->rootObject() << "context" << m_qmlShow->rootContext();
|
||||
}
|
||||
|
||||
JobQueue* queue = JobQueue::instance();
|
||||
foreach ( const QString& instanceKey, m_jobInstanceKeys )
|
||||
@ -191,4 +196,11 @@ ExecutionViewStep::updateFromJobQueue( qreal percent, const QString& message )
|
||||
m_label->setText( message );
|
||||
}
|
||||
|
||||
void
|
||||
ExecutionViewStep::onLeave()
|
||||
{
|
||||
delete m_qmlObject;
|
||||
m_qmlObject = nullptr;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -25,8 +25,10 @@
|
||||
#include <QStringList>
|
||||
|
||||
class QLabel;
|
||||
class QObject;
|
||||
class QProgressBar;
|
||||
class QQuickWidget;
|
||||
class QQmlComponent;
|
||||
|
||||
namespace Calamares
|
||||
{
|
||||
@ -51,6 +53,7 @@ public:
|
||||
bool isAtEnd() const override;
|
||||
|
||||
void onActivate() override;
|
||||
void onLeave() override;
|
||||
|
||||
JobList jobs() const override;
|
||||
|
||||
@ -61,7 +64,8 @@ private:
|
||||
QProgressBar* m_progressBar;
|
||||
QLabel* m_label;
|
||||
QQuickWidget* m_qmlShow;
|
||||
bool m_qmlShowLoaded;
|
||||
QQmlComponent* m_qmlComponent;
|
||||
QObject* m_qmlObject; //< The actual show
|
||||
|
||||
QStringList m_jobInstanceKeys;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user