57 lines
1.2 KiB
C++
57 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include <QObject>
|
|
#include <QString>
|
|
|
|
#include <memory>
|
|
|
|
class QProcess;
|
|
class QTemporaryDir;
|
|
|
|
namespace dts {
|
|
|
|
struct ConversionRequest {
|
|
QString editorPath;
|
|
QString editorVersion;
|
|
QString skeletonPath;
|
|
QString atlasPath;
|
|
QString outputParent;
|
|
QString assetName;
|
|
bool unpremultiplyAlpha = false;
|
|
};
|
|
|
|
class ConversionJob final : public QObject {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit ConversionJob(ConversionRequest request, QObject* parent = nullptr);
|
|
~ConversionJob() override;
|
|
void start();
|
|
|
|
signals:
|
|
void finished(bool success, const QString& outputDirectory, const QString& error);
|
|
|
|
private:
|
|
enum class Stage { Preparing, Unpacking, Importing, Publishing, Done };
|
|
|
|
bool prepare(QString& error);
|
|
bool writeUnpackAtlas(QString& error);
|
|
bool hasUnpackedImages() const;
|
|
void startUnpack();
|
|
void startImport();
|
|
void processFinished(int exitCode);
|
|
void fail(const QString& reason);
|
|
void publish();
|
|
|
|
ConversionRequest request_;
|
|
Stage stage_ = Stage::Preparing;
|
|
std::unique_ptr<QTemporaryDir> staging_;
|
|
QProcess* process_ = nullptr;
|
|
QString finalDirectory_;
|
|
QString projectPath_;
|
|
QString unpackAtlasPath_;
|
|
QString importScale_;
|
|
};
|
|
|
|
} // namespace dts
|