1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-22 10:42:29 +01:00

Remove countless debugs

Add success screen
This commit is contained in:
Elias 2018-12-05 13:15:24 +01:00
parent e4904b8904
commit 35942c5e57
5 changed files with 58 additions and 28 deletions

View File

@ -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
}
}

View File

@ -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<QProcess> proConvertImage(new QProcess());
proConvertImage.data()->setArguments(args);
qDebug() << "Start extracting video to audio";
QScopedPointer<QProcess> 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()

View File

@ -117,7 +117,6 @@ public slots:
if (qFuzzyCompare(m_progress, progress))
return;
qDebug() << progress;
m_progress = progress;
emit progressChanged(m_progress);
}

View File

@ -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) {

View File

@ -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)) {