diff --git a/src/libcalamares/JobQueue.cpp b/src/libcalamares/JobQueue.cpp index cf9d9ad65..6a2aa4cba 100644 --- a/src/libcalamares/JobQueue.cpp +++ b/src/libcalamares/JobQueue.cpp @@ -69,6 +69,7 @@ public: if ( anyFailed && !job->isEmergency() ) { cDebug() << "Skipping non-emergency job" << job->prettyName(); + ++m_jobIndex; continue; } @@ -83,10 +84,8 @@ public: message = result.message(); details = result.details(); } - if ( !anyFailed ) - { - ++m_jobIndex; - } + emitProgress( 1.0 ); + ++m_jobIndex; } if ( anyFailed ) { @@ -141,7 +140,7 @@ private: m_queue, "failed", Qt::QueuedConnection, Q_ARG( QString, message ), Q_ARG( QString, details ) ); } - void emitFinished() { QMetaObject::invokeMethod( m_queue, "finished", Qt::QueuedConnection ); } + void emitFinished() { QMetaObject::invokeMethod( m_queue, "finish", Qt::QueuedConnection ); } }; JobThread::~JobThread() {} @@ -196,6 +195,7 @@ JobQueue::start() Q_ASSERT( !m_thread->isRunning() ); m_thread->setJobs( std::move( m_jobs ) ); m_jobs.clear(); + m_finished = false; m_thread->start(); } @@ -217,4 +217,11 @@ JobQueue::enqueue( const JobList& jobs ) emit queueChanged( m_jobs ); } +void +JobQueue::finish() +{ + m_finished = true; + emit finished(); +} + } // namespace Calamares diff --git a/src/libcalamares/JobQueue.h b/src/libcalamares/JobQueue.h index a58b873d9..88a2bb0c3 100644 --- a/src/libcalamares/JobQueue.h +++ b/src/libcalamares/JobQueue.h @@ -45,6 +45,11 @@ public: void enqueue( const JobList& jobs ); void start(); + bool isRunning() const { return !m_finished; } + +public slots: + void finish(); + signals: void queueChanged( const JobList& jobs ); void progress( qreal percent, const QString& prettyName ); @@ -57,6 +62,7 @@ private: JobList m_jobs; JobThread* m_thread; GlobalStorage* m_storage; + bool m_finished = true; ///< Initially, not running }; } // namespace Calamares diff --git a/src/libcalamaresui/ViewManager.cpp b/src/libcalamaresui/ViewManager.cpp index 96d4cc3a0..6ee0d5de3 100644 --- a/src/libcalamaresui/ViewManager.cpp +++ b/src/libcalamaresui/ViewManager.cpp @@ -29,8 +29,8 @@ #include "utils/Paste.h" #include "utils/Retranslator.h" #include "viewpages/BlankViewStep.h" -#include "viewpages/ViewStep.h" #include "viewpages/ExecutionViewStep.h" +#include "viewpages/ViewStep.h" #include #include @@ -309,6 +309,13 @@ stepIsExecute( const ViewStepList& steps, int index ) && ( qobject_cast< ExecutionViewStep* >( steps.at( index ) ) != nullptr ); } +static inline bool +isAtVeryEnd( const ViewStepList& steps, int index ) + +{ + return ( index >= steps.count() ) || ( index == steps.count() - 1 && steps.last()->isAtEnd() ); +} + void ViewManager::next() { @@ -412,7 +419,7 @@ ViewManager::updateButtonLabels() m_back->setText( tr( "&Back" ) ); // Cancel button changes label at the end - if ( isAtVeryEnd() ) + if ( isAtVeryEnd( m_steps, m_currentStep ) ) { m_quit->setText( tr( "&Done" ) ); m_quit->setToolTip( quitOnCompleteTooltip ); @@ -473,7 +480,7 @@ ViewManager::confirmCancelInstallation() const auto* const settings = Calamares::Settings::instance(); // When we're at the very end, then it's always OK to exit. - if ( isAtVeryEnd() ) + if ( isAtVeryEnd( m_steps, m_currentStep ) ) { return true; } diff --git a/src/libcalamaresui/ViewManager.h b/src/libcalamaresui/ViewManager.h index 7ca6eb377..a4bedd7bc 100644 --- a/src/libcalamaresui/ViewManager.h +++ b/src/libcalamaresui/ViewManager.h @@ -132,12 +132,6 @@ private: void updateButtonLabels(); void updateCancelEnabled( bool enabled ); - bool isAtVeryEnd() const - { - return ( m_currentStep >= m_steps.count() ) - || ( m_currentStep == m_steps.count() - 1 && m_steps.last()->isAtEnd() ); - } - static ViewManager* s_instance; ViewStepList m_steps; diff --git a/src/libcalamaresui/viewpages/ExecutionViewStep.cpp b/src/libcalamaresui/viewpages/ExecutionViewStep.cpp index 8ea918690..c9bc4b8c3 100644 --- a/src/libcalamaresui/viewpages/ExecutionViewStep.cpp +++ b/src/libcalamaresui/viewpages/ExecutionViewStep.cpp @@ -136,7 +136,7 @@ ExecutionViewStep::isAtBeginning() const bool ExecutionViewStep::isAtEnd() const { - return true; + return !JobQueue::instance()->isRunning(); } void diff --git a/src/modules/dummypython/main.py b/src/modules/dummypython/main.py index 2da9b4760..96de6030f 100644 --- a/src/modules/dummypython/main.py +++ b/src/modules/dummypython/main.py @@ -102,7 +102,7 @@ def run(): status = _("Dummy python step {}").format(str(c) + ":" + repr(k)) libcalamares.utils.debug(_("Dummy python step {}").format(str(k))) sleep(1) - libcalamares.job.setprogress(c * 1.0 / len(configlist)) + libcalamares.job.setprogress(c * 1.0 / (len(configlist)+1)) c += 1 sleep(3)