1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-07 03:22:33 +01:00

Fix enum c++ to qml export

Remove custon CreateWallpaperData struct because it is no longer needed. All variables are now public members of the new createimportvideoo class
Fix removing of files when converting successful
This commit is contained in:
Elias 2019-03-28 19:02:47 +01:00
parent 6b370d57ba
commit 0352a88e02
9 changed files with 53 additions and 391 deletions

View File

@ -122,9 +122,7 @@
<file>qml/Community/XMLNewsfeed.qml</file> <file>qml/Community/XMLNewsfeed.qml</file>
<file>qml/Workshop/WorkshopAvailableTest.qml</file> <file>qml/Workshop/WorkshopAvailableTest.qml</file>
<file>qml/Workshop/WorkshopLoader.qml</file> <file>qml/Workshop/WorkshopLoader.qml</file>
<file>qml/Create/Wizards/CreateWallpaper/CreateWallpaperVideoImport.qml</file>
<file>qml/Create/Wizards/CreateWallpaper/CreateWallpaperVideoImportConvert.qml</file> <file>qml/Create/Wizards/CreateWallpaper/CreateWallpaperVideoImportConvert.qml</file>
<file>qml/Create/Wizards/CreateWallpaper/CreateWallpaperSuccess.qml</file> <file>qml/Create/Wizards/CreateWallpaper/CreateWallpaperResult.qml</file>
<file>qml/Create/Wizards/CreateWallpaper/CreateWallpaperError.qml</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@ -84,4 +84,22 @@ Item {
utility.setNavigation("Create") utility.setNavigation("Create")
} }
} }
states: [
State {
name: "error"
PropertyChanges {
target: txtFFMPEGDebug
text: "Error!"
}
},
State {
name: "success"
PropertyChanges {
target: txtFFMPEGDebug
text: "Success!"
}
}
]
} }

View File

@ -1,58 +0,0 @@
import QtQuick 2.12
import QtGraphicalEffects 1.0
import QtQuick.Controls 2.2
import QtQuick.Controls.Material 2.3
import Qt.labs.platform 1.0
import QtQuick.Layouts 1.3
import net.aimber.create 1.0
Item {
id: wrapperSuccess
opacity: 0
Text {
id: txtSuccessHeadline
text: qsTr("Video creation success!")
anchors {
top: parent.top
topMargin: 30
horizontalCenter: parent.horizontalCenter
}
height: 40
font.family: "Segoe UI, Roboto"
font.weight: Font.Light
color: Material.color(Material.Green)
font.pixelSize: 32
}
AnimatedImage {
id: imgSuccess
asynchronous: true
playing: true
anchors.centerIn: parent
width: 600
height: 400
}
Button {
id: btnSuccessBack
text: qsTr("Back to create!")
Material.background: Material.Orange
Material.foreground: "white"
anchors {
horizontalCenter: parent.horizontalCenter
bottom: parent.bottom
margins: 10
}
onClicked: {
utility.setNavigationActive(true)
utility.setNavigation("Create")
}
}
}
/*##^## Designer {
D{i:0;autoSize:true;height:768;width:1366}
}
##^##*/

View File

@ -1,245 +0,0 @@
import QtQuick 2.12
import QtGraphicalEffects 1.0
import QtQuick.Controls 2.2
import QtQuick.Controls.Material 2.3
import Qt.labs.platform 1.0
import QtQuick.Layouts 1.3
import net.aimber.create 1.0
Item {
id: wrapperContent
Text {
id: txtHeadline
text: qsTr("Import a video to a wallpaper")
height: 40
font.family: "Roboto"
font.weight: Font.Light
color: "#757575"
font.pixelSize: 23
anchors {
top: parent.top
left: parent.left
margins: 40
bottomMargin: 0
}
}
Item {
id: wrapperLeft
width: parent.width * .5
anchors {
left: parent.left
top: txtHeadline.bottom
margins: 30
bottom: parent.bottom
}
Rectangle {
id: imgWrapper
width: 425
height: 247
anchors {
top: parent.top
left: parent.left
}
color: Material.color(Material.Grey)
AnimatedImage {
id: imgPreview
asynchronous: true
playing: true
visible: false
anchors.fill: parent
}
BusyIndicator {
id: busyIndicator
anchors.centerIn: parent
running: true
}
Text {
id: txtConvertNumber
color: "white"
text: qsTr("")
font.pixelSize: 21
anchors {
horizontalCenter: parent.horizontalCenter
bottom: parent.bottom
bottomMargin: 40
}
}
Text {
id: txtConvert
color: "white"
text: qsTr("Generating preview video...")
font.pixelSize: 14
anchors {
horizontalCenter: parent.horizontalCenter
bottom: parent.bottom
bottomMargin: 20
}
}
}
RowLayout {
id: row
height: 50
anchors {
top: imgWrapper.bottom
topMargin: 20
right: parent.right
rightMargin: 30
left: parent.left
}
Rectangle {
height: 50
color: "#eeeeee"
Layout.fillWidth: true
Text {
id: txtCustomPreviewPath
color: "#333333"
text: qsTr("Add custom preview image")
anchors {
verticalCenter: parent.verticalCenter
left: parent.left
leftMargin: 10
}
}
Button {
id: button
Material.background: Material.Orange
Material.foreground: "white"
text: qsTr("Choose Image")
anchors {
right: parent.right
rightMargin: 10
}
onClicked: fileDialogOpenFile.open()
}
FileDialog {
id: fileDialogOpenFile
nameFilters: ["*.png *.jpg"]
onAccepted: {
var file = fileDialogOpenFile.file.toString()
txtCustomPreviewPath.text = fileDialogOpenFile.file
}
}
}
}
}
Item {
id: wrapperRight
width: parent.width * .5
anchors {
top: txtHeadline.bottom
topMargin: 30
bottom: parent.bottom
right: parent.right
}
ColumnLayout {
id: column
spacing: 0
anchors {
right: parent.right
left: parent.left
margins: 30
top:parent.top
topMargin: 0
bottom: column1.top
bottomMargin: 50
}
TextField {
id: textField
placeholderText: qsTr("Name")
width:parent.width
Layout.fillWidth: true
onTextChanged: {
if (textField.text.length >= 3) {
canNext = true
} else {
canNext = false
}
}
}
TextField {
id: textField1
placeholderText: qsTr("Description")
width:parent.width
Layout.fillWidth: true
}
TextField {
id: textField2
placeholderText: qsTr("Youtube URL")
width:parent.width
Layout.fillWidth: true
}
TextField {
id: textField3
width:parent.width
placeholderText: qsTr("Tags")
Layout.fillWidth: true
}
}
Row {
id: column1
height: 80
width: childrenRect.width
spacing: 10
anchors {
horizontalCenter: parent.horizontalCenter
bottom: parent.bottom
}
Button {
id: btnExit
text: qsTr("Abort")
Material.background: Material.Gray
Material.foreground: "white"
onClicked: {
screenPlayCreate.abort()
utility.setNavigationActive(true)
utility.setNavigation("Create")
}
}
NextButton {
id: btnFinish
onClicked: {
if (btnFinish.state === "enabled" && canNext) {
screenPlayCreate.createWallpaperProjectFile(
textField.text, textField1.text)
utility.setNavigationActive(true)
createNew.state = "success"
}
}
}
}
Connections {
target: screenPlayCreate
onCreateWallpaperStateChanged: {
if (state === CreateImportVideo.State.ConvertingVideoFinished) {
btnFinish.state = "enabled"
}
}
}
}
}

View File

@ -18,12 +18,8 @@ Item {
Component.onCompleted: { Component.onCompleted: {
state = "in" state = "in"
utility.setNavigationActive(false) utility.setNavigationActive(false)
loader_wrapperContent.source = "qrc:/qml/Create/Wizards/CreateWallpaper/CreateWallpaperVideoImportConvert.qml" loader_wrapperContent.source
// if (importState === CreateWallpaperWizard.ImportState.Import) { = "qrc:/qml/Create/Wizards/CreateWallpaper/CreateWallpaperVideoImportConvert.qml"
// loader_wrapperContent.source
// = "qrc:/qml/Create/Wizards/CreateWallpaper/CreateWallpaperVideoImport.qml"
// } else {
// }
} }
//Blocks some MouseArea from create page //Blocks some MouseArea from create page
@ -88,18 +84,12 @@ Item {
Loader { Loader {
id: loader_wrapperContent id: loader_wrapperContent
anchors.fill: parent anchors.fill: parent
z: 10 z: 10
} }
CreateWallpaperError { CreateWallpaperResult {
id: wrapperError id: wrapperResult
anchors.fill: parent
}
CreateWallpaperSuccess {
id: wrapperSuccess
anchors.fill: parent anchors.fill: parent
} }
@ -156,7 +146,7 @@ Item {
opacity: 0 opacity: 0
} }
PropertyChanges { PropertyChanges {
target: wrapperError target: wrapperResult
opacity: 0 opacity: 0
} }
}, },
@ -172,7 +162,7 @@ Item {
opacity: .4 opacity: .4
} }
PropertyChanges { PropertyChanges {
target: wrapperError target: wrapperResult
opacity: 0 opacity: 0
} }
}, },
@ -193,7 +183,7 @@ Item {
z: 0 z: 0
} }
PropertyChanges { PropertyChanges {
target: wrapperError target: wrapperResult
opacity: 1 opacity: 1
} }
}, },
@ -213,10 +203,6 @@ Item {
opacity: 0 opacity: 0
z: 0 z: 0
} }
PropertyChanges {
target: wrapperSuccess
opacity: 1
}
} }
] ]
transitions: [ transitions: [
@ -303,7 +289,7 @@ Item {
duration: 50 duration: 50
} }
PropertyAnimation { PropertyAnimation {
target: wrapperError target: wrapperResult
duration: 200 duration: 200
property: "opacity" property: "opacity"
easing.type: Easing.OutQuart easing.type: Easing.OutQuart
@ -323,12 +309,6 @@ Item {
PauseAnimation { PauseAnimation {
duration: 50 duration: 50
} }
PropertyAnimation {
target: wrapperSuccess
duration: 200
property: "opacity"
easing.type: Easing.OutQuart
}
} }
} }
] ]

View File

@ -9,7 +9,7 @@ Create::Create(Settings* st, QMLUtilities* util, QObject* parent)
qRegisterMetaType<CreateImportVideo::State>(); qRegisterMetaType<CreateImportVideo::State>();
qmlRegisterType<Create>("net.aimber.create", 1, 0, "Create"); qmlRegisterType<Create>("net.aimber.create", 1, 0, "Create");
qmlRegisterType<CreateImportVideo>("net.aimber.create", 1, 0, "Create"); qmlRegisterType<CreateImportVideo>("net.aimber.create", 1, 0, "CreateImportVideo");
} }
void Create::copyProject(QString relativeProjectPath, QString toPath) void Create::copyProject(QString relativeProjectPath, QString toPath)
@ -57,8 +57,6 @@ void Create::createWallpaperStart(QString videoPath)
QDir dir; QDir dir;
dir.cd(this->m_settings->localStoragePath().toLocalFile()); dir.cd(this->m_settings->localStoragePath().toLocalFile());
m_createWallpaperData.videoPath = videoPath;
// Create a temp dir so we can later alter it to the workshop id // Create a temp dir so we can later alter it to the workshop id
auto folderName = QString("_tmp_" + QTime::currentTime().toString()).replace(":", ""); auto folderName = QString("_tmp_" + QTime::currentTime().toString()).replace(":", "");
@ -67,34 +65,35 @@ void Create::createWallpaperStart(QString videoPath)
return; return;
} }
m_createWallpaperData.exportPath = dir.path() + "/" + folderName;
setWorkingDir(m_createWallpaperData.exportPath);
m_createImportVideoThread = new QThread; m_createImportVideoThread = new QThread;
m_createImportVideo = new CreateImportVideo(videoPath, m_createWallpaperData.exportPath); m_createImportVideo = new CreateImportVideo(videoPath, dir.path() + "/" + folderName);
//connect(m_createImportVideo, SIGNAL(error(QString)), this, SLOT(errorString(QString)));
connect(m_createImportVideo, &CreateImportVideo::createWallpaperStateChanged, this, &Create::createWallpaperStateChanged);
connect(m_createImportVideoThread, &QThread::started, m_createImportVideo, &CreateImportVideo::process); connect(m_createImportVideoThread, &QThread::started, m_createImportVideo, &CreateImportVideo::process);
connect(m_createImportVideo, &CreateImportVideo::finished, m_createImportVideoThread, &QThread::quit); connect(m_createImportVideo, &CreateImportVideo::finished, m_createImportVideoThread, &QThread::quit);
connect(m_createImportVideo, &CreateImportVideo::finished, m_createImportVideo, &QObject::deleteLater); connect(m_createImportVideo, &CreateImportVideo::finished, m_createImportVideo, &QObject::deleteLater);
connect(m_createImportVideoThread, &QThread::finished, m_createImportVideoThread, &QObject::deleteLater); connect(m_createImportVideoThread, &QThread::finished, m_createImportVideoThread, &QObject::deleteLater);
connect(m_createImportVideoThread, &QThread::destroyed, this, [this]() {
QDir exportPath(m_createWallpaperData.exportPath);
if (exportPath.exists()) {
if (!exportPath.removeRecursively()) {
emit createWallpaperStateChanged(CreateImportVideo::State::AbortCleanupError);
qWarning() << "Could not delete temp exportPath: " << exportPath;
} else {
qDebug() << "cleanup " << m_createWallpaperData.exportPath;
}
}
});
m_createImportVideo->moveToThread(m_createImportVideoThread); m_createImportVideo->moveToThread(m_createImportVideoThread);
m_createImportVideoThread->start(); m_createImportVideoThread->start();
} }
void Create::abortAndCleanup() void Create::abortAndCleanup()
{ {
// Save to export path before aborting to be able to cleanup the tmp folder
QString tmpExportPath = m_createImportVideo->m_exportPath;
connect(m_createImportVideoThread, &QThread::destroyed, this, [=]() {
QDir exportPath(tmpExportPath);
if (exportPath.exists()) {
if (!exportPath.removeRecursively()) {
emit createWallpaperStateChanged(CreateImportVideo::State::AbortCleanupError);
qWarning() << "Could not delete temp exportPath: " << exportPath;
} else {
qDebug() << "cleanup " << tmpExportPath;
}
}
});
m_createImportVideoThread->requestInterruption(); m_createImportVideoThread->requestInterruption();
} }

View File

@ -26,31 +26,16 @@
#include "qmlutilities.h" #include "qmlutilities.h"
#include "settings.h" #include "settings.h"
struct CreateWallpaperData {
CreateWallpaperData() {}
QString videoPath = "";
QString exportPath = "";
int length = 0;
int framerate = 0;
};
class Create : public QObject { class Create : public QObject {
Q_OBJECT Q_OBJECT
public: public:
explicit Create(Settings* st, QMLUtilities* util, QObject* parent = nullptr); explicit Create(Settings* st, QMLUtilities* util, QObject* parent = nullptr);
Q_PROPERTY(QString workingDir READ workingDir WRITE setWorkingDir NOTIFY workingDirChanged)
Q_PROPERTY(float progress READ progress WRITE setProgress NOTIFY progressChanged) Q_PROPERTY(float progress READ progress WRITE setProgress NOTIFY progressChanged)
Create() {} Create() {}
~Create() {} ~Create() {}
QString workingDir() const
{
return m_workingDir;
}
float progress() const float progress() const
{ {
return m_progress; return m_progress;
@ -59,7 +44,6 @@ public:
signals: signals:
void createWallpaperStateChanged(CreateImportVideo::State state); void createWallpaperStateChanged(CreateImportVideo::State state);
void processOutput(QString text); void processOutput(QString text);
void workingDirChanged(QString workingDir);
void progressChanged(float progress); void progressChanged(float progress);
void abortCreateWallpaper(); void abortCreateWallpaper();
@ -69,15 +53,6 @@ public slots:
void abortAndCleanup(); void abortAndCleanup();
void createWallpaperStart(QString videoPath); void createWallpaperStart(QString videoPath);
void setWorkingDir(QString workingDir)
{
if (m_workingDir == workingDir)
return;
m_workingDir = workingDir;
emit workingDirChanged(m_workingDir);
}
void setProgress(float progress) void setProgress(float progress)
{ {
if (qFuzzyCompare(m_progress, progress)) if (qFuzzyCompare(m_progress, progress))
@ -92,8 +67,6 @@ private:
Settings* m_settings; Settings* m_settings;
QThread* m_createImportVideoThread; QThread* m_createImportVideoThread;
QMLUtilities* m_utils; QMLUtilities* m_utils;
CreateWallpaperData m_createWallpaperData;
QString m_workingDir;
float m_progress = 0.0f;
float m_progress = 0.0f;
}; };

View File

@ -134,8 +134,6 @@ bool CreateImportVideo::createWallpaperVideoPreview()
args.append(m_exportPath + "/preview.webm"); args.append(m_exportPath + "/preview.webm");
QScopedPointer<QProcess> proConvertPreviewWebM(new QProcess()); QScopedPointer<QProcess> proConvertPreviewWebM(new QProcess());
qDebug() << args;
proConvertPreviewWebM.data()->setArguments(args); proConvertPreviewWebM.data()->setArguments(args);
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
proConvertPreviewWebM.data()->setProgram(QApplication::applicationDirPath() + "/ffmpeg.exe"); proConvertPreviewWebM.data()->setProgram(QApplication::applicationDirPath() + "/ffmpeg.exe");

View File

@ -50,6 +50,12 @@ public:
}; };
Q_ENUM(State) Q_ENUM(State)
QProcess m_process;
QString m_videoPath;
QString m_exportPath;
int m_length = 0;
int m_framerate = 0;
signals: signals:
void createWallpaperStateChanged(CreateImportVideo::State state); void createWallpaperStateChanged(CreateImportVideo::State state);
void processOutput(QString text); void processOutput(QString text);
@ -67,11 +73,4 @@ public slots:
bool createWallpaperImagePreview(); bool createWallpaperImagePreview();
bool extractWallpaperAudio(); bool extractWallpaperAudio();
bool createWallpaperProjectFile(const QString title, const QString description); bool createWallpaperProjectFile(const QString title, const QString description);
private:
QProcess m_process;
QString m_videoPath;
QString m_exportPath;
int m_length = 0;
int m_framerate = 0;
}; };