1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-09-02 08:39:49 +02: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/Workshop/WorkshopAvailableTest.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/CreateWallpaperSuccess.qml</file>
<file>qml/Create/Wizards/CreateWallpaper/CreateWallpaperError.qml</file>
<file>qml/Create/Wizards/CreateWallpaper/CreateWallpaperResult.qml</file>
</qresource>
</RCC>

View File

@ -84,4 +84,22 @@ Item {
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: {
state = "in"
utility.setNavigationActive(false)
loader_wrapperContent.source = "qrc:/qml/Create/Wizards/CreateWallpaper/CreateWallpaperVideoImportConvert.qml"
// if (importState === CreateWallpaperWizard.ImportState.Import) {
// loader_wrapperContent.source
// = "qrc:/qml/Create/Wizards/CreateWallpaper/CreateWallpaperVideoImport.qml"
// } else {
// }
loader_wrapperContent.source
= "qrc:/qml/Create/Wizards/CreateWallpaper/CreateWallpaperVideoImportConvert.qml"
}
//Blocks some MouseArea from create page
@ -88,18 +84,12 @@ Item {
Loader {
id: loader_wrapperContent
anchors.fill: parent
z: 10
}
CreateWallpaperError {
id: wrapperError
anchors.fill: parent
}
CreateWallpaperSuccess {
id: wrapperSuccess
CreateWallpaperResult {
id: wrapperResult
anchors.fill: parent
}
@ -156,7 +146,7 @@ Item {
opacity: 0
}
PropertyChanges {
target: wrapperError
target: wrapperResult
opacity: 0
}
},
@ -172,7 +162,7 @@ Item {
opacity: .4
}
PropertyChanges {
target: wrapperError
target: wrapperResult
opacity: 0
}
},
@ -193,7 +183,7 @@ Item {
z: 0
}
PropertyChanges {
target: wrapperError
target: wrapperResult
opacity: 1
}
},
@ -213,10 +203,6 @@ Item {
opacity: 0
z: 0
}
PropertyChanges {
target: wrapperSuccess
opacity: 1
}
}
]
transitions: [
@ -303,7 +289,7 @@ Item {
duration: 50
}
PropertyAnimation {
target: wrapperError
target: wrapperResult
duration: 200
property: "opacity"
easing.type: Easing.OutQuart
@ -323,12 +309,6 @@ Item {
PauseAnimation {
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>();
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)
@ -57,8 +57,6 @@ void Create::createWallpaperStart(QString videoPath)
QDir dir;
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
auto folderName = QString("_tmp_" + QTime::currentTime().toString()).replace(":", "");
@ -67,34 +65,35 @@ void Create::createWallpaperStart(QString videoPath)
return;
}
m_createWallpaperData.exportPath = dir.path() + "/" + folderName;
setWorkingDir(m_createWallpaperData.exportPath);
m_createImportVideoThread = new QThread;
m_createImportVideo = new CreateImportVideo(videoPath, m_createWallpaperData.exportPath);
//connect(m_createImportVideo, SIGNAL(error(QString)), this, SLOT(errorString(QString)));
m_createImportVideo = new CreateImportVideo(videoPath, dir.path() + "/" + folderName);
connect(m_createImportVideo, &CreateImportVideo::createWallpaperStateChanged, this, &Create::createWallpaperStateChanged);
connect(m_createImportVideoThread, &QThread::started, m_createImportVideo, &CreateImportVideo::process);
connect(m_createImportVideo, &CreateImportVideo::finished, m_createImportVideoThread, &QThread::quit);
connect(m_createImportVideo, &CreateImportVideo::finished, m_createImportVideo, &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_createImportVideoThread->start();
}
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();
}

View File

@ -26,31 +26,16 @@
#include "qmlutilities.h"
#include "settings.h"
struct CreateWallpaperData {
CreateWallpaperData() {}
QString videoPath = "";
QString exportPath = "";
int length = 0;
int framerate = 0;
};
class Create : public QObject {
Q_OBJECT
public:
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)
Create() {}
~Create() {}
QString workingDir() const
{
return m_workingDir;
}
float progress() const
{
return m_progress;
@ -59,7 +44,6 @@ public:
signals:
void createWallpaperStateChanged(CreateImportVideo::State state);
void processOutput(QString text);
void workingDirChanged(QString workingDir);
void progressChanged(float progress);
void abortCreateWallpaper();
@ -69,15 +53,6 @@ public slots:
void abortAndCleanup();
void createWallpaperStart(QString videoPath);
void setWorkingDir(QString workingDir)
{
if (m_workingDir == workingDir)
return;
m_workingDir = workingDir;
emit workingDirChanged(m_workingDir);
}
void setProgress(float progress)
{
if (qFuzzyCompare(m_progress, progress))
@ -92,8 +67,6 @@ private:
Settings* m_settings;
QThread* m_createImportVideoThread;
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");
QScopedPointer<QProcess> proConvertPreviewWebM(new QProcess());
qDebug() << args;
proConvertPreviewWebM.data()->setArguments(args);
#ifdef Q_OS_WIN
proConvertPreviewWebM.data()->setProgram(QApplication::applicationDirPath() + "/ffmpeg.exe");

View File

@ -50,6 +50,12 @@ public:
};
Q_ENUM(State)
QProcess m_process;
QString m_videoPath;
QString m_exportPath;
int m_length = 0;
int m_framerate = 0;
signals:
void createWallpaperStateChanged(CreateImportVideo::State state);
void processOutput(QString text);
@ -67,11 +73,4 @@ public slots:
bool createWallpaperImagePreview();
bool extractWallpaperAudio();
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;
};