mirror of
https://github.com/parchlinux/calamares.git
synced 2025-06-25 16:38:21 -04:00
Change signature of JobQueue::progress, add finished() signal
Now uses a qreal for progress instead of current and total Also added a finished() signal because determining whether the queue is finished should not be done by comparing a qreal with 1.0 as this is not precise.
This commit is contained in:
parent
2636a1273f
commit
e9da5cb6cb
6 changed files with 28 additions and 24 deletions
|
@ -50,31 +50,33 @@ public:
|
|||
|
||||
void run() override
|
||||
{
|
||||
int total = m_jobs.size();
|
||||
qreal total = m_jobs.size();
|
||||
int current = 0;
|
||||
for( auto job : m_jobs )
|
||||
{
|
||||
emitProgress( current, total, job->prettyName() );
|
||||
qreal percent = current / total;
|
||||
emitProgress( percent, job->prettyName() );
|
||||
JobResult result = job->exec();
|
||||
if ( !result )
|
||||
{
|
||||
emitFailed( result.message(), result.details() );
|
||||
emitFinished();
|
||||
return;
|
||||
}
|
||||
++current;
|
||||
}
|
||||
emitProgress( total, total, QString() );
|
||||
emitProgress( 1, QString() );
|
||||
emitFinished();
|
||||
}
|
||||
|
||||
private:
|
||||
QList< Calamares::job_ptr > m_jobs;
|
||||
JobQueue* m_queue;
|
||||
|
||||
void emitProgress( int current, int total, const QString& prettyName )
|
||||
void emitProgress( qreal percent, const QString& prettyName )
|
||||
{
|
||||
QMetaObject::invokeMethod( m_queue, "progress", Qt::QueuedConnection,
|
||||
Q_ARG( int, current ),
|
||||
Q_ARG( int, total ),
|
||||
Q_ARG( qreal, percent ),
|
||||
Q_ARG( QString, prettyName )
|
||||
);
|
||||
}
|
||||
|
@ -86,6 +88,11 @@ private:
|
|||
Q_ARG( QString, details )
|
||||
);
|
||||
}
|
||||
|
||||
void emitFinished()
|
||||
{
|
||||
QMetaObject::invokeMethod( m_queue, "finished", Qt::QueuedConnection );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue