From 35942c5e5758b4f2ab95a624e75b4786bf150a3c Mon Sep 17 00:00:00 2001 From: Elias Date: Wed, 5 Dec 2018 13:15:24 +0100 Subject: [PATCH] Remove countless debugs Add success screen --- .../CreateWallpaper/CreateWallpaperWizard.qml | 50 +++++++++++++++---- ScreenPlay/src/create.cpp | 32 ++++++------ ScreenPlay/src/create.h | 1 - ScreenPlay/src/screenplay.cpp | 2 +- ScreenPlay/src/steamworkshop.cpp | 1 - 5 files changed, 58 insertions(+), 28 deletions(-) diff --git a/ScreenPlay/qml/Create/Wizards/CreateWallpaper/CreateWallpaperWizard.qml b/ScreenPlay/qml/Create/Wizards/CreateWallpaper/CreateWallpaperWizard.qml index 58a75781..b0fc37f0 100644 --- a/ScreenPlay/qml/Create/Wizards/CreateWallpaper/CreateWallpaperWizard.qml +++ b/ScreenPlay/qml/Create/Wizards/CreateWallpaper/CreateWallpaperWizard.qml @@ -164,22 +164,42 @@ Item { target: screenPlayCreate onCreateWallpaperStateChanged: { - if (state === Create.State.ConvertingPreviewGif) { - txtConvert.text = qsTr( - "Generating preview gif...") - } - if (state === Create.State.ConvertingPreviewImageFinished) { imgPreview.source = "file:///" + screenPlayCreate.workingDir + "/preview.png" imgPreview.visible = true + txtConvert.text = qsTr( + "Converting Video preview mp4") + } + + if (state === Create.State.ConvertingPreviewVideo) { + txtConvert.text = qsTr( + "Generating preview video...") + } + + if (state === Create.State.ConvertingPreviewGif) { + txtConvert.text = qsTr( + "Generating preview gif...") } if (state === Create.State.ConvertingPreviewGifFinished) { imgPreview.source = "file:///" + screenPlayCreate.workingDir + "/preview.gif" imgPreview.visible = true - txtConvert.text = qsTr("Converting Video") + imgPreview.playing = true + } + if (state === Create.State.ConvertingAudio) { + txtConvert.text = qsTr("Converting Audio...") + } + if (state === Create.State.ConvertingVideo) { + txtConvert.text = qsTr("Converting Video...") + } + + if (state === Create.State.Finished) { + imgSuccess.source = "file:///" + + screenPlayCreate.workingDir + "/preview.gif" + imgPreview.visible = true + imgPreview.playing = true } } onProgressChanged: { @@ -272,6 +292,8 @@ Item { if (btnFinish.state === "enabled" && canNext) { screenPlayCreate.createWallpaperProjectFile( textField.text, textField1.text) + utility.setNavigationActive(true) + createNew.state = "success" } } } @@ -376,7 +398,7 @@ Item { Text { id: txtSuccessHeadline - text: qsTr("An error occurred!") + text: qsTr("Video creation success!") anchors { top: parent.top topMargin: 30 @@ -385,11 +407,21 @@ Item { height: 40 font.family: "Segoe UI, Roboto" font.weight: Font.Light - color: Material.color(Material.Orange) + color: Material.color(Material.Green) renderType: Text.NativeRendering font.pixelSize: 32 } + AnimatedImage { + id: imgSuccess + asynchronous: true + playing: true + visible: false + anchors.centerIn: parent + width: 800 + height: 600 + } + Button { id: btnSuccessBack text: qsTr("Back to create!") @@ -518,7 +550,7 @@ Item { z: 0 } PropertyChanges { - target: wrapperError + target: wrapperSuccess opacity: 1 } } diff --git a/ScreenPlay/src/create.cpp b/ScreenPlay/src/create.cpp index 97c109dd..535720a2 100644 --- a/ScreenPlay/src/create.cpp +++ b/ScreenPlay/src/create.cpp @@ -67,6 +67,7 @@ void Create::createWallpaperStart(QString videoPath) m_createWallpaperData.exportPath = dir.path() + "/" + folderName; m_workingDir = m_createWallpaperData.exportPath; + // If we return early/false this means the creation // process did not work // Todo: cleanup! @@ -343,34 +344,34 @@ bool Create::createWallpaperVideo() args.append("-vn"); args.append(m_createWallpaperData.exportPath + "/audio.mp3"); - QScopedPointer proConvertImage(new QProcess()); - proConvertImage.data()->setArguments(args); - qDebug() << "Start extracting video to audio"; + QScopedPointer proConvertAudio(new QProcess()); + proConvertAudio.data()->setArguments(args); #ifdef Q_OS_WIN - proConvertImage.data()->setProgram(QApplication::applicationDirPath() + "/ffmpeg.exe"); + proConvertAudio.data()->setProgram(QApplication::applicationDirPath() + "/ffmpeg.exe"); #endif #ifdef Q_OS_MACOS pro.data()->setProgram(QApplication::applicationDirPath() + "/ffmpeg"); #endif - connect(this, &Create::abortCreateWallpaper, proConvertImage.data(), &QProcess::kill); - proConvertImage.data()->start(QIODevice::ReadOnly); - while (!proConvertImage.data()->waitForFinished(100)) //Wake up every 100ms and check if we must exit + connect(this, &Create::abortCreateWallpaper, proConvertAudio.data(), &QProcess::kill); + proConvertAudio.data()->start(QIODevice::ReadOnly); + while (!proConvertAudio.data()->waitForFinished(100)) //Wake up every 100ms and check if we must exit { QCoreApplication::processEvents(); } + disconnect(this, &Create::abortCreateWallpaper, proConvertAudio.data(), &QProcess::kill); - QString tmpErrImg = proConvertImage.data()->readAllStandardError(); + QString tmpErrImg = proConvertAudio.data()->readAllStandardError(); if (!tmpErrImg.isEmpty()) { - QFile previewImg(m_createWallpaperData.exportPath + "/preview.png"); + QFile previewImg(m_createWallpaperData.exportPath + "/audio.mp3"); if (!previewImg.exists() && !(previewImg.size() > 0)) { emit createWallpaperStateChanged(Create::State::ConvertingAudioError); return false; } } - this->processOutput(proConvertImage.data()->readAll()); - proConvertImage.data()->close(); + this->processOutput(proConvertAudio.data()->readAll()); + proConvertAudio.data()->close(); emit createWallpaperStateChanged(Create::State::ConvertingAudioFinished); /* @@ -412,8 +413,6 @@ bool Create::createWallpaperVideo() #ifdef Q_OS_MACOS proConvertVideo.data()->setProgram(QApplication::applicationDirPath() + "/ffmpeg"); #endif - qDebug() << "Start converting video"; - connect(proConvertVideo.data(), &QProcess::readyRead, this, [&]() { // Somehow readyRead gets seldom called in the end with an // not valid QProcess pointer.... @@ -433,7 +432,7 @@ bool Create::createWallpaperVideo() } QString tmpOut = proConvertVideo.data()->readAll(); - qDebug() << tmpOut << m_createWallpaperData.length; + auto tmpList = tmpOut.split(QRegExp("\\s+"), QString::SkipEmptyParts); if (tmpList.length() > 2) { bool ok = false; @@ -441,10 +440,9 @@ bool Create::createWallpaperVideo() if (!ok) return; - qDebug() << currentFrame << m_createWallpaperData.length << m_createWallpaperData.framerate; float progress = currentFrame / (m_createWallpaperData.length * m_createWallpaperData.framerate); - qDebug() << progress; + this->setProgress(progress); } this->processOutput(tmpOut); @@ -503,6 +501,8 @@ bool Create::createWallpaperProjectFile(const QString title, const QString descr out << configJsonDocument.toJson(); configFile.close(); return true; + + emit createWallpaperStateChanged(Create::State::Finished); } void Create::abort() diff --git a/ScreenPlay/src/create.h b/ScreenPlay/src/create.h index 81708725..dfc6911b 100644 --- a/ScreenPlay/src/create.h +++ b/ScreenPlay/src/create.h @@ -117,7 +117,6 @@ public slots: if (qFuzzyCompare(m_progress, progress)) return; - qDebug() << progress; m_progress = progress; emit progressChanged(m_progress); } diff --git a/ScreenPlay/src/screenplay.cpp b/ScreenPlay/src/screenplay.cpp index 88595262..442c3022 100644 --- a/ScreenPlay/src/screenplay.cpp +++ b/ScreenPlay/src/screenplay.cpp @@ -51,7 +51,7 @@ void ScreenPlay::removeAllWallpaper() void ScreenPlay::requestProjectSettingsListModelAt(int index) { - qDebug() << index << m_mlm->size(); + //Q_ASSERT(index > m_mlm->size()); for (int i = 0; i < m_screenPlayWallpaperList.count(); ++i) { if (m_screenPlayWallpaperList.at(i).data()->screenNumber().at(0) == index) { diff --git a/ScreenPlay/src/steamworkshop.cpp b/ScreenPlay/src/steamworkshop.cpp index b2ba5778..2119e3f1 100644 --- a/ScreenPlay/src/steamworkshop.cpp +++ b/ScreenPlay/src/steamworkshop.cpp @@ -202,7 +202,6 @@ void SteamWorkshop::onWorkshopSearched(SteamUGCQueryCompleted_t* pCallback, bool char* pchValue[cchValueSize]; uint32 results = pCallback->m_unTotalMatchingResults; - qDebug() << "ok " << results; for (uint32 i = 0; i < results; i++) { if (SteamUGC()->GetQueryUGCResult(pCallback->m_handle, i, &details)) {