From 5feb7715d659c03648310e091b437e02756eb6d3 Mon Sep 17 00:00:00 2001 From: Elias Date: Sat, 27 Jul 2019 13:51:00 +0200 Subject: [PATCH] Add ImageSelector placeholder text Fix skip conversion on webm --- ScreenPlay/qml/Common/ImageSelector.qml | 32 +++++++++++++++++-- .../CreateWallpaperVideoImportConvert.qml | 22 +++++++++---- ScreenPlay/src/create.cpp | 8 ++++- ScreenPlay/src/createimportvideo.cpp | 14 ++++---- 4 files changed, 60 insertions(+), 16 deletions(-) diff --git a/ScreenPlay/qml/Common/ImageSelector.qml b/ScreenPlay/qml/Common/ImageSelector.qml index 0c457f01..f51b085b 100644 --- a/ScreenPlay/qml/Common/ImageSelector.qml +++ b/ScreenPlay/qml/Common/ImageSelector.qml @@ -30,7 +30,7 @@ Item { state: "nothingSelected" property string imageSource - + property alias placeHolderText: txtPlaceholder.text onImageSourceChanged: { if (imageSource === "") { @@ -98,6 +98,24 @@ Item { } } + Text { + id: txtPlaceholder + clip: true + font.pointSize: 12 + font.family: "Roboto" + wrapMode: Text.WordWrap + color: Material.color(Material.Grey) + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignLeft + anchors { + top: parent.top + left: imgWrapper.right + right: btnClear.left + bottom: parent.bottom + margins: 10 + } + } + Text { id: txtName clip: true @@ -147,7 +165,7 @@ Item { id: fileDialog title: "Please choose a file" fileMode: FileDialog.OpenFile - nameFilters: [] + nameFilters: ["Images (*.png *.jpg)"] onAccepted: { imageSource = fileDialog.file txtName.text = fileDialog.file.toString().replace(/^.*[\\\/]/, @@ -164,6 +182,10 @@ Item { opacity: 1 anchors.topMargin: 5 } + PropertyChanges { + target: txtPlaceholder + opacity: 0 + } }, State { name: "nothingSelected" @@ -186,6 +208,12 @@ Item { duration: 300 easing.type: Easing.OutQuart } + PropertyAnimation { + target: txtPlaceholder + property: "opacity" + duration: 300 + easing.type: Easing.OutQuart + } } ] } diff --git a/ScreenPlay/qml/Create/Wizards/CreateWallpaper/CreateWallpaperVideoImportConvert.qml b/ScreenPlay/qml/Create/Wizards/CreateWallpaper/CreateWallpaperVideoImportConvert.qml index f73848a0..da59c888 100644 --- a/ScreenPlay/qml/Create/Wizards/CreateWallpaper/CreateWallpaperVideoImportConvert.qml +++ b/ScreenPlay/qml/Create/Wizards/CreateWallpaper/CreateWallpaperVideoImportConvert.qml @@ -33,7 +33,7 @@ Item { switch (state) { case CreateImportVideo.ConvertingPreviewImageFinished: - imgPreview.source = "file:///" + screenPlayCreate.workingDir + "/preview.png" + imgPreview.source = "file:///" + screenPlayCreate.workingDir + "/preview.jpg" imgPreview.visible = true txtConvert.text = qsTr("Converting Video preview mp4") break @@ -44,15 +44,16 @@ Item { txtConvert.text = qsTr("Generating preview gif...") break case CreateImportVideo.ConvertingPreviewGifFinished: - imgPreview.source = "file:///" + screenPlayCreate.workingDir + "/preview.gif" - imgPreview.visible = true - imgPreview.playing = true + gifPreview.source = "file:///" + screenPlayCreate.workingDir + "/preview.gif" + imgPreview.visible = false + gifPreview.visible = true + gifPreview.playing = true break case CreateImportVideo.ConvertingAudio: txtConvert.text = qsTr("Converting Audio...") break case CreateImportVideo.ConvertingVideo: - txtConvert.text = qsTr("Converting Video...") + txtConvert.text = qsTr("Converting Video... This can take some time!") break case CreateImportVideo.ConvertingVideoError: txtConvert.text = qsTr("Converting Video ERROR!") @@ -110,9 +111,16 @@ Item { left: parent.left } - AnimatedImage { + Image { id: imgPreview asynchronous: true + visible: false + anchors.fill: parent + } + + AnimatedImage { + id: gifPreview + asynchronous: true playing: true visible: false anchors.fill: parent @@ -150,7 +158,7 @@ Item { } ImageSelector { id: previewSelector - + placeHolderText: qsTr("You can set your own preview image here!") anchors { top: imgWrapper.bottom topMargin: 20 diff --git a/ScreenPlay/src/create.cpp b/ScreenPlay/src/create.cpp index afaa839a..dd0a8a04 100644 --- a/ScreenPlay/src/create.cpp +++ b/ScreenPlay/src/create.cpp @@ -96,7 +96,13 @@ void Create::saveWallpaper(QString title, QString description, QString filePath, obj.insert("description", description); obj.insert("title", title); obj.insert("youtube", youtube); - obj.insert("file", filePathFile.fileName()); + + // If the input file is a webm we don't need to convert it + if (filePath.endsWith(".webm")) { + obj.insert("file", filePathFile.fileName()); + } else { + obj.insert("file", filePathFile.baseName() + ".webm"); + } obj.insert("previewGIF", "preview.gif"); obj.insert("previewWEBM", "preview.webm"); if (previewImageFile.exists()) { diff --git a/ScreenPlay/src/createimportvideo.cpp b/ScreenPlay/src/createimportvideo.cpp index 2c421f0c..e8270c2f 100644 --- a/ScreenPlay/src/createimportvideo.cpp +++ b/ScreenPlay/src/createimportvideo.cpp @@ -35,10 +35,10 @@ void CreateImportVideo::process() if (!createWallpaperVideoPreview()) return; - if (!createWallpaperGifPreview()) + if (!createWallpaperImagePreview()) return; - if (!createWallpaperImagePreview()) + if (!createWallpaperGifPreview()) return; if (!createWallpaperVideo()) @@ -352,7 +352,10 @@ bool CreateImportVideo::createWallpaperVideo() args.append("yuv420p"); args.append("-b:v"); args.append("0"); - args.append(m_exportPath + "/video.webm"); + + QFileInfo file(m_videoPath); + QString convertedFileAbsolutePath {m_exportPath +"/"+ file.baseName() +".webm"}; + args.append(convertedFileAbsolutePath); QScopedPointer proConvertVideo(new QProcess()); proConvertVideo.data()->setArguments(args); @@ -379,15 +382,14 @@ bool CreateImportVideo::createWallpaperVideo() } QString tmpErrImg = proConvertVideo.data()->readAllStandardError(); if (!tmpErrImg.isEmpty()) { - QFile video(m_exportPath + "/video.webm"); + QFile video(convertedFileAbsolutePath); if (!video.exists() && !(video.size() > 0)) { - qDebug() << video.fileName() << proConvertVideo.data()->readAll(); + qDebug() << convertedFileAbsolutePath << proConvertVideo.data()->readAll(); emit createWallpaperStateChanged(ImportVideoState::ConvertingVideoError); return false; } } - //this->processOutput(proConvertImage.data()->readAll()); proConvertVideo.data()->close(); emit createWallpaperStateChanged(ImportVideoState::ConvertingVideoFinished);