Merge branch 'develop' of https://github.com/PrismLauncher/PrismLauncher into download_threads

Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
Trial97
2023-08-15 12:49:21 +03:00
219 changed files with 3290 additions and 1839 deletions

View File

@ -88,6 +88,7 @@ bool ConcurrentTask::abort()
QMutableHashIterator<Task*, Task::Ptr> doing_iter(m_doing);
while (doing_iter.hasNext()) {
auto task = doing_iter.next();
disconnect(task->get(), &Task::aborted, this, 0);
suceedeed &= (task.value())->abort();
}
@ -130,6 +131,7 @@ void ConcurrentTask::startNext()
connect(next.get(), &Task::succeeded, this, [this, next]() { subTaskSucceeded(next); });
connect(next.get(), &Task::failed, this, [this, next](QString msg) { subTaskFailed(next, msg); });
connect(next.get(), &Task::aborted, this, [this, next] { subTaskFailed(next, "Aborted"); });
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); });
@ -171,7 +173,7 @@ void ConcurrentTask::subTaskSucceeded(Task::Ptr task)
startNext();
}
void ConcurrentTask::subTaskFailed(Task::Ptr task, const QString& msg)
void ConcurrentTask::subTaskFailed(Task::Ptr task, [[maybe_unused]] const QString& msg)
{
m_done.insert(task.get(), task);
m_failed.insert(task.get(), task);

View File

@ -56,7 +56,7 @@ class ConcurrentTask : public Task {
bool canAbort() const override { return true; }
inline auto isMultiStep() const -> bool override { return totalSize() > 1; };
inline auto isMultiStep() const -> bool override { return totalSize() > 1; }
auto getStepProgress() const -> TaskStepProgressList override;
void addTask(Task::Ptr task);
@ -83,7 +83,7 @@ class ConcurrentTask : public Task {
protected:
// NOTE: This is not thread-safe.
[[nodiscard]] unsigned int totalSize() const { return m_queue.size() + m_doing.size() + m_done.size(); }
[[nodiscard]] unsigned int totalSize() const { return static_cast<unsigned int>(m_queue.size() + m_doing.size() + m_done.size()); }
enum class Operation { ADDED, REMOVED, CHANGED };
void updateStepProgress(TaskStepProgress const& changed_progress, Operation);

View File

@ -59,16 +59,18 @@ struct TaskStepProgress {
QString status = "";
QString details = "";
TaskStepState state = TaskStepState::Waiting;
TaskStepProgress() { this->uid = QUuid::createUuid(); }
TaskStepProgress(QUuid uid) { this->uid = uid; }
TaskStepProgress(QUuid uid_) : uid(uid_) {}
bool isDone() const { return (state == TaskStepState::Failed) || (state == TaskStepState::Succeeded); }
void update(qint64 current, qint64 total)
void update(qint64 new_current, qint64 new_total)
{
this->old_current = this->current;
this->old_total = this->total;
this->current = current;
this->total = total;
this->current = new_current;
this->total = new_total;
this->state = TaskStepState::Running;
}
};
@ -150,7 +152,7 @@ class Task : public QObject, public QRunnable {
if (canAbort())
emitAborted();
return canAbort();
};
}
void setAbortable(bool can_abort)
{