aboutsummaryrefslogtreecommitdiff
path: root/launcher/tasks/MultipleOptionsTask.cpp
diff options
context:
space:
mode:
authorflow <flowlnlnln@gmail.com>2022-07-21 22:40:06 -0300
committerflow <flowlnlnln@gmail.com>2022-08-28 16:29:01 -0300
commit87a0482b8b299fd54691e3042ca661863ea6290a (patch)
tree5a3075bf4735d8048c2da00fabfafcabf223982e /launcher/tasks/MultipleOptionsTask.cpp
parente89969991868b05723ae87454d4e22e370137d15 (diff)
downloadPrismLauncher-87a0482b8b299fd54691e3042ca661863ea6290a.tar.gz
PrismLauncher-87a0482b8b299fd54691e3042ca661863ea6290a.tar.bz2
PrismLauncher-87a0482b8b299fd54691e3042ca661863ea6290a.zip
refactor: make MultipleOptionsTask inherit from ConcurrentTask too
Signed-off-by: flow <flowlnlnln@gmail.com>
Diffstat (limited to 'launcher/tasks/MultipleOptionsTask.cpp')
-rw-r--r--launcher/tasks/MultipleOptionsTask.cpp43
1 files changed, 11 insertions, 32 deletions
diff --git a/launcher/tasks/MultipleOptionsTask.cpp b/launcher/tasks/MultipleOptionsTask.cpp
index 6e853568..7741bef0 100644
--- a/launcher/tasks/MultipleOptionsTask.cpp
+++ b/launcher/tasks/MultipleOptionsTask.cpp
@@ -2,47 +2,26 @@
#include <QDebug>
-MultipleOptionsTask::MultipleOptionsTask(QObject* parent, const QString& task_name) : SequentialTask(parent, task_name) {}
+MultipleOptionsTask::MultipleOptionsTask(QObject* parent, const QString& task_name) : ConcurrentTask(parent, task_name) {}
void MultipleOptionsTask::startNext()
{
- Task* previous = nullptr;
- if (m_currentIndex != -1) {
- previous = m_queue[m_currentIndex].get();
- disconnect(previous, 0, this, 0);
- }
-
- m_currentIndex++;
- if ((previous && previous->wasSuccessful())) {
+ if (m_done.size() != m_failed.size()) {
emitSucceeded();
return;
}
- Task::Ptr next = m_queue[m_currentIndex];
-
- connect(next.get(), &Task::failed, this, &MultipleOptionsTask::subTaskFailed);
- connect(next.get(), &Task::succeeded, this, &MultipleOptionsTask::startNext);
-
- connect(next.get(), &Task::status, this, &MultipleOptionsTask::subTaskStatus);
- connect(next.get(), &Task::stepStatus, this, &MultipleOptionsTask::subTaskStatus);
-
- connect(next.get(), &Task::progress, this, &MultipleOptionsTask::subTaskProgress);
-
- qDebug() << QString("Making attemp %1 out of %2").arg(m_currentIndex + 1).arg(m_queue.size());
- setStatus(tr("Making attempt #%1 out of %2").arg(m_currentIndex + 1).arg(m_queue.size()));
- setStepStatus(next->isMultiStep() ? next->getStepStatus() : next->getStatus());
+ if (m_queue.isEmpty()) {
+ emitFailed(tr("All attempts have failed!"));
+ qWarning() << "All attempts have failed!";
+ return;
+ }
- next->start();
+ ConcurrentTask::startNext();
}
-void MultipleOptionsTask::subTaskFailed(QString const& reason)
+void MultipleOptionsTask::updateState()
{
- qDebug() << QString("Failed attempt #%1 of %2. Reason: %3").arg(m_currentIndex + 1).arg(m_queue.size()).arg(reason);
- if(m_currentIndex < m_queue.size() - 1) {
- startNext();
- return;
- }
-
- qWarning() << QString("All attempts have failed!");
- emitFailed();
+ setProgress(m_done.count(), m_total_size);
+ setStatus(tr("Attempting task %1 out of %2").arg(QString::number(m_doing.count() + m_done.count()), QString::number(m_total_size)));
}