mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-07 03:22:33 +01:00
Add basic error check
This commit is contained in:
parent
989dc77046
commit
51ab2b6006
@ -18,6 +18,17 @@ Item {
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: screenPlayCreate
|
||||||
|
onCreateWallpaperStateChanged: {
|
||||||
|
print(state)
|
||||||
|
if (state === Create.State.ConvertingPreviewGifError ||
|
||||||
|
state === Create.State.ConvertingPreviewVideoError) {
|
||||||
|
createNew.state = "error"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
interval: 1000
|
interval: 1000
|
||||||
triggeredOnStart: false
|
triggeredOnStart: false
|
||||||
@ -63,189 +74,198 @@ Item {
|
|||||||
radius: 4
|
radius: 4
|
||||||
height: 560
|
height: 560
|
||||||
|
|
||||||
Text {
|
Item {
|
||||||
id: txtHeadline
|
id: wrapperSteps
|
||||||
text: qsTr("Convert a video to a wallpaper")
|
anchors.fill: parent
|
||||||
height: 40
|
|
||||||
font.family: "Roboto"
|
|
||||||
font.weight: Font.Light
|
|
||||||
color: "#757575"
|
|
||||||
renderType: Text.NativeRendering
|
|
||||||
font.pixelSize: 23
|
|
||||||
anchors {
|
|
||||||
top: parent.top
|
|
||||||
left: parent.left
|
|
||||||
margins: 40
|
|
||||||
bottomMargin: 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SwipeView {
|
|
||||||
id: view
|
|
||||||
clip: true
|
|
||||||
currentIndex: 0
|
|
||||||
interactive: false
|
|
||||||
onCurrentIndexChanged: {
|
|
||||||
|
|
||||||
|
Text {
|
||||||
|
id: txtHeadline
|
||||||
|
text: qsTr("Convert a video to a wallpaper")
|
||||||
|
height: 40
|
||||||
|
font.family: "Roboto"
|
||||||
|
font.weight: Font.Light
|
||||||
|
color: "#757575"
|
||||||
|
renderType: Text.NativeRendering
|
||||||
|
font.pixelSize: 23
|
||||||
|
anchors {
|
||||||
|
top: parent.top
|
||||||
|
left: parent.left
|
||||||
|
margins: 40
|
||||||
|
bottomMargin: 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
anchors {
|
SwipeView {
|
||||||
top: txtHeadline.bottom
|
id: view
|
||||||
right: parent.right
|
clip: true
|
||||||
bottom: indicator.top
|
currentIndex: 0
|
||||||
left: parent.left
|
interactive: false
|
||||||
margins: 40
|
onCurrentIndexChanged: {
|
||||||
bottomMargin: 20
|
|
||||||
topMargin: 0
|
|
||||||
}
|
|
||||||
|
|
||||||
Page_0 {
|
}
|
||||||
id: page_0
|
|
||||||
onCanNextChanged: {
|
anchors {
|
||||||
if (canNext) {
|
top: txtHeadline.bottom
|
||||||
btnNext.state = "enabledPage0"
|
right: parent.right
|
||||||
} else {
|
bottom: indicator.top
|
||||||
|
left: parent.left
|
||||||
|
margins: 40
|
||||||
|
bottomMargin: 20
|
||||||
|
topMargin: 0
|
||||||
|
}
|
||||||
|
|
||||||
|
Page_0 {
|
||||||
|
id: page_0
|
||||||
|
onCanNextChanged: {
|
||||||
|
if (canNext) {
|
||||||
|
btnNext.state = "enabledPage0"
|
||||||
|
} else {
|
||||||
|
if (gifCreated) {
|
||||||
|
btnNext.state = "diabledPage0NoTitle"
|
||||||
|
} else {
|
||||||
|
btnNext.state = "diabledPage0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onGifCreatedChanged: {
|
||||||
if (gifCreated) {
|
if (gifCreated) {
|
||||||
btnNext.state = "diabledPage0NoTitle"
|
btnNext.state = "diabledPage0NoTitle"
|
||||||
} else {
|
|
||||||
btnNext.state = "diabledPage0"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onGifCreatedChanged: {
|
Page_1 {
|
||||||
if (gifCreated) {
|
id: secondPage
|
||||||
btnNext.state = "diabledPage0NoTitle"
|
}
|
||||||
|
Page_2 {
|
||||||
|
id: thirdPage
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PageIndicator {
|
||||||
|
id: indicator
|
||||||
|
count: view.count
|
||||||
|
currentIndex: view.currentIndex
|
||||||
|
anchors {
|
||||||
|
bottom: parent.bottom
|
||||||
|
bottomMargin: 20
|
||||||
|
left: parent.left
|
||||||
|
leftMargin: 40
|
||||||
|
}
|
||||||
|
|
||||||
|
delegate: Item {
|
||||||
|
width: txtStep.paintedWidth + 20
|
||||||
|
height: 30
|
||||||
|
property bool filled
|
||||||
|
Text {
|
||||||
|
id: txtStep
|
||||||
|
text: {
|
||||||
|
switch (index) {
|
||||||
|
case 0:
|
||||||
|
return "1. Configure"
|
||||||
|
case 1:
|
||||||
|
return "2. Convert"
|
||||||
|
case 2:
|
||||||
|
return "3. Finish"
|
||||||
|
default:
|
||||||
|
return "Undefiend"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
color: view.currentIndex == index ? "orange" : "gray"
|
||||||
|
renderType: Text.NativeRendering
|
||||||
|
font.family: "Roboto"
|
||||||
|
font.pixelSize: 14
|
||||||
|
anchors {
|
||||||
|
left: parent.left
|
||||||
|
verticalCenter: parent.verticalCenter
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
onClicked: {
|
||||||
|
|
||||||
|
if (!page_0.canNext || !page_0.gifCreated)
|
||||||
|
return
|
||||||
|
|
||||||
|
view.setCurrentIndex(index)
|
||||||
|
}
|
||||||
|
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Page_1 {
|
|
||||||
id: secondPage
|
|
||||||
}
|
|
||||||
Page_2 {
|
|
||||||
id: thirdPage
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PageIndicator {
|
Row {
|
||||||
id: indicator
|
width: childrenRect.width
|
||||||
count: view.count
|
height: 50
|
||||||
currentIndex: view.currentIndex
|
spacing: 20
|
||||||
anchors {
|
anchors {
|
||||||
bottom: parent.bottom
|
bottom: parent.bottom
|
||||||
bottomMargin: 20
|
right: parent.right
|
||||||
left: parent.left
|
margins: 20
|
||||||
leftMargin: 40
|
rightMargin: 40
|
||||||
}
|
}
|
||||||
|
Button {
|
||||||
|
text: qsTr("Back")
|
||||||
|
Material.background: Material.Gray
|
||||||
|
Material.foreground: "white"
|
||||||
|
|
||||||
delegate: Item {
|
icon.source: "qrc:/assets/icons/icon_arrow_left.svg"
|
||||||
width: txtStep.paintedWidth + 20
|
icon.color: "white"
|
||||||
height: 30
|
icon.width: 16
|
||||||
property bool filled
|
icon.height: 16
|
||||||
Text {
|
onClicked: {
|
||||||
id: txtStep
|
if (view.currentIndex > 0)
|
||||||
text: {
|
view.setCurrentIndex(view.currentIndex - 1)
|
||||||
switch (index) {
|
|
||||||
case 0:
|
|
||||||
return "1. Configure"
|
|
||||||
case 1:
|
|
||||||
return "2. Convert"
|
|
||||||
case 2:
|
|
||||||
return "3. Finish"
|
|
||||||
default:
|
|
||||||
return "Undefiend"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
color: view.currentIndex == index ? "orange" : "gray"
|
|
||||||
renderType: Text.NativeRendering
|
|
||||||
font.family: "Roboto"
|
|
||||||
font.pixelSize: 14
|
|
||||||
anchors {
|
|
||||||
left: parent.left
|
|
||||||
verticalCenter: parent.verticalCenter
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
NextButton {
|
||||||
|
id: btnNext
|
||||||
|
state: "diabledPage0"
|
||||||
|
onClicked: {
|
||||||
|
|
||||||
MouseArea {
|
if (!page_0.canNext || !page_0.gifCreated)
|
||||||
anchors.fill: parent
|
return
|
||||||
onClicked: {
|
|
||||||
view.setCurrentIndex(index)
|
|
||||||
}
|
|
||||||
|
|
||||||
cursorShape: Qt.PointingHandCursor
|
if (view.currentIndex < view.count - 1)
|
||||||
|
view.setCurrentIndex(view.currentIndex + 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Row {
|
MouseArea {
|
||||||
width: childrenRect.width
|
anchors {
|
||||||
height: 50
|
top: parent.top
|
||||||
spacing: 20
|
right: parent.right
|
||||||
anchors {
|
margins: 5
|
||||||
bottom: parent.bottom
|
}
|
||||||
right: parent.right
|
width: 32
|
||||||
margins: 20
|
height: width
|
||||||
rightMargin: 40
|
cursorShape: Qt.PointingHandCursor
|
||||||
}
|
|
||||||
Button {
|
|
||||||
text: qsTr("Back")
|
|
||||||
Material.background: Material.Gray
|
|
||||||
Material.foreground: "white"
|
|
||||||
|
|
||||||
icon.source: "qrc:/assets/icons/icon_arrow_left.svg"
|
|
||||||
icon.color: "white"
|
|
||||||
icon.width: 16
|
|
||||||
icon.height: 16
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (view.currentIndex > 0)
|
createNew.state = "out"
|
||||||
view.setCurrentIndex(view.currentIndex - 1)
|
timerBack.start()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
NextButton {
|
|
||||||
id: btnNext
|
|
||||||
state: "diabledPage0"
|
|
||||||
onClicked: {
|
|
||||||
|
|
||||||
if (!page_0.canNext || !page_0.gifCreated )
|
Image {
|
||||||
return
|
id: imgClose
|
||||||
|
source: "qrc:/assets/icons/font-awsome/close.svg"
|
||||||
if (view.currentIndex < view.count - 1)
|
width: 16
|
||||||
view.setCurrentIndex(view.currentIndex + 1)
|
height: 16
|
||||||
|
anchors.centerIn: parent
|
||||||
|
sourceSize: Qt.size(width, width)
|
||||||
|
}
|
||||||
|
ColorOverlay {
|
||||||
|
id: iconColorOverlay
|
||||||
|
anchors.fill: imgClose
|
||||||
|
source: imgClose
|
||||||
|
color: "gray"
|
||||||
|
}
|
||||||
|
Timer {
|
||||||
|
id: timerBack
|
||||||
|
interval: 800
|
||||||
|
onTriggered: utility.setNavigation("Create")
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
anchors {
|
|
||||||
top: parent.top
|
|
||||||
right: parent.right
|
|
||||||
margins: 5
|
|
||||||
}
|
|
||||||
width: 32
|
|
||||||
height: width
|
|
||||||
cursorShape: Qt.PointingHandCursor
|
|
||||||
onClicked: {
|
|
||||||
createNew.state = "out"
|
|
||||||
timerBack.start()
|
|
||||||
}
|
|
||||||
|
|
||||||
Image {
|
|
||||||
id: imgClose
|
|
||||||
source: "qrc:/assets/icons/font-awsome/close.svg"
|
|
||||||
width: 16
|
|
||||||
height: 16
|
|
||||||
anchors.centerIn: parent
|
|
||||||
sourceSize: Qt.size(width, width)
|
|
||||||
}
|
|
||||||
ColorOverlay {
|
|
||||||
id: iconColorOverlay
|
|
||||||
anchors.fill: imgClose
|
|
||||||
source: imgClose
|
|
||||||
color: "gray"
|
|
||||||
}
|
|
||||||
Timer {
|
|
||||||
id: timerBack
|
|
||||||
interval: 800
|
|
||||||
onTriggered: utility.setNavigation("Create")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -274,6 +294,22 @@ Item {
|
|||||||
target: effect
|
target: effect
|
||||||
opacity: .4
|
opacity: .4
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
State {
|
||||||
|
name: "error"
|
||||||
|
PropertyChanges {
|
||||||
|
target: wrapper
|
||||||
|
anchors.topMargin: 40
|
||||||
|
opacity: 1
|
||||||
|
}
|
||||||
|
PropertyChanges {
|
||||||
|
target: effect
|
||||||
|
opacity: .4
|
||||||
|
}
|
||||||
|
PropertyChanges {
|
||||||
|
target: wrapperSteps
|
||||||
|
opacity: 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
transitions: [
|
transitions: [
|
||||||
@ -345,6 +381,16 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
Transition {
|
||||||
|
from: "in"
|
||||||
|
to: "error"
|
||||||
|
PropertyAnimation {
|
||||||
|
target: wrapperSteps
|
||||||
|
duration: 600
|
||||||
|
property: "opacity"
|
||||||
|
easing.type: Easing.InOutQuad
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,6 @@ void Create::createWallpaperStart(QString videoPath)
|
|||||||
videoPath.remove("file:///");
|
videoPath.remove("file:///");
|
||||||
|
|
||||||
QtConcurrent::run([=]() {
|
QtConcurrent::run([=]() {
|
||||||
|
|
||||||
QDir dir;
|
QDir dir;
|
||||||
dir.cd(this->m_settings->localStoragePath().toString());
|
dir.cd(this->m_settings->localStoragePath().toString());
|
||||||
|
|
||||||
@ -60,7 +59,7 @@ void Create::createWallpaperStart(QString videoPath)
|
|||||||
createWallpaperData.videoPath = videoPath;
|
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(":", "");
|
||||||
|
|
||||||
if (!dir.mkdir(folderName))
|
if (!dir.mkdir(folderName))
|
||||||
return;
|
return;
|
||||||
@ -189,15 +188,20 @@ bool Create::createWallpaperVideoPreview(CreateWallpaperData& createWallpaperDat
|
|||||||
|
|
||||||
QScopedPointer<QTimer> processOutputTimer(new QTimer());
|
QScopedPointer<QTimer> processOutputTimer(new QTimer());
|
||||||
|
|
||||||
connect(processOutputTimer.data(), &QTimer::timeout, [&]() {
|
// connect(processOutputTimer.data(), &QTimer::timeout, [&]() {
|
||||||
qDebug() << "### " << proConvertPreviewMP4.data()->readAll();
|
// qDebug() << "### " << proConvertPreviewMP4.data()->readAll();
|
||||||
this->processOutput(proConvertPreviewMP4.data()->readAll());
|
// this->processOutput(proConvertPreviewMP4.data()->readAll());
|
||||||
});
|
// });
|
||||||
processOutputTimer.data()->start(100);
|
processOutputTimer.data()->start(100);
|
||||||
proConvertPreviewMP4.data()->waitForFinished(-1);
|
proConvertPreviewMP4.data()->waitForFinished(-1);
|
||||||
|
if (!proConvertPreviewMP4.data()->readAllStandardError().isEmpty()) {
|
||||||
|
emit createWallpaperStateChanged(Create::State::ConvertingPreviewVideoError);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
// qDebug() << proConvertPreviewMP4.data()->program() << proConvertPreviewMP4.data()->arguments();
|
// qDebug() << proConvertPreviewMP4.data()->program() << proConvertPreviewMP4.data()->arguments();
|
||||||
// qDebug() << "Done converting video to preview" << proConvertPreviewMP4.data()->readAll() << "\n"
|
// qDebug() << "Done converting video to preview" << proConvertPreviewMP4.data()->readAll() << "\n"
|
||||||
// << proConvertPreviewMP4.data()->readAllStandardError();
|
// << proConvertPreviewMP4.data()->readAllStandardError();
|
||||||
|
this->processOutput(proConvertPreviewMP4.data()->readAll());
|
||||||
proConvertPreviewMP4.data()->close();
|
proConvertPreviewMP4.data()->close();
|
||||||
processOutputTimer.data()->stop();
|
processOutputTimer.data()->stop();
|
||||||
emit createWallpaperStateChanged(Create::State::ConvertingPreviewVideoFinished);
|
emit createWallpaperStateChanged(Create::State::ConvertingPreviewVideoFinished);
|
||||||
@ -226,9 +230,15 @@ bool Create::createWallpaperVideoPreview(CreateWallpaperData& createWallpaperDat
|
|||||||
#endif
|
#endif
|
||||||
proConvertGif.data()->start();
|
proConvertGif.data()->start();
|
||||||
proConvertGif.data()->waitForFinished(-1);
|
proConvertGif.data()->waitForFinished(-1);
|
||||||
|
if (!proConvertGif.data()->readAllStandardError().isEmpty()) {
|
||||||
|
emit createWallpaperStateChanged(Create::State::ConvertingPreviewGifError);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// qDebug() << proConvertGif.data()->program() << proConvertGif.data()->arguments();
|
// qDebug() << proConvertGif.data()->program() << proConvertGif.data()->arguments();
|
||||||
// qDebug() << "Done converting video to preview" << proConvertGif.data()->readAll() << "\n"
|
// qDebug() << "Done converting video to preview" << proConvertGif.data()->readAll() << "\n"
|
||||||
// << proConvertGif.data()->readAllStandardError();
|
// << proConvertGif.data()->readAllStandardError();
|
||||||
|
this->processOutput(proConvertPreviewMP4.data()->readAll());
|
||||||
proConvertGif.data()->close();
|
proConvertGif.data()->close();
|
||||||
emit createWallpaperStateChanged(Create::State::ConvertingPreviewGifFinished);
|
emit createWallpaperStateChanged(Create::State::ConvertingPreviewGifFinished);
|
||||||
|
|
||||||
|
@ -45,17 +45,14 @@ public:
|
|||||||
Started,
|
Started,
|
||||||
ConvertingPreviewImage,
|
ConvertingPreviewImage,
|
||||||
ConvertingPreviewImageFinished,
|
ConvertingPreviewImageFinished,
|
||||||
|
ConvertingPreviewImageError,
|
||||||
ConvertingPreviewVideo,
|
ConvertingPreviewVideo,
|
||||||
ConvertingPreviewVideoFinished,
|
ConvertingPreviewVideoFinished,
|
||||||
|
ConvertingPreviewVideoError,
|
||||||
ConvertingPreviewGif,
|
ConvertingPreviewGif,
|
||||||
ConvertingPreviewGifFinished,
|
ConvertingPreviewGifFinished,
|
||||||
|
ConvertingPreviewGifError,
|
||||||
Finished,
|
Finished,
|
||||||
ErrorFolder,
|
|
||||||
ErrorFolderCreation,
|
|
||||||
ErrorDiskSpace,
|
|
||||||
ErrorCopyVideo,
|
|
||||||
ErrorCopyImage,
|
|
||||||
ErrorCopyConfig,
|
|
||||||
ErrorUnknown,
|
ErrorUnknown,
|
||||||
};
|
};
|
||||||
Q_ENUM(State)
|
Q_ENUM(State)
|
||||||
@ -69,8 +66,6 @@ public:
|
|||||||
signals:
|
signals:
|
||||||
void createWallpaperStateChanged(Create::State state);
|
void createWallpaperStateChanged(Create::State state);
|
||||||
void processOutput(QString text);
|
void processOutput(QString text);
|
||||||
|
|
||||||
|
|
||||||
void workingDirChanged(QString workingDir);
|
void workingDirChanged(QString workingDir);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
Loading…
Reference in New Issue
Block a user