mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-22 18:52:30 +01:00
Add better data checks and important thread fixes
This commit is contained in:
parent
6d2497bd83
commit
4856c7ba9b
@ -65,18 +65,29 @@ bool SteamWorkshop::contentFolderExist(QString folder)
|
||||
|
||||
void SteamWorkshop::createLocalWorkshopItem(QString title, QUrl videoPath, QUrl previewPath)
|
||||
{
|
||||
QFuture<void> future = QtConcurrent::run([&]() {
|
||||
QFuture<void> future = QtConcurrent::run([=]() {
|
||||
|
||||
if (title.isEmpty() || videoPath.fileName() == "" || previewPath.fileName() == "") {
|
||||
emit workshopCreationCompleted(false);
|
||||
return;
|
||||
}
|
||||
|
||||
QString fromVideoPath = QString(videoPath.toString()).replace("file:///", "");
|
||||
QString fromImagePath =QString(previewPath.toString()).replace("file:///", "");
|
||||
QString fromImagePath = QString(previewPath.toString()).replace("file:///", "");
|
||||
QString toPath = m_settings->localStoragePath().toString() + "/" + title;
|
||||
QString toPathWithVideoFile = toPath + "/" + videoPath.fileName();
|
||||
QString toPathWithImageFile = toPath + "/" + previewPath.fileName();
|
||||
|
||||
if (!QDir(toPath).exists()) {
|
||||
if (QDir(toPath).exists()) {
|
||||
if (!QDir(toPath).isEmpty()) {
|
||||
emit workshopCreationFolderDuplicate();
|
||||
return;
|
||||
}
|
||||
|
||||
} else {
|
||||
//TODO: Display Error
|
||||
if (!QDir().mkdir(toPath)){
|
||||
emit workshopCreationComplete(false);
|
||||
if (!QDir().mkdir(toPath)) {
|
||||
emit workshopCreationCompleted(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -90,30 +101,32 @@ void SteamWorkshop::createLocalWorkshopItem(QString title, QUrl videoPath, QUrl
|
||||
|
||||
//Copy Image File
|
||||
if (QFile::copy(fromImagePath, toPathWithImageFile)) {
|
||||
emit workshopCreationCopyImage(true);
|
||||
emit workshopCreationCopyImage(true);
|
||||
} else {
|
||||
emit workshopCreationCopyImage(false);
|
||||
}
|
||||
|
||||
//Copy Project File
|
||||
QFile configFile(toPath + "/" + "project.json");
|
||||
if(!configFile.open(QIODevice::ReadWrite | QIODevice::Text))
|
||||
|
||||
if (!configFile.open(QIODevice::ReadWrite | QIODevice::Text))
|
||||
return;
|
||||
|
||||
QTextStream out(&configFile);
|
||||
QJsonObject configObj;
|
||||
|
||||
//configObj = configJsonDocument.object();
|
||||
configObj.insert("file",videoPath.fileName());
|
||||
//TODO
|
||||
configObj.insert("description","");
|
||||
configObj.insert("title",title);
|
||||
configObj.insert("preview",previewPath.fileName());
|
||||
|
||||
QJsonDocument configJsonDocument(configObj);
|
||||
configObj = configJsonDocument.object();
|
||||
|
||||
configObj.insert("file", videoPath.fileName());
|
||||
configObj.insert("preview", previewPath.fileName());
|
||||
|
||||
//TODO
|
||||
configObj.insert("description", "");
|
||||
configObj.insert("title", title);
|
||||
|
||||
out << configJsonDocument.toJson();
|
||||
configFile.close();
|
||||
emit workshopCreationComplete(true);
|
||||
emit workshopCreationCompleted(true);
|
||||
|
||||
});
|
||||
}
|
||||
|
@ -70,7 +70,8 @@ signals:
|
||||
// Workshop item creation
|
||||
void workshopCreationCopyVideo(bool sucessful);
|
||||
void workshopCreationCopyImage(bool sucessful);
|
||||
void workshopCreationComplete(bool sucessful);
|
||||
void workshopCreationCompleted(bool sucessful);
|
||||
void workshopCreationFolderDuplicate();
|
||||
|
||||
private:
|
||||
void workshopItemCreated(CreateItemResult_t* pCallback, bool bIOFailure);
|
||||
|
Loading…
Reference in New Issue
Block a user