Merge branch 'issue-1351'

FIXES #1351
This commit is contained in:
Adriaan de Groot 2020-03-24 15:32:30 +01:00
commit 938277b74e
6 changed files with 30 additions and 16 deletions

View File

@ -69,6 +69,7 @@ public:
if ( anyFailed && !job->isEmergency() )
{
cDebug() << "Skipping non-emergency job" << job->prettyName();
++m_jobIndex;
continue;
}
@ -83,11 +84,9 @@ public:
message = result.message();
details = result.details();
}
if ( !anyFailed )
{
emitProgress( 1.0 );
++m_jobIndex;
}
}
if ( anyFailed )
{
emitFailed( message, details );
@ -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

View File

@ -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

View File

@ -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 <QApplication>
#include <QBoxLayout>
@ -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;
}

View File

@ -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;

View File

@ -136,7 +136,7 @@ ExecutionViewStep::isAtBeginning() const
bool
ExecutionViewStep::isAtEnd() const
{
return true;
return !JobQueue::instance()->isRunning();
}
void

View File

@ -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)