feat(ui): adapt SequentialTask to nested SequentialTasks

This commit is contained in:
flow 2022-04-13 19:23:12 -03:00 committed by flow
parent c86c719e1a
commit eaa5ce4467
No known key found for this signature in database
GPG Key ID: 8D0F221F0A59F469
4 changed files with 15 additions and 12 deletions

View File

@ -1,13 +1,12 @@
#pragma once
#include "modplatform/ModIndex.h"
#include <QString>
#include <QUrl>
#include <QVariant>
namespace ModPlatform {
enum class Provider;
class IndexedPack;
class IndexedVersion;
} // namespace ModPlatform
class QDir;

View File

@ -53,12 +53,18 @@ void SequentialTask::startNext()
return;
}
Task::Ptr next = m_queue[m_currentIndex];
connect(next.get(), SIGNAL(failed(QString)), this, SLOT(subTaskFailed(QString)));
connect(next.get(), SIGNAL(status(QString)), this, SLOT(subTaskStatus(QString)));
connect(next.get(), SIGNAL(progress(qint64, qint64)), this, SLOT(subTaskProgress(qint64, qint64)));
connect(next.get(), SIGNAL(succeeded()), this, SLOT(startNext()));
connect(next.get(), SIGNAL(status(QString)), this, SLOT(subTaskStatus(QString)));
connect(next.get(), SIGNAL(stepStatus(QString)), this, SLOT(subTaskStatus(QString)));
connect(next.get(), SIGNAL(progress(qint64, qint64)), this, SLOT(subTaskProgress(qint64, qint64)));
setStatus(tr("Executing task %1 out of %2").arg(m_currentIndex + 1).arg(m_queue.size()));
setStepStatus(next->isMultiStep() ? next->getStepStatus() : next->getStatus());
next->start();
}
@ -68,7 +74,7 @@ void SequentialTask::subTaskFailed(const QString& msg)
}
void SequentialTask::subTaskStatus(const QString& msg)
{
setStepStatus(m_queue[m_currentIndex]->getStatus());
setStepStatus(msg);
}
void SequentialTask::subTaskProgress(qint64 current, qint64 total)
{

View File

@ -32,13 +32,10 @@ slots:
void subTaskStatus(const QString &msg);
void subTaskProgress(qint64 current, qint64 total);
signals:
void stepStatus(QString status);
protected:
void setStepStatus(QString status) { m_step_status = status; emit stepStatus(status); };
private:
void setStepStatus(QString status) { m_step_status = status; };
private:
protected:
QString m_name;
QString m_step_status;

View File

@ -92,6 +92,7 @@ class Task : public QObject {
void aborted();
void failed(QString reason);
void status(QString status);
void stepStatus(QString status);
public slots:
virtual void start();