diff --git a/src/libcalamares/JobQueue.cpp b/src/libcalamares/JobQueue.cpp index bc3028ae7..b78ba32dc 100644 --- a/src/libcalamares/JobQueue.cpp +++ b/src/libcalamares/JobQueue.cpp @@ -205,16 +205,7 @@ JobQueue::start() void -JobQueue::enqueue( const job_ptr& job ) -{ - Q_ASSERT( !m_thread->isRunning() ); - m_jobs.append( job ); - emit queueChanged( m_jobs ); -} - - -void -JobQueue::enqueue( const JobList& jobs ) +JobQueue::enqueue( int moduleWeight, const JobList& jobs ) { Q_ASSERT( !m_thread->isRunning() ); m_jobs.append( jobs ); diff --git a/src/libcalamares/JobQueue.h b/src/libcalamares/JobQueue.h index ff2694d8f..3847b4667 100644 --- a/src/libcalamares/JobQueue.h +++ b/src/libcalamares/JobQueue.h @@ -1,5 +1,5 @@ /* === This file is part of Calamares - <https://github.com/calamares> === - * + * * SPDX-FileCopyrightText: 2014-2015 Teo Mrnjavac <teo@kde.org> * * Calamares is free software: you can redistribute it and/or modify @@ -30,7 +30,6 @@ namespace Calamares { - class GlobalStorage; class JobThread; @@ -45,8 +44,12 @@ public: GlobalStorage* globalStorage() const; - void enqueue( const job_ptr& job ); - void enqueue( const JobList& jobs ); + /** @brief Queues up jobs from a single module source + * + * The total weight of the jobs is spread out to fill the weight + * of the module. + */ + void enqueue( int moduleWeight, const JobList& jobs ); void start(); bool isRunning() const { return !m_finished; } diff --git a/src/libcalamaresui/modulesystem/ModuleManager.h b/src/libcalamaresui/modulesystem/ModuleManager.h index ed4cef8ba..eb7d086c1 100644 --- a/src/libcalamaresui/modulesystem/ModuleManager.h +++ b/src/libcalamaresui/modulesystem/ModuleManager.h @@ -71,6 +71,16 @@ public: */ ModuleSystem::Descriptor moduleDescriptor( const QString& name ); + /** @brief returns the module descriptor structure for the module @p instance + * + * Descriptors are for the module, which may have multiple instances; + * this is the same as moduleDescriptor( instance.module() ). + */ + ModuleSystem::Descriptor moduleDescriptor( const ModuleSystem::InstanceKey& instanceKey ) + { + return moduleDescriptor( instanceKey.module() ); + } + /** * @brief moduleInstance returns a Module object for a given instance key. * @param instanceKey the instance key for a module instance. diff --git a/src/libcalamaresui/viewpages/ExecutionViewStep.cpp b/src/libcalamaresui/viewpages/ExecutionViewStep.cpp index b2205d70e..6f3983dc4 100644 --- a/src/libcalamaresui/viewpages/ExecutionViewStep.cpp +++ b/src/libcalamaresui/viewpages/ExecutionViewStep.cpp @@ -146,10 +146,24 @@ ExecutionViewStep::onActivate() { m_slideshow->changeSlideShowState( Slideshow::Start ); + const auto instanceDescriptors = Calamares::Settings::instance()->moduleInstances(); + JobQueue* queue = JobQueue::instance(); - for( const auto& instanceKey : m_jobInstanceKeys ) + for ( const auto& instanceKey : m_jobInstanceKeys ) { + const auto& moduleDescriptor = Calamares::ModuleManager::instance()->moduleDescriptor( instanceKey ); Calamares::Module* module = Calamares::ModuleManager::instance()->moduleInstance( instanceKey ); + + const auto instanceDescriptor + = std::find_if( instanceDescriptors.constBegin(), + instanceDescriptors.constEnd(), + [=]( const Calamares::InstanceDescription& d ) { return d.key() == instanceKey; } ); + int weight = moduleDescriptor.weight(); + if ( instanceDescriptor != instanceDescriptors.constEnd() && instanceDescriptor->explicitWeight() ) + { + weight = instanceDescriptor->weight(); + } + weight = qBound( 1, weight, 100 ); if ( module ) { auto jl = module->jobs(); @@ -160,7 +174,7 @@ ExecutionViewStep::onActivate() j->setEmergency( true ); } } - queue->enqueue( jl ); + queue->enqueue( weight, jl ); } }