sneedmc/api/logic/modplatform/legacy_ftb/PackInstallTask.h

55 lines
1.1 KiB
C
Raw Normal View History

#pragma once
2018-03-19 01:36:12 +00:00
#include "InstanceTask.h"
#include "net/NetJob.h"
#include "quazip.h"
#include "quazipdir.h"
#include "meta/Index.h"
#include "meta/Version.h"
#include "meta/VersionList.h"
#include "PackHelpers.h"
#include <nonstd/optional>
namespace LegacyFTB {
class MULTIMC_LOGIC_EXPORT PackInstallTask : public InstanceTask
{
2018-07-15 12:51:05 +00:00
Q_OBJECT
public:
explicit PackInstallTask(Modpack pack, QString version);
virtual ~PackInstallTask(){}
2018-03-19 01:36:12 +00:00
2018-07-15 12:51:05 +00:00
bool abort() override;
protected:
2018-07-15 12:51:05 +00:00
//! Entry point for tasks.
virtual void executeTask() override;
2018-03-19 01:36:12 +00:00
private:
2018-07-15 12:51:05 +00:00
void downloadPack();
void unzip();
void install();
private slots:
2018-07-15 12:51:05 +00:00
void onDownloadSucceeded();
void onDownloadFailed(QString reason);
void onDownloadProgress(qint64 current, qint64 total);
2018-07-15 12:51:05 +00:00
void onUnzipFinished();
void onUnzipCanceled();
2018-03-19 01:36:12 +00:00
private: /* data */
2018-07-15 12:51:05 +00:00
bool abortable = false;
std::unique_ptr<QuaZip> m_packZip;
QFuture<nonstd::optional<QStringList>> m_extractFuture;
QFutureWatcher<nonstd::optional<QStringList>> m_extractFutureWatcher;
2018-07-15 12:51:05 +00:00
NetJobPtr netJobContainer;
QString archivePath;
Modpack m_pack;
2018-07-15 12:51:05 +00:00
QString m_version;
};
}