made hasing task async

Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
Trial97
2024-06-18 17:27:17 +03:00
parent 766ddc80e3
commit 9cbdbddb08
3 changed files with 32 additions and 17 deletions

View File

@ -1,6 +1,8 @@
#pragma once
#include <QCryptographicHash>
#include <QFuture>
#include <QFutureWatcher>
#include <QString>
#include "modplatform/ModIndex.h"
@ -24,8 +26,7 @@ class Hasher : public Task {
Hasher(QString file_path, Algorithm alg) : m_path(file_path), m_alg(alg) {}
Hasher(QString file_path, QString alg) : Hasher(file_path, algorithmFromString(alg)) {}
/* We can't really abort this task, but we can say we aborted and finish our thing quickly :) */
bool abort() override { return true; }
bool abort() override;
void executeTask() override;
@ -35,10 +36,13 @@ class Hasher : public Task {
signals:
void resultsReady(QString hash);
protected:
private:
QString m_result;
QString m_path;
Algorithm m_alg;
QFuture<QString> m_zip_future;
QFutureWatcher<QString> m_zip_watcher;
};
Hasher::Ptr createHasher(QString file_path, ModPlatform::ResourceProvider provider);