diff options
author | Trial97 <alexandru.tripon97@gmail.com> | 2023-08-05 19:09:10 +0300 |
---|---|---|
committer | Trial97 <alexandru.tripon97@gmail.com> | 2023-08-05 19:09:10 +0300 |
commit | b2fdd8359405c93d0d93aa8c68971c986a1f68cb (patch) | |
tree | 59859119373213ce04b2f5e2d7a95227b57be609 /launcher/tasks/Task.h | |
parent | 149b6d59cf848a3b3cd50b3aee1c112e9c47e633 (diff) | |
parent | ae793f6cf11658c9abc5111e82d5ba7b3e6af127 (diff) | |
download | PrismLauncher-b2fdd8359405c93d0d93aa8c68971c986a1f68cb.tar.gz PrismLauncher-b2fdd8359405c93d0d93aa8c68971c986a1f68cb.tar.bz2 PrismLauncher-b2fdd8359405c93d0d93aa8c68971c986a1f68cb.zip |
Merge branch 'develop' of https://github.com/PrismLauncher/PrismLauncher into download_threads
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
Diffstat (limited to 'launcher/tasks/Task.h')
-rw-r--r-- | launcher/tasks/Task.h | 46 |
1 files changed, 22 insertions, 24 deletions
diff --git a/launcher/tasks/Task.h b/launcher/tasks/Task.h index 6d8bbbb4..7e1defd8 100644 --- a/launcher/tasks/Task.h +++ b/launcher/tasks/Task.h @@ -36,25 +36,20 @@ #pragma once +#include <QLoggingCategory> #include <QRunnable> #include <QUuid> -#include <QLoggingCategory> #include "QObjectPtr.h" Q_DECLARE_LOGGING_CATEGORY(taskLogC) -enum class TaskStepState { - Waiting, - Running, - Failed, - Succeeded -}; +enum class TaskStepState { Waiting, Running, Failed, Succeeded }; Q_DECLARE_METATYPE(TaskStepState) struct TaskStepProgress { - QUuid uid; + QUuid uid; qint64 current = 0; qint64 total = -1; @@ -64,14 +59,11 @@ struct TaskStepProgress { QString status = ""; QString details = ""; TaskStepState state = TaskStepState::Waiting; - TaskStepProgress() { - this->uid = QUuid::createUuid(); - } - TaskStepProgress(QUuid uid) { - this->uid = uid; - } + TaskStepProgress() { this->uid = QUuid::createUuid(); } + TaskStepProgress(QUuid uid) { this->uid = uid; } bool isDone() const { return (state == TaskStepState::Failed) || (state == TaskStepState::Succeeded); } - void update(qint64 current, qint64 total) { + void update(qint64 current, qint64 total) + { this->old_current = this->current; this->old_total = this->total; @@ -100,8 +92,8 @@ class Task : public QObject, public QRunnable { bool isFinished() const; bool wasSuccessful() const; - /*! - * MultiStep tasks are combinations of multiple tasks into a single logical task. + /*! + * MultiStep tasks are combinations of multiple tasks into a single logical task. * The main usage of this is in SequencialTask. */ virtual auto isMultiStep() const -> bool { return false; } @@ -125,8 +117,6 @@ class Task : public QObject, public QRunnable { qint64 getTotalProgress() { return m_progressTotal; } virtual auto getStepProgress() const -> TaskStepProgressList { return {}; } - - QUuid getUid() { return m_uid; } protected: @@ -155,9 +145,18 @@ class Task : public QObject, public QRunnable { void run() override { start(); } virtual void start(); - virtual bool abort() { if(canAbort()) emitAborted(); return canAbort(); }; - - void setAbortable(bool can_abort) { m_can_abort = can_abort; emit abortStatusChanged(can_abort); } + virtual bool abort() + { + if (canAbort()) + emitAborted(); + return canAbort(); + }; + + void setAbortable(bool can_abort) + { + m_can_abort = can_abort; + emit abortStatusChanged(can_abort); + } protected: virtual void executeTask() = 0; @@ -167,7 +166,7 @@ class Task : public QObject, public QRunnable { virtual void emitAborted(); virtual void emitFailed(QString reason = ""); - virtual void propogateStepProgress(TaskStepProgress const& task_progress); + virtual void propagateStepProgress(TaskStepProgress const& task_progress); public slots: void setStatus(const QString& status); @@ -190,5 +189,4 @@ class Task : public QObject, public QRunnable { // Change using setAbortStatus bool m_can_abort = false; QUuid m_uid; - }; |