aboutsummaryrefslogtreecommitdiff
path: root/launcher/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'launcher/tasks')
-rw-r--r--launcher/tasks/ConcurrentTask.cpp11
-rw-r--r--launcher/tasks/ConcurrentTask.h1
-rw-r--r--launcher/tasks/Task.cpp42
-rw-r--r--launcher/tasks/Task.h8
4 files changed, 44 insertions, 18 deletions
diff --git a/launcher/tasks/ConcurrentTask.cpp b/launcher/tasks/ConcurrentTask.cpp
index 41c405db..8d4f94ed 100644
--- a/launcher/tasks/ConcurrentTask.cpp
+++ b/launcher/tasks/ConcurrentTask.cpp
@@ -95,6 +95,7 @@ void ConcurrentTask::startNext()
connect(next.get(), &Task::failed, this, [this, next](QString msg) { subTaskFailed(next, msg); });
connect(next.get(), &Task::status, this, [this, next](QString msg){ subTaskStatus(next, msg); });
+ connect(next.get(), &Task::details, this, [this, next](QString msg){ subTaskDetails(next, msg); });
connect(next.get(), &Task::stepProgress, this, [this, next](TaskStepProgressList tp){ subTaskStepProgress(next, tp); });
connect(next.get(), &Task::progress, this, [this, next](qint64 current, qint64 total){ subTaskProgress(next, current, total); });
@@ -151,7 +152,14 @@ void ConcurrentTask::subTaskStatus(Task::Ptr task, const QString& msg)
auto taskProgress = m_task_progress.value(task->getUid());
taskProgress->status = msg;
taskProgress->state = TaskStepState::Running;
- updateState();
+ updateStepProgress();
+}
+
+void ConcurrentTask::subTaskDetails(Task::Ptr task, const QString& msg)
+{
+ auto taskProgress = m_task_progress.value(task->getUid());
+ taskProgress->details = msg;
+ taskProgress->state = TaskStepState::Running;
updateStepProgress();
}
@@ -162,7 +170,6 @@ void ConcurrentTask::subTaskProgress(Task::Ptr task, qint64 current, qint64 tota
taskProgress->current = current;
taskProgress->total = total;
taskProgress->state = TaskStepState::Running;
- taskProgress->details = task->getDetails();
updateStepProgress();
updateState();
diff --git a/launcher/tasks/ConcurrentTask.h b/launcher/tasks/ConcurrentTask.h
index 9d4413c6..43e9f866 100644
--- a/launcher/tasks/ConcurrentTask.h
+++ b/launcher/tasks/ConcurrentTask.h
@@ -40,6 +40,7 @@ slots:
void subTaskSucceeded(Task::Ptr);
void subTaskFailed(Task::Ptr, const QString &msg);
void subTaskStatus(Task::Ptr task, const QString &msg);
+ void subTaskDetails(Task::Ptr task, const QString &msg);
void subTaskProgress(Task::Ptr task, qint64 current, qint64 total);
void subTaskStepProgress(Task::Ptr task, TaskStepProgressList task_step_progress);
diff --git a/launcher/tasks/Task.cpp b/launcher/tasks/Task.cpp
index 5aada876..ffde4a10 100644
--- a/launcher/tasks/Task.cpp
+++ b/launcher/tasks/Task.cpp
@@ -37,7 +37,7 @@
#include <QDebug>
-Q_LOGGING_CATEGORY(TaskLogC, "Task")
+Q_LOGGING_CATEGORY(taskLogC, "launcher.task")
Task::Task(QObject *parent, bool show_debug) : QObject(parent), m_show_debug(show_debug)
{
@@ -54,11 +54,23 @@ void Task::setStatus(const QString &new_status)
}
}
+void Task::setDetails(const QString& new_details)
+{
+ if (m_details != new_details)
+ {
+ m_details = new_details;
+ emit details(m_details);
+ }
+}
+
void Task::setProgress(qint64 current, qint64 total)
{
- m_progress = current;
- m_progressTotal = total;
- emit progress(m_progress, m_progressTotal);
+ if ((m_progress != current) || (m_progressTotal != total)) {
+ m_progress = current;
+ m_progressTotal = total;
+
+ emit progress(m_progress, m_progressTotal);
+ }
}
void Task::start()
@@ -68,31 +80,31 @@ void Task::start()
case State::Inactive:
{
if (m_show_debug)
- qCDebug(TaskLogC) << "Task" << describe() << "starting for the first time";
+ qCDebug(taskLogC) << "Task" << describe() << "starting for the first time";
break;
}
case State::AbortedByUser:
{
if (m_show_debug)
- qCDebug(TaskLogC) << "Task" << describe() << "restarting for after being aborted by user";
+ qCDebug(taskLogC) << "Task" << describe() << "restarting for after being aborted by user";
break;
}
case State::Failed:
{
if (m_show_debug)
- qCDebug(TaskLogC) << "Task" << describe() << "restarting for after failing at first";
+ qCDebug(taskLogC) << "Task" << describe() << "restarting for after failing at first";
break;
}
case State::Succeeded:
{
if (m_show_debug)
- qCDebug(TaskLogC) << "Task" << describe() << "restarting for after succeeding at first";
+ qCDebug(taskLogC) << "Task" << describe() << "restarting for after succeeding at first";
break;
}
case State::Running:
{
if (m_show_debug)
- qCWarning(TaskLogC) << "The launcher tried to start task" << describe() << "while it was already running!";
+ qCWarning(taskLogC) << "The launcher tried to start task" << describe() << "while it was already running!";
return;
}
}
@@ -107,12 +119,12 @@ void Task::emitFailed(QString reason)
// Don't fail twice.
if (!isRunning())
{
- qCCritical(TaskLogC) << "Task" << describe() << "failed while not running!!!!: " << reason;
+ qCCritical(taskLogC) << "Task" << describe() << "failed while not running!!!!: " << reason;
return;
}
m_state = State::Failed;
m_failReason = reason;
- qCCritical(TaskLogC) << "Task" << describe() << "failed: " << reason;
+ qCCritical(taskLogC) << "Task" << describe() << "failed: " << reason;
emit failed(reason);
emit finished();
}
@@ -122,13 +134,13 @@ void Task::emitAborted()
// Don't abort twice.
if (!isRunning())
{
- qCCritical(TaskLogC) << "Task" << describe() << "aborted while not running!!!!";
+ qCCritical(taskLogC) << "Task" << describe() << "aborted while not running!!!!";
return;
}
m_state = State::AbortedByUser;
m_failReason = "Aborted.";
if (m_show_debug)
- qCDebug(TaskLogC) << "Task" << describe() << "aborted.";
+ qCDebug(taskLogC) << "Task" << describe() << "aborted.";
emit aborted();
emit finished();
}
@@ -138,12 +150,12 @@ void Task::emitSucceeded()
// Don't succeed twice.
if (!isRunning())
{
- qCCritical(TaskLogC) << "Task" << describe() << "succeeded while not running!!!!";
+ qCCritical(taskLogC) << "Task" << describe() << "succeeded while not running!!!!";
return;
}
m_state = State::Succeeded;
if (m_show_debug)
- qCDebug(TaskLogC) << "Task" << describe() << "succeeded";
+ qCDebug(taskLogC) << "Task" << describe() << "succeeded";
emit succeeded();
emit finished();
}
diff --git a/launcher/tasks/Task.h b/launcher/tasks/Task.h
index 863f8a4c..96b3b855 100644
--- a/launcher/tasks/Task.h
+++ b/launcher/tasks/Task.h
@@ -42,6 +42,8 @@
#include "QObjectPtr.h"
+Q_DECLARE_LOGGING_CATEGORY(taskLogC)
+
enum class TaskStepState {
Waiting,
Running,
@@ -100,12 +102,13 @@ class Task : public QObject, public QRunnable {
auto getState() const -> State { return m_state; }
QString getStatus() { return m_status; }
+ QString getDetails() { return m_details; }
qint64 getProgress() { return m_progress; }
qint64 getTotalProgress() { return m_progressTotal; }
virtual auto getStepProgress() const -> TaskStepProgressList { return {}; }
- virtual auto getDetails() const -> QString { return ""; }
+
QUuid getUid() { return m_uid; }
@@ -123,6 +126,7 @@ class Task : public QObject, public QRunnable {
void aborted();
void failed(QString reason);
void status(QString status);
+ void details(QString details);
void stepProgress(TaskStepProgressList task_progress); //
/** Emitted when the canAbort() status has changed.
@@ -150,6 +154,7 @@ class Task : public QObject, public QRunnable {
public slots:
void setStatus(const QString& status);
+ void setDetails(const QString& details);
void setProgress(qint64 current, qint64 total);
protected:
@@ -157,6 +162,7 @@ class Task : public QObject, public QRunnable {
QStringList m_Warnings;
QString m_failReason = "";
QString m_status;
+ QString m_details;
int m_progress = 0;
int m_progressTotal = 100;