2017-12-20 14:39:09 +01:00
|
|
|
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
2014-07-08 15:23:30 +02:00
|
|
|
*
|
|
|
|
* Copyright 2014, Aurélien Gâteau <agateau@kde.org>
|
2015-01-29 20:24:09 +01:00
|
|
|
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
|
2018-03-28 15:59:26 +02:00
|
|
|
* Copyright 2018, Adriaan de Groot <groot@kde.org>
|
2014-07-08 15:23:30 +02:00
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2015-09-09 18:44:43 +02:00
|
|
|
#include <ExecutionViewStep.h>
|
2014-07-08 15:23:30 +02:00
|
|
|
|
2015-01-23 14:02:40 +01:00
|
|
|
#include "Branding.h"
|
2018-06-15 16:20:07 +02:00
|
|
|
#include "Job.h"
|
2015-09-09 18:44:43 +02:00
|
|
|
#include "JobQueue.h"
|
|
|
|
#include "modulesystem/Module.h"
|
|
|
|
#include "modulesystem/ModuleManager.h"
|
|
|
|
#include "Settings.h"
|
2019-04-29 12:27:31 +02:00
|
|
|
#include "ViewManager.h"
|
|
|
|
|
2015-01-23 14:02:40 +01:00
|
|
|
#include "utils/CalamaresUtilsGui.h"
|
2019-04-29 12:27:31 +02:00
|
|
|
#include "utils/Dirs.h"
|
2015-01-23 14:02:40 +01:00
|
|
|
#include "utils/Logger.h"
|
2015-05-07 16:12:19 +02:00
|
|
|
#include "utils/Retranslator.h"
|
2014-07-08 17:04:39 +02:00
|
|
|
|
2015-01-23 14:02:40 +01:00
|
|
|
#include <QDir>
|
2014-07-08 15:23:30 +02:00
|
|
|
#include <QLabel>
|
2014-07-08 17:04:39 +02:00
|
|
|
#include <QProgressBar>
|
2019-06-02 13:40:53 +02:00
|
|
|
#include <QQmlComponent>
|
2015-01-23 14:02:40 +01:00
|
|
|
#include <QQmlEngine>
|
2019-06-01 23:26:08 +02:00
|
|
|
#include <QQuickWidget>
|
|
|
|
#include <QVBoxLayout>
|
2015-06-29 10:00:47 +02:00
|
|
|
|
2014-07-08 15:23:30 +02:00
|
|
|
namespace Calamares
|
|
|
|
{
|
|
|
|
|
2015-09-09 18:44:43 +02:00
|
|
|
ExecutionViewStep::ExecutionViewStep( QObject* parent )
|
2014-07-08 15:23:30 +02:00
|
|
|
: ViewStep( parent )
|
2014-07-08 17:04:39 +02:00
|
|
|
, m_widget( new QWidget )
|
2019-06-01 23:39:39 +02:00
|
|
|
, m_progressBar( new QProgressBar )
|
|
|
|
, m_label( new QLabel )
|
|
|
|
, m_qmlShow( new QQuickWidget )
|
2019-06-02 13:40:53 +02:00
|
|
|
, m_qmlComponent( nullptr )
|
|
|
|
, m_qmlObject( nullptr )
|
2014-07-08 15:23:30 +02:00
|
|
|
{
|
2014-07-08 17:04:39 +02:00
|
|
|
QVBoxLayout* layout = new QVBoxLayout( m_widget );
|
2015-01-23 14:02:40 +01:00
|
|
|
QVBoxLayout* innerLayout = new QVBoxLayout;
|
|
|
|
|
2019-06-01 23:39:39 +02:00
|
|
|
m_progressBar->setMaximum( 10000 );
|
2015-01-23 14:02:40 +01:00
|
|
|
|
2019-06-01 23:26:08 +02:00
|
|
|
m_qmlShow->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
|
|
|
|
m_qmlShow->setResizeMode( QQuickWidget::SizeRootObjectToView );
|
|
|
|
m_qmlShow->engine()->addImportPath( CalamaresUtils::qmlModulesDir().absolutePath() );
|
2015-01-23 20:24:12 +01:00
|
|
|
|
2019-06-01 23:39:39 +02:00
|
|
|
layout->addWidget( m_qmlShow );
|
|
|
|
CalamaresUtils::unmarginLayout( layout );
|
|
|
|
layout->addLayout( innerLayout );
|
|
|
|
|
2015-01-23 14:02:40 +01:00
|
|
|
innerLayout->addSpacing( CalamaresUtils::defaultFontHeight() / 2 );
|
|
|
|
innerLayout->addWidget( m_progressBar );
|
|
|
|
innerLayout->addWidget( m_label );
|
|
|
|
|
2019-06-01 23:26:08 +02:00
|
|
|
cDebug() << "QML import paths:" << Logger::DebugList( m_qmlShow->engine()->importPathList() );
|
2019-06-02 13:19:16 +02:00
|
|
|
loadQml();
|
2015-09-09 18:44:43 +02:00
|
|
|
|
2019-06-01 23:39:39 +02:00
|
|
|
connect( JobQueue::instance(), &JobQueue::progress, this, &ExecutionViewStep::updateFromJobQueue );
|
2014-07-08 15:23:30 +02:00
|
|
|
}
|
|
|
|
|
2015-06-29 10:00:47 +02:00
|
|
|
|
2014-07-08 15:23:30 +02:00
|
|
|
QString
|
2015-09-09 18:44:43 +02:00
|
|
|
ExecutionViewStep::prettyName() const
|
2014-07-08 15:23:30 +02:00
|
|
|
{
|
2019-05-08 12:29:01 +02:00
|
|
|
return Calamares::Settings::instance()->isSetupMode()
|
|
|
|
? tr( "Set up" )
|
|
|
|
: tr( "Install" );
|
2014-07-08 15:23:30 +02:00
|
|
|
}
|
|
|
|
|
2015-06-29 10:00:47 +02:00
|
|
|
|
2014-07-08 15:23:30 +02:00
|
|
|
QWidget*
|
2015-09-09 18:44:43 +02:00
|
|
|
ExecutionViewStep::widget()
|
2014-07-08 15:23:30 +02:00
|
|
|
{
|
|
|
|
return m_widget;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2015-09-09 18:44:43 +02:00
|
|
|
ExecutionViewStep::next()
|
2014-07-08 15:23:30 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-06-29 10:00:47 +02:00
|
|
|
|
2014-07-08 15:23:30 +02:00
|
|
|
void
|
2015-09-09 18:44:43 +02:00
|
|
|
ExecutionViewStep::back()
|
2014-07-08 15:23:30 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-06-29 10:00:47 +02:00
|
|
|
|
2014-07-08 15:23:30 +02:00
|
|
|
bool
|
2015-09-09 18:44:43 +02:00
|
|
|
ExecutionViewStep::isNextEnabled() const
|
2014-07-08 15:23:30 +02:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-01-29 20:24:09 +01:00
|
|
|
|
2014-07-08 15:23:30 +02:00
|
|
|
bool
|
2015-09-09 18:44:43 +02:00
|
|
|
ExecutionViewStep::isBackEnabled() const
|
2014-07-08 15:23:30 +02:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-01-29 20:24:09 +01:00
|
|
|
|
|
|
|
bool
|
2015-09-09 18:44:43 +02:00
|
|
|
ExecutionViewStep::isAtBeginning() const
|
2015-01-29 20:24:09 +01:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-06-29 10:00:47 +02:00
|
|
|
|
2014-07-08 15:23:30 +02:00
|
|
|
bool
|
2015-09-09 18:44:43 +02:00
|
|
|
ExecutionViewStep::isAtEnd() const
|
2014-07-08 15:23:30 +02:00
|
|
|
{
|
2015-01-29 20:24:09 +01:00
|
|
|
return true;
|
2014-07-08 15:23:30 +02:00
|
|
|
}
|
|
|
|
|
2015-06-29 10:00:47 +02:00
|
|
|
void
|
2019-06-02 13:19:16 +02:00
|
|
|
ExecutionViewStep::loadQml()
|
2015-06-29 10:00:47 +02:00
|
|
|
{
|
2019-06-02 13:40:53 +02:00
|
|
|
if ( !m_qmlComponent && !Calamares::Branding::instance()->slideshowPath().isEmpty() )
|
2019-06-01 23:39:39 +02:00
|
|
|
{
|
2019-06-02 13:40:53 +02:00
|
|
|
m_qmlComponent = new QQmlComponent( m_qmlShow->engine(),
|
|
|
|
QUrl::fromLocalFile( Calamares::Branding::instance()->slideshowPath() ),
|
|
|
|
QQmlComponent::CompilationMode::Asynchronous
|
|
|
|
);
|
2019-06-01 23:39:39 +02:00
|
|
|
}
|
2019-06-02 13:19:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ExecutionViewStep::onActivate()
|
|
|
|
{
|
|
|
|
loadQml();
|
2019-06-02 13:40:53 +02:00
|
|
|
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();
|
|
|
|
}
|
2015-06-29 10:00:47 +02:00
|
|
|
|
2015-09-09 18:44:43 +02:00
|
|
|
JobQueue* queue = JobQueue::instance();
|
|
|
|
foreach ( const QString& instanceKey, m_jobInstanceKeys )
|
|
|
|
{
|
2019-06-01 23:26:08 +02:00
|
|
|
Calamares::Module* module = Calamares::ModuleManager::instance()->moduleInstance( instanceKey );
|
2015-09-09 18:44:43 +02:00
|
|
|
if ( module )
|
2018-06-15 16:20:07 +02:00
|
|
|
{
|
|
|
|
auto jl = module->jobs();
|
|
|
|
if ( module->isEmergency() )
|
|
|
|
{
|
|
|
|
for( auto& j : jl )
|
|
|
|
j->setEmergency( true );
|
|
|
|
}
|
|
|
|
queue->enqueue( jl );
|
|
|
|
}
|
2015-09-09 18:44:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
queue->start();
|
2015-06-29 10:00:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-03 15:10:37 +01:00
|
|
|
JobList
|
2015-09-09 18:44:43 +02:00
|
|
|
ExecutionViewStep::jobs() const
|
2014-07-08 15:51:45 +02:00
|
|
|
{
|
2017-11-03 15:10:37 +01:00
|
|
|
return JobList();
|
2014-07-08 15:51:45 +02:00
|
|
|
}
|
|
|
|
|
2015-06-29 10:00:47 +02:00
|
|
|
|
2014-07-08 17:04:39 +02:00
|
|
|
void
|
2015-09-09 18:44:43 +02:00
|
|
|
ExecutionViewStep::appendJobModuleInstanceKey( const QString& instanceKey )
|
|
|
|
{
|
|
|
|
m_jobInstanceKeys.append( instanceKey );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
ExecutionViewStep::updateFromJobQueue( qreal percent, const QString& message )
|
2014-07-08 17:04:39 +02:00
|
|
|
{
|
2017-09-10 12:22:59 +02:00
|
|
|
m_progressBar->setValue( int( percent * m_progressBar->maximum() ) );
|
2014-07-08 17:04:39 +02:00
|
|
|
m_label->setText( message );
|
|
|
|
}
|
|
|
|
|
2019-06-02 13:40:53 +02:00
|
|
|
void
|
|
|
|
ExecutionViewStep::onLeave()
|
|
|
|
{
|
|
|
|
delete m_qmlObject;
|
|
|
|
m_qmlObject = nullptr;
|
|
|
|
}
|
|
|
|
|
2014-07-08 15:23:30 +02:00
|
|
|
} // namespace
|