|
|
|
@ -49,7 +49,7 @@ ExecutionViewStep::ExecutionViewStep( QObject* parent )
|
|
|
|
|
, m_widget( new QWidget )
|
|
|
|
|
, m_progressBar( new QProgressBar )
|
|
|
|
|
, m_label( new QLabel )
|
|
|
|
|
, m_slideshow( nullptr )
|
|
|
|
|
, m_slideshow( new SlideshowQML( m_widget ) )
|
|
|
|
|
{
|
|
|
|
|
QVBoxLayout* layout = new QVBoxLayout( m_widget );
|
|
|
|
|
QVBoxLayout* innerLayout = new QVBoxLayout;
|
|
|
|
@ -64,12 +64,6 @@ ExecutionViewStep::ExecutionViewStep( QObject* parent )
|
|
|
|
|
innerLayout->addWidget( m_progressBar );
|
|
|
|
|
innerLayout->addWidget( m_label );
|
|
|
|
|
|
|
|
|
|
if ( Branding::instance()->slideshowAPI() == 2 )
|
|
|
|
|
{
|
|
|
|
|
cDebug() << "QML load on startup, API 2.";
|
|
|
|
|
loadQmlV2();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
connect( JobQueue::instance(), &JobQueue::progress, this, &ExecutionViewStep::updateFromJobQueue );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -127,108 +121,10 @@ ExecutionViewStep::isAtEnd() const
|
|
|
|
|
return !JobQueue::instance()->isRunning();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
ExecutionViewStep::loadQmlV2()
|
|
|
|
|
{
|
|
|
|
|
if ( !m_qmlComponent && !Calamares::Branding::instance()->slideshowPath().isEmpty() )
|
|
|
|
|
{
|
|
|
|
|
m_qmlComponent = new QQmlComponent( m_qmlShow->engine(),
|
|
|
|
|
QUrl::fromLocalFile( Calamares::Branding::instance()->slideshowPath() ),
|
|
|
|
|
QQmlComponent::CompilationMode::Asynchronous );
|
|
|
|
|
connect( m_qmlComponent, &QQmlComponent::statusChanged, this, &ExecutionViewStep::loadQmlV2Complete );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// @brief State-change of the slideshow, for changeSlideShowState()
|
|
|
|
|
enum class Slideshow
|
|
|
|
|
{
|
|
|
|
|
Start,
|
|
|
|
|
Stop
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** @brief Tells the slideshow we activated or left the show.
|
|
|
|
|
*
|
|
|
|
|
* If @p state is @c Slideshow::Start, calls suitable activation procedures.
|
|
|
|
|
* If @p state is @c Slideshow::Stop, calls deactivation procedures.
|
|
|
|
|
*
|
|
|
|
|
* Applies V1 and V2 QML activation / deactivation:
|
|
|
|
|
* - V1 loads the QML in @p widget on activation. Sets root object property
|
|
|
|
|
* *activatedInCalamares* as appropriate.
|
|
|
|
|
* - V2 calls onActivate() or onLeave() in the QML as appropriate. Also
|
|
|
|
|
* sets the *activatedInCalamares* property.
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
changeSlideShowState( Slideshow state, QQuickItem* slideshow, QQuickWidget* widget )
|
|
|
|
|
{
|
|
|
|
|
bool activate = state == Slideshow::Start;
|
|
|
|
|
|
|
|
|
|
if ( Branding::instance()->slideshowAPI() == 2 )
|
|
|
|
|
{
|
|
|
|
|
// The QML was already loaded in the constructor, need to start it
|
|
|
|
|
CalamaresUtils::callQMLFunction( slideshow, activate ? "onActivate" : "onLeave" );
|
|
|
|
|
}
|
|
|
|
|
else if ( !Calamares::Branding::instance()->slideshowPath().isEmpty() )
|
|
|
|
|
{
|
|
|
|
|
// API version 1 assumes onCompleted is the trigger
|
|
|
|
|
if ( activate )
|
|
|
|
|
{
|
|
|
|
|
widget->setSource( QUrl::fromLocalFile( Calamares::Branding::instance()->slideshowPath() ) );
|
|
|
|
|
}
|
|
|
|
|
// needs the root object for property setting, below
|
|
|
|
|
slideshow = widget->rootObject();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// V1 API has picked up the root object for use, V2 passed it in.
|
|
|
|
|
if ( slideshow )
|
|
|
|
|
{
|
|
|
|
|
static const char propertyName[] = "activatedInCalamares";
|
|
|
|
|
auto property = slideshow->property( propertyName );
|
|
|
|
|
if ( property.isValid() && ( property.type() == QVariant::Bool ) && ( property.toBool() != activate ) )
|
|
|
|
|
{
|
|
|
|
|
slideshow->setProperty( propertyName, activate );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
ExecutionViewStep::loadQmlV2Complete()
|
|
|
|
|
{
|
|
|
|
|
if ( m_qmlComponent && m_qmlComponent->isReady() && !m_qmlObject )
|
|
|
|
|
{
|
|
|
|
|
cDebug() << "QML component complete, API 2";
|
|
|
|
|
// Don't do this again
|
|
|
|
|
disconnect( m_qmlComponent, &QQmlComponent::statusChanged, this, &ExecutionViewStep::loadQmlV2Complete );
|
|
|
|
|
|
|
|
|
|
QObject* o = m_qmlComponent->create();
|
|
|
|
|
m_qmlObject = qobject_cast< QQuickItem* >( o );
|
|
|
|
|
if ( !m_qmlObject )
|
|
|
|
|
{
|
|
|
|
|
delete o;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
cDebug() << Logger::SubEntry << "Loading" << Calamares::Branding::instance()->slideshowPath();
|
|
|
|
|
|
|
|
|
|
// setContent() is public API, but not documented publicly.
|
|
|
|
|
// It is marked \internal in the Qt sources, but does exactly
|
|
|
|
|
// what is needed: sets up visual parent by replacing the root
|
|
|
|
|
// item, and handling resizes.
|
|
|
|
|
m_qmlShow->setContent(
|
|
|
|
|
QUrl::fromLocalFile( Calamares::Branding::instance()->slideshowPath() ), m_qmlComponent, m_qmlObject );
|
|
|
|
|
if ( ViewManager::instance()->currentStep() == this )
|
|
|
|
|
{
|
|
|
|
|
// We're alreay visible! Must have been slow QML loading, and we
|
|
|
|
|
// passed onActivate already.
|
|
|
|
|
changeSlideShowState( Slideshow::Start, m_qmlObject, m_qmlShow );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
ExecutionViewStep::onActivate()
|
|
|
|
|
{
|
|
|
|
|
changeSlideShowState( Slideshow::Start, m_qmlObject, m_qmlShow );
|
|
|
|
|
m_slideshow->changeSlideShowState( Slideshow::Start );
|
|
|
|
|
|
|
|
|
|
JobQueue* queue = JobQueue::instance();
|
|
|
|
|
foreach ( const QString& instanceKey, m_jobInstanceKeys )
|
|
|
|
@ -276,13 +172,7 @@ ExecutionViewStep::updateFromJobQueue( qreal percent, const QString& message )
|
|
|
|
|
void
|
|
|
|
|
ExecutionViewStep::onLeave()
|
|
|
|
|
{
|
|
|
|
|
changeSlideShowState( Slideshow::Stop, m_qmlObject, m_qmlShow );
|
|
|
|
|
// API version 2 is explicitly stopped; version 1 keeps running
|
|
|
|
|
if ( Branding::instance()->slideshowAPI() == 2 )
|
|
|
|
|
{
|
|
|
|
|
delete m_qmlObject;
|
|
|
|
|
m_qmlObject = nullptr;
|
|
|
|
|
}
|
|
|
|
|
m_slideshow->changeSlideShowState( Slideshow::Stop );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Calamares
|
|
|
|
|