GH-1949 Allow modpacks.ch pack downloads to be aborted
This commit is contained in:
parent
d1a142f040
commit
db392b4994
@ -19,7 +19,11 @@ PackInstallTask::PackInstallTask(Modpack pack, QString version)
|
|||||||
|
|
||||||
bool PackInstallTask::abort()
|
bool PackInstallTask::abort()
|
||||||
{
|
{
|
||||||
return true;
|
if(abortable)
|
||||||
|
{
|
||||||
|
return jobPtr->abort();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PackInstallTask::executeTask()
|
void PackInstallTask::executeTask()
|
||||||
@ -117,16 +121,19 @@ void PackInstallTask::downloadPack()
|
|||||||
|
|
||||||
connect(jobPtr.get(), &NetJob::succeeded, this, [&]()
|
connect(jobPtr.get(), &NetJob::succeeded, this, [&]()
|
||||||
{
|
{
|
||||||
|
abortable = false;
|
||||||
jobPtr.reset();
|
jobPtr.reset();
|
||||||
install();
|
install();
|
||||||
});
|
});
|
||||||
connect(jobPtr.get(), &NetJob::failed, [&](QString reason)
|
connect(jobPtr.get(), &NetJob::failed, [&](QString reason)
|
||||||
{
|
{
|
||||||
|
abortable = false;
|
||||||
jobPtr.reset();
|
jobPtr.reset();
|
||||||
emitFailed(reason);
|
emitFailed(reason);
|
||||||
});
|
});
|
||||||
connect(jobPtr.get(), &NetJob::progress, [&](qint64 current, qint64 total)
|
connect(jobPtr.get(), &NetJob::progress, [&](qint64 current, qint64 total)
|
||||||
{
|
{
|
||||||
|
abortable = true;
|
||||||
setProgress(current, total);
|
setProgress(current, total);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ public:
|
|||||||
explicit PackInstallTask(Modpack pack, QString version);
|
explicit PackInstallTask(Modpack pack, QString version);
|
||||||
virtual ~PackInstallTask(){}
|
virtual ~PackInstallTask(){}
|
||||||
|
|
||||||
|
bool canAbort() const override { return true; }
|
||||||
bool abort() override;
|
bool abort() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -30,6 +31,8 @@ private:
|
|||||||
void install();
|
void install();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool abortable = false;
|
||||||
|
|
||||||
NetJobPtr jobPtr;
|
NetJobPtr jobPtr;
|
||||||
QByteArray response;
|
QByteArray response;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user