mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-09-15 06:52:34 +02:00
Add ImageSelector
Add project config creation Add more enum states Remove no longer used functions
This commit is contained in:
parent
5f491212de
commit
5c04b3074f
@ -127,7 +127,7 @@ Item {
|
|||||||
Material.foreground: "white"
|
Material.foreground: "white"
|
||||||
anchors {
|
anchors {
|
||||||
right: parent.right
|
right: parent.right
|
||||||
rightMargin: 20
|
rightMargin: 10
|
||||||
verticalCenter: parent.verticalCenter
|
verticalCenter: parent.verticalCenter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ Item {
|
|||||||
|
|
||||||
property bool conversionFinishedSuccessful: false
|
property bool conversionFinishedSuccessful: false
|
||||||
property bool canSave: false
|
property bool canSave: false
|
||||||
|
property string filePath
|
||||||
onCanSaveChanged: wrapperContent.checkCanSave()
|
onCanSaveChanged: wrapperContent.checkCanSave()
|
||||||
signal save
|
signal save
|
||||||
|
|
||||||
@ -145,9 +146,9 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RowLayout {
|
ImageSelector {
|
||||||
id: row
|
id: previewSelector
|
||||||
height: 50
|
|
||||||
anchors {
|
anchors {
|
||||||
top: imgWrapper.bottom
|
top: imgWrapper.bottom
|
||||||
topMargin: 20
|
topMargin: 20
|
||||||
@ -155,46 +156,6 @@ Item {
|
|||||||
rightMargin: 30
|
rightMargin: 30
|
||||||
left: parent.left
|
left: parent.left
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
height: 50
|
|
||||||
color: "#eeeeee"
|
|
||||||
Layout.preferredWidth: imgWrapper.width
|
|
||||||
|
|
||||||
Text {
|
|
||||||
id: txtCustomPreviewPath
|
|
||||||
color: "#333333"
|
|
||||||
|
|
||||||
text: qsTr("Add custom preview image")
|
|
||||||
anchors {
|
|
||||||
verticalCenter: parent.verticalCenter
|
|
||||||
left: parent.left
|
|
||||||
leftMargin: 20
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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: []
|
|
||||||
onAccepted: {
|
|
||||||
var file = fileDialogOpenFile.file.toString()
|
|
||||||
|
|
||||||
txtCustomPreviewPath.text = fileDialogOpenFile.file
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Item {
|
Item {
|
||||||
@ -290,6 +251,8 @@ Item {
|
|||||||
screenPlayCreate.saveWallpaper(
|
screenPlayCreate.saveWallpaper(
|
||||||
textFieldName.text,
|
textFieldName.text,
|
||||||
textFieldDescription.text,
|
textFieldDescription.text,
|
||||||
|
wrapperContent.filePath,
|
||||||
|
previewSelector.imageSource,
|
||||||
textFieldYoutubeURL.text,
|
textFieldYoutubeURL.text,
|
||||||
textFieldTags.getTags())
|
textFieldTags.getTags())
|
||||||
savePopup.open()
|
savePopup.open()
|
||||||
@ -329,8 +292,10 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*##^## Designer {
|
/*##^## Designer {
|
||||||
D{i:0;autoSize:true;height:480;width:950}
|
D{i:0;autoSize:true;height:480;width:950}
|
||||||
}
|
}
|
||||||
##^##*/
|
##^##*/
|
||||||
|
|
||||||
|
@ -18,8 +18,12 @@ 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.setSource(
|
||||||
|
"qrc:/qml/Create/Wizards/CreateWallpaper/CreateWallpaperVideoImportConvert.qml",
|
||||||
|
{
|
||||||
|
"filePath": createNew.filePath
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
//Blocks some MouseArea from create page
|
//Blocks some MouseArea from create page
|
||||||
@ -30,13 +34,14 @@ Item {
|
|||||||
Connections {
|
Connections {
|
||||||
target: screenPlayCreate
|
target: screenPlayCreate
|
||||||
onCreateWallpaperStateChanged: {
|
onCreateWallpaperStateChanged: {
|
||||||
if (state === CreateImportVideo.State.AnalyseVideoError
|
if (state === CreateImportVideo.State.AnalyseVideoError || state
|
||||||
|| state === CreateImportVideo.State.ConvertingPreviewVideoError
|
=== CreateImportVideo.State.ConvertingPreviewGifError || state
|
||||||
|| state === CreateImportVideo.State.ConvertingPreviewGifError
|
=== CreateImportVideo.State.ConvertingPreviewImageError || state
|
||||||
|| state === CreateImportVideo.State.ConvertingPreviewImageError
|
=== CreateImportVideo.State.ConvertingAudioError || state
|
||||||
|| state === CreateImportVideo.State.ConvertingAudioError
|
=== CreateImportVideo.State.AbortCleanupError || state
|
||||||
|| state === CreateImportVideo.State.AbortCleanupError
|
=== CreateImportVideo.State.CopyFilesError || state
|
||||||
|| state === CreateImportVideo.State.ErrorUnknown) {
|
=== CreateImportVideo.State.CreateProjectFileError || state
|
||||||
|
=== CreateImportVideo.State.CreateTmpFolderError) {
|
||||||
createNew.state = "result"
|
createNew.state = "result"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -88,7 +93,7 @@ Item {
|
|||||||
z: 10
|
z: 10
|
||||||
Connections {
|
Connections {
|
||||||
target: loader_wrapperContent.sourceComponent
|
target: loader_wrapperContent.sourceComponent
|
||||||
onSave:{
|
onSave: {
|
||||||
createNew.state = "result"
|
createNew.state = "result"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,10 @@ import QtQuick 2.12
|
|||||||
import QtQuick.Controls 2.2
|
import QtQuick.Controls 2.2
|
||||||
import QtQuick.Controls.Material 2.2
|
import QtQuick.Controls.Material 2.2
|
||||||
|
|
||||||
|
import "../Common"
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: screen
|
id: screen
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,44 +12,6 @@ Create::Create(Settings* st, QMLUtilities* util, QObject* parent)
|
|||||||
qmlRegisterType<CreateImportVideo>("net.aimber.create", 1, 0, "CreateImportVideo");
|
qmlRegisterType<CreateImportVideo>("net.aimber.create", 1, 0, "CreateImportVideo");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Create::copyProject(QString relativeProjectPath, QString toPath)
|
|
||||||
{
|
|
||||||
if (toPath.contains("file:///")) {
|
|
||||||
toPath.remove("file:///");
|
|
||||||
}
|
|
||||||
QString srcFilePath = m_settings->getScreenPlayBasePath().toString() + relativeProjectPath;
|
|
||||||
|
|
||||||
// Todo: UI Error handling
|
|
||||||
if (copyRecursively(srcFilePath, toPath)) {
|
|
||||||
emit m_utils->openFolderInExplorer(toPath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Create::copyRecursively(const QString& srcFilePath, const QString& tgtFilePath)
|
|
||||||
{
|
|
||||||
QFileInfo srcFileInfo(srcFilePath);
|
|
||||||
if (srcFileInfo.isDir()) {
|
|
||||||
QDir targetDir(tgtFilePath);
|
|
||||||
targetDir.cdUp();
|
|
||||||
QDir sourceDir(srcFilePath);
|
|
||||||
QStringList fileNames = sourceDir.entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot | QDir::Hidden | QDir::System);
|
|
||||||
Q_FOREACH (const QString& fileName, fileNames) {
|
|
||||||
const QString newSrcFilePath
|
|
||||||
= srcFilePath + QLatin1Char('/') + fileName;
|
|
||||||
const QString newTgtFilePath
|
|
||||||
= tgtFilePath + QLatin1Char('/') + fileName;
|
|
||||||
if (!copyRecursively(newSrcFilePath, newTgtFilePath)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!QFile::copy(srcFilePath, tgtFilePath)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Create::createWallpaperStart(QString videoPath)
|
void Create::createWallpaperStart(QString videoPath)
|
||||||
{
|
{
|
||||||
videoPath.remove("file:///");
|
videoPath.remove("file:///");
|
||||||
@ -67,11 +29,12 @@ void Create::createWallpaperStart(QString videoPath)
|
|||||||
}
|
}
|
||||||
setWorkingDir(dir.path() + "/" + folderName);
|
setWorkingDir(dir.path() + "/" + folderName);
|
||||||
|
|
||||||
m_createImportVideoThread = new QThread;
|
m_createImportVideoThread = new QThread();
|
||||||
m_createImportVideo = new CreateImportVideo(videoPath, workingDir());
|
m_createImportVideo = new CreateImportVideo(videoPath, workingDir());
|
||||||
|
|
||||||
connect(m_createImportVideo, &CreateImportVideo::createWallpaperStateChanged, this, &Create::createWallpaperStateChanged);
|
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::canceled, this, &Create::abortAndCleanup);
|
||||||
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);
|
||||||
@ -80,18 +43,38 @@ void Create::createWallpaperStart(QString videoPath)
|
|||||||
m_createImportVideoThread->start();
|
m_createImportVideoThread->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Create::saveWallpaper(QString title, QString description, QString youtube, QVector<QString> tags)
|
void Create::saveWallpaper(QString title, QString description, QString filePath, QString previewImagePath, QString youtube, QVector<QString> tags)
|
||||||
{
|
{
|
||||||
qDebug() << tags;
|
filePath.remove("file:///");
|
||||||
|
previewImagePath.remove("file:///");
|
||||||
|
|
||||||
|
emit createWallpaperStateChanged(CreateImportVideo::State::CopyFiles);
|
||||||
|
|
||||||
|
QFileInfo previewImageFile(previewImagePath);
|
||||||
|
if (!QFile::copy(previewImagePath, m_workingDir + "/" + previewImageFile.fileName())) {
|
||||||
|
qDebug() << "Could not copy" << previewImagePath << " to " << m_workingDir + "/" + previewImageFile.fileName();
|
||||||
|
emit createWallpaperStateChanged(CreateImportVideo::State::CopyFilesError);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QFileInfo filePathFile(filePath);
|
||||||
|
if (!QFile::copy(filePath, m_workingDir + "/" + filePathFile.fileName())) {
|
||||||
|
qDebug() << "Could not copy" << filePath << " to " << m_workingDir + "/" + filePathFile.fileName();
|
||||||
|
emit createWallpaperStateChanged(CreateImportVideo::State::CopyFilesError);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
emit createWallpaperStateChanged(CreateImportVideo::State::CopyFilesFinished);
|
||||||
|
emit createWallpaperStateChanged(CreateImportVideo::State::CreateProjectFile);
|
||||||
QFile file(m_workingDir + "/project.json");
|
QFile file(m_workingDir + "/project.json");
|
||||||
|
|
||||||
QJsonObject obj;
|
QJsonObject obj;
|
||||||
obj.insert("description", description);
|
obj.insert("description", description);
|
||||||
obj.insert("title", title);
|
obj.insert("title", title);
|
||||||
|
obj.insert("youtube", youtube);
|
||||||
obj.insert("file", "video.webm");
|
obj.insert("file", "video.webm");
|
||||||
obj.insert("previewGIF", "preview.gif");
|
obj.insert("previewGIF", "preview.gif");
|
||||||
obj.insert("previewWEBM", "preview.webm");
|
obj.insert("previewWEBM", filePathFile.fileName());
|
||||||
|
obj.insert("preview", previewImageFile.fileName());
|
||||||
obj.insert("type", "video");
|
obj.insert("type", "video");
|
||||||
|
|
||||||
QJsonArray arr;
|
QJsonArray arr;
|
||||||
@ -102,6 +85,7 @@ void Create::saveWallpaper(QString title, QString description, QString youtube,
|
|||||||
|
|
||||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||||
qDebug() << "Could not open /project.json";
|
qDebug() << "Could not open /project.json";
|
||||||
|
emit createWallpaperStateChanged(CreateImportVideo::State::CreateProjectFileError);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,6 +95,7 @@ void Create::saveWallpaper(QString title, QString description, QString youtube,
|
|||||||
out << doc.toJson();
|
out << doc.toJson();
|
||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
|
emit createWallpaperStateChanged(CreateImportVideo::State::CreateProjectFileFinished);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Create::abortAndCleanup()
|
void Create::abortAndCleanup()
|
||||||
@ -120,6 +105,9 @@ void Create::abortAndCleanup()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
disconnect(m_createImportVideo);
|
||||||
|
disconnect(m_createImportVideoThread);
|
||||||
|
|
||||||
// Save to export path before aborting to be able to cleanup the tmp folder
|
// Save to export path before aborting to be able to cleanup the tmp folder
|
||||||
QString tmpExportPath = m_createImportVideo->m_exportPath;
|
QString tmpExportPath = m_createImportVideo->m_exportPath;
|
||||||
|
|
||||||
|
@ -55,10 +55,8 @@ signals:
|
|||||||
void workingDirChanged(QString workingDir);
|
void workingDirChanged(QString workingDir);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void copyProject(QString relativeProjectPath, QString toPath);
|
|
||||||
bool copyRecursively(const QString& srcFilePath, const QString& tgtFilePath);
|
|
||||||
void createWallpaperStart(QString videoPath);
|
void createWallpaperStart(QString videoPath);
|
||||||
void saveWallpaper(QString title, QString description, QString youtube, QVector<QString> tags);
|
void saveWallpaper(QString title, QString description, QString filePath, QString previewImagePath, QString youtube, QVector<QString> tags);
|
||||||
void abortAndCleanup();
|
void abortAndCleanup();
|
||||||
|
|
||||||
void setProgress(float progress)
|
void setProgress(float progress)
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include "createimportvideo.h"
|
#include "createimportvideo.h"
|
||||||
|
#include <QScopeGuard>
|
||||||
|
|
||||||
CreateImportVideo::CreateImportVideo(QObject* parent)
|
CreateImportVideo::CreateImportVideo(QObject* parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
@ -15,13 +16,26 @@ CreateImportVideo::CreateImportVideo(QString videoPath, QString exportPath, QObj
|
|||||||
void CreateImportVideo::process()
|
void CreateImportVideo::process()
|
||||||
{
|
{
|
||||||
qDebug() << "start converting video in thread: " << QThread::currentThreadId();
|
qDebug() << "start converting video in thread: " << QThread::currentThreadId();
|
||||||
createWallpaperInfo();
|
|
||||||
createWallpaperVideoPreview();
|
|
||||||
createWallpaperGifPreview();
|
|
||||||
extractWallpaperAudio();
|
|
||||||
emit createWallpaperStateChanged(CreateImportVideo::State::Finished);
|
|
||||||
|
|
||||||
emit finished();
|
auto cleanup = qScopeGuard([this] {
|
||||||
|
qDebug() << "ABORT";
|
||||||
|
this->requestInterruption();
|
||||||
|
emit canceled();
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!createWallpaperInfo())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!createWallpaperVideoPreview())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!createWallpaperGifPreview())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!extractWallpaperAudio())
|
||||||
|
return;
|
||||||
|
|
||||||
|
emit createWallpaperStateChanged(CreateImportVideo::State::Finished);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CreateImportVideo::createWallpaperInfo()
|
bool CreateImportVideo::createWallpaperInfo()
|
||||||
@ -345,32 +359,4 @@ bool CreateImportVideo::extractWallpaperAudio()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CreateImportVideo::createWallpaperProjectFile(const QString title, const QString description)
|
|
||||||
{
|
|
||||||
//Copy Project File
|
|
||||||
QFile configFile(m_exportPath + "/project.json");
|
|
||||||
|
|
||||||
if (!configFile.open(QIODevice::ReadWrite | QIODevice::Text)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
QTextStream out(&configFile);
|
|
||||||
QJsonObject configObj;
|
|
||||||
|
|
||||||
configObj.insert("description", description);
|
|
||||||
configObj.insert("title", title);
|
|
||||||
|
|
||||||
configObj.insert("file", "video.webm");
|
|
||||||
configObj.insert("preview", "preview.png");
|
|
||||||
configObj.insert("previewGIF", "preview.gif");
|
|
||||||
configObj.insert("previewWebM", "preview.webm");
|
|
||||||
configObj.insert("type", "video");
|
|
||||||
|
|
||||||
QJsonDocument configJsonDocument(configObj);
|
|
||||||
out << configJsonDocument.toJson();
|
|
||||||
configFile.close();
|
|
||||||
|
|
||||||
emit createWallpaperStateChanged(CreateImportVideo::State::Finished);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
@ -44,14 +44,18 @@ public:
|
|||||||
// ConvertingVideo,
|
// ConvertingVideo,
|
||||||
// ConvertingVideoFinished,
|
// ConvertingVideoFinished,
|
||||||
// ConvertingVideoError,
|
// ConvertingVideoError,
|
||||||
|
CopyFiles,
|
||||||
|
CopyFilesFinished,
|
||||||
|
CopyFilesError,
|
||||||
|
CreateProjectFile,
|
||||||
|
CreateProjectFileFinished,
|
||||||
|
CreateProjectFileError,
|
||||||
AbortCleanupError,
|
AbortCleanupError,
|
||||||
CreateTmpFolderError,
|
CreateTmpFolderError,
|
||||||
Finished,
|
Finished,
|
||||||
ErrorUnknown,
|
|
||||||
};
|
};
|
||||||
Q_ENUM(State)
|
Q_ENUM(State)
|
||||||
|
|
||||||
QProcess m_process;
|
|
||||||
QString m_videoPath;
|
QString m_videoPath;
|
||||||
QString m_exportPath;
|
QString m_exportPath;
|
||||||
int m_length = 0;
|
int m_length = 0;
|
||||||
@ -61,17 +65,15 @@ signals:
|
|||||||
void createWallpaperStateChanged(CreateImportVideo::State state);
|
void createWallpaperStateChanged(CreateImportVideo::State state);
|
||||||
void processOutput(QString text);
|
void processOutput(QString text);
|
||||||
void finished();
|
void finished();
|
||||||
|
void canceled();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void process();
|
void process();
|
||||||
void requestInterruption()
|
void requestInterruption() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool createWallpaperInfo();
|
bool createWallpaperInfo();
|
||||||
bool createWallpaperVideoPreview();
|
bool createWallpaperVideoPreview();
|
||||||
bool createWallpaperGifPreview();
|
bool createWallpaperGifPreview();
|
||||||
bool createWallpaperImagePreview();
|
bool createWallpaperImagePreview();
|
||||||
bool extractWallpaperAudio();
|
bool extractWallpaperAudio();
|
||||||
bool createWallpaperProjectFile(const QString title, const QString description);
|
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user