diff --git a/ScreenPlay/src/create.cpp b/ScreenPlay/src/create.cpp index 2d24761a..945730fe 100644 --- a/ScreenPlay/src/create.cpp +++ b/ScreenPlay/src/create.cpp @@ -49,26 +49,24 @@ bool Create::copyRecursively(const QString& srcFilePath, const QString& tgtFileP void Create::createWallpaperStart(QString videoPath) { - videoPath.remove("file:///"); QtConcurrent::run([=]() { QDir dir; - dir.cd(m_settings->localStoragePath().toString()); + dir.cd(this->m_settings->localStoragePath().toString()); CreateWallpaperData createWallpaperData; createWallpaperData.videoPath = videoPath; // Create a temp dir so we can later alter it to the workshop id - createWallpaperData.exportPath = QString(dir.path() + "/" + "_tmp_" + QTime::currentTime().toString()).replace(":", ""); + auto folderName = QString( "_tmp_" + QTime::currentTime().toString()).replace(":", ""); - - if (dir.mkdir(createWallpaperData.exportPath)) { - // TODO - } else { + if (!dir.mkdir(folderName)) return; - } + + createWallpaperData.exportPath = dir.path() + "/" + folderName; + m_workingDir = createWallpaperData.exportPath; // If we return early/false this means the creation // process did not work @@ -205,10 +203,10 @@ bool Create::createWallpaperVideoPreview(CreateWallpaperData& createWallpaperDat emit createWallpaperStateChanged(Create::State::ConvertingPreviewVideoFinished); /* - * - * Create gif - * - */ + * + * Create gif + * + */ emit createWallpaperStateChanged(Create::State::ConvertingPreviewGif); args.clear(); @@ -239,7 +237,7 @@ bool Create::createWallpaperVideoPreview(CreateWallpaperData& createWallpaperDat bool Create::createWallpaperVideo(CreateWallpaperData& createWallpaperData) { - return true; + return true; } bool Create::createWallpaperProjectFile(CreateWallpaperData& createWallpaperData) diff --git a/ScreenPlay/src/create.h b/ScreenPlay/src/create.h index d3bff356..5b6189e1 100644 --- a/ScreenPlay/src/create.h +++ b/ScreenPlay/src/create.h @@ -34,6 +34,9 @@ class Create : public QObject { Q_OBJECT public: explicit Create(Settings* st, QMLUtilities* util, QObject* parent = nullptr); + + Q_PROPERTY(QString workingDir READ workingDir WRITE setWorkingDir NOTIFY workingDirChanged) + Create() {} ~Create() {} @@ -58,11 +61,18 @@ public: Q_ENUM(State) + QString workingDir() const + { + return m_workingDir; + } + signals: void createWallpaperStateChanged(Create::State state); void processOutput(QString text); + void workingDirChanged(QString workingDir); + public slots: void copyProject(QString relativeProjectPath, QString toPath); bool copyRecursively(const QString& srcFilePath, const QString& tgtFilePath); @@ -75,8 +85,18 @@ public slots: bool createWallpaperVideo(CreateWallpaperData& createWallpaperData); bool createWallpaperProjectFile(CreateWallpaperData& createWallpaperData); + void setWorkingDir(QString workingDir) + { + if (m_workingDir == workingDir) + return; + + m_workingDir = workingDir; + emit workingDirChanged(m_workingDir); + } + private: Settings* m_settings; QMLUtilities* m_utils; + QString m_workingDir; };