mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-07 03:22:33 +01:00
Refactor wizards into separate class
This commit is contained in:
parent
bbb827ed66
commit
7302b2eba5
@ -41,7 +41,8 @@ set(src
|
|||||||
src/screenplaymanager.cpp
|
src/screenplaymanager.cpp
|
||||||
src/sdkconnection.cpp
|
src/sdkconnection.cpp
|
||||||
src/util.cpp
|
src/util.cpp
|
||||||
src/create.cpp)
|
src/create.cpp
|
||||||
|
src/wizards.cpp)
|
||||||
|
|
||||||
set(headers
|
set(headers
|
||||||
app.h
|
app.h
|
||||||
@ -61,7 +62,8 @@ set(headers
|
|||||||
src/screenplaymanager.h
|
src/screenplaymanager.h
|
||||||
src/sdkconnection.h
|
src/sdkconnection.h
|
||||||
src/util.h
|
src/util.h
|
||||||
src/create.h)
|
src/create.h
|
||||||
|
src/wizards.h)
|
||||||
|
|
||||||
set(l10n
|
set(l10n
|
||||||
translations/ScreenPlay_de.ts
|
translations/ScreenPlay_de.ts
|
||||||
|
@ -118,6 +118,7 @@ App::App()
|
|||||||
qmlRegisterAnonymousType<ScreenPlayManager>("ScreenPlay", 1);
|
qmlRegisterAnonymousType<ScreenPlayManager>("ScreenPlay", 1);
|
||||||
qmlRegisterAnonymousType<Util>("ScreenPlay", 1);
|
qmlRegisterAnonymousType<Util>("ScreenPlay", 1);
|
||||||
qmlRegisterAnonymousType<Create>("ScreenPlay", 1);
|
qmlRegisterAnonymousType<Create>("ScreenPlay", 1);
|
||||||
|
qmlRegisterAnonymousType<Wizards>("ScreenPlay", 1);
|
||||||
qmlRegisterAnonymousType<Settings>("ScreenPlay", 1);
|
qmlRegisterAnonymousType<Settings>("ScreenPlay", 1);
|
||||||
|
|
||||||
// ScreenPlayManager first to check if another ScreenPlay Instace is running
|
// ScreenPlayManager first to check if another ScreenPlay Instace is running
|
||||||
@ -150,6 +151,7 @@ void App::init()
|
|||||||
m_mainWindowEngine = make_unique<QQmlApplicationEngine>();
|
m_mainWindowEngine = make_unique<QQmlApplicationEngine>();
|
||||||
m_screenPlayManager->init(m_globalVariables, m_monitorListModel, m_telemetry, m_settings);
|
m_screenPlayManager->init(m_globalVariables, m_monitorListModel, m_telemetry, m_settings);
|
||||||
|
|
||||||
|
|
||||||
// Only create tracker if user did not disallow!
|
// Only create tracker if user did not disallow!
|
||||||
if (m_settings->anonymousTelemetry()) {
|
if (m_settings->anonymousTelemetry()) {
|
||||||
m_telemetry = make_shared<GAnalytics>("UA-152830367-3");
|
m_telemetry = make_shared<GAnalytics>("UA-152830367-3");
|
||||||
@ -173,6 +175,13 @@ void App::init()
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_create = make_unique<Create>(m_globalVariables);
|
m_create = make_unique<Create>(m_globalVariables);
|
||||||
|
m_threadPool.setMaxThreadCount(5);
|
||||||
|
m_threadPool.reserveThread();
|
||||||
|
m_wizards = make_unique<Wizards>(m_globalVariables);
|
||||||
|
m_wizards->moveToThread(m_threadPool.thread());
|
||||||
|
qInfo() << m_installedListModel->thread() << m_threadPool.thread();
|
||||||
|
m_installedListModel->moveToThread(m_threadPool.thread());
|
||||||
|
qInfo() << m_installedListModel->thread();
|
||||||
|
|
||||||
// When the installed storage path changed
|
// When the installed storage path changed
|
||||||
QObject::connect(m_settings.get(), &Settings::resetInstalledListmodel, m_installedListModel.get(), &InstalledListModel::reset);
|
QObject::connect(m_settings.get(), &Settings::resetInstalledListmodel, m_installedListModel.get(), &InstalledListModel::reset);
|
||||||
|
@ -11,151 +11,104 @@ import "../../Common" as Common
|
|||||||
|
|
||||||
WizardPage {
|
WizardPage {
|
||||||
id: root
|
id: root
|
||||||
sourceComponent: Item {
|
|
||||||
|
|
||||||
ColumnLayout {
|
sourceComponent: ColumnLayout {
|
||||||
id: rightWrapper
|
id: rightWrapper
|
||||||
spacing: 10
|
spacing: 10
|
||||||
anchors {
|
anchors {
|
||||||
top: parent.top
|
top: parent.top
|
||||||
right: parent.right
|
right: parent.right
|
||||||
left: parent.left
|
left: parent.left
|
||||||
}
|
}
|
||||||
|
|
||||||
Common.Headline {
|
function create() {
|
||||||
text: qsTr("Create a QML Wallpaper")
|
ScreenPlay.wizards.createQMLWallpaper(
|
||||||
}
|
tfTitle.text, previewSelector.imageSource,
|
||||||
|
cbLicense.currentText, tagSelector.getTags())
|
||||||
|
}
|
||||||
|
|
||||||
Common.HeadlineSection {
|
Common.Headline {
|
||||||
text: qsTr("General")
|
text: qsTr("Create a QML Wallpaper")
|
||||||
}
|
}
|
||||||
RowLayout {
|
|
||||||
spacing: 20
|
|
||||||
|
|
||||||
Common.TextField {
|
Common.HeadlineSection {
|
||||||
id: tfTitle
|
text: qsTr("General")
|
||||||
Layout.fillWidth: true
|
}
|
||||||
placeholderText: qsTr("Wallpaper name")
|
RowLayout {
|
||||||
onTextChanged: {
|
spacing: 20
|
||||||
if (text.length >= 3) {
|
|
||||||
btnSave.enabled = true
|
Common.TextField {
|
||||||
} else {
|
id: tfTitle
|
||||||
btnSave.enabled = false
|
Layout.fillWidth: true
|
||||||
}
|
placeholderText: qsTr("Wallpaper name")
|
||||||
}
|
onTextChanged: root.ready = text.length >= 1
|
||||||
}
|
|
||||||
Common.TextField {
|
|
||||||
id: tfCreatedBy
|
|
||||||
Layout.fillWidth: true
|
|
||||||
placeholderText: qsTr("Copyright owner")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Common.TextField {
|
Common.TextField {
|
||||||
id: tfDescription
|
id: tfCreatedBy
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
placeholderText: qsTr("Description")
|
placeholderText: qsTr("Copyright owner")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
Common.TextField {
|
||||||
|
id: tfDescription
|
||||||
|
Layout.fillWidth: true
|
||||||
|
placeholderText: qsTr("Description")
|
||||||
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
height: 30
|
height: 30
|
||||||
}
|
}
|
||||||
|
|
||||||
Common.HeadlineSection {
|
Common.HeadlineSection {
|
||||||
text: qsTr("License & Tags")
|
text: qsTr("License & Tags")
|
||||||
}
|
}
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
spacing: 20
|
spacing: 20
|
||||||
|
|
||||||
ComboBox {
|
ComboBox {
|
||||||
id: cbLicense
|
id: cbLicense
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
font.family: ScreenPlay.settings.font
|
font.family: ScreenPlay.settings.font
|
||||||
model: ListModel {
|
model: ListModel {
|
||||||
id: modelLicense
|
id: modelLicense
|
||||||
ListElement {
|
ListElement {
|
||||||
text: "Copyright by me"
|
text: "Copyright by me"
|
||||||
}
|
}
|
||||||
ListElement {
|
ListElement {
|
||||||
text: "Open Source - GPLv3"
|
text: "Open Source - GPLv3"
|
||||||
}
|
}
|
||||||
ListElement {
|
ListElement {
|
||||||
text: "Open Source - MIT/Apache2"
|
text: "Open Source - MIT/Apache2"
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Common.TagSelector {
|
|
||||||
id: tagSelector
|
|
||||||
Layout.fillWidth: true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
Common.TagSelector {
|
||||||
height: 30
|
id: tagSelector
|
||||||
}
|
|
||||||
|
|
||||||
Common.HeadlineSection {
|
|
||||||
text: qsTr("Preview Image")
|
|
||||||
}
|
|
||||||
|
|
||||||
Common.ImageSelector {
|
|
||||||
id: previewSelector
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
height: 30
|
height: 30
|
||||||
}
|
}
|
||||||
|
|
||||||
RowLayout {
|
Common.HeadlineSection {
|
||||||
spacing: 10
|
text: qsTr("Preview Image")
|
||||||
|
}
|
||||||
|
|
||||||
Connections {
|
Common.ImageSelector {
|
||||||
target: ScreenPlay.create
|
id: previewSelector
|
||||||
function onHtmlWallpaperCreatedSuccessful(path) {
|
Layout.fillWidth: true
|
||||||
ScreenPlay.util.openFolderInExplorer(path)
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
Item {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
}
|
|
||||||
|
|
||||||
Button {
|
Item {
|
||||||
id: btnExit
|
height: 30
|
||||||
text: qsTr("Abort")
|
|
||||||
Material.background: Material.Red
|
|
||||||
Material.foreground: "white"
|
|
||||||
Layout.alignment: Qt.AlignRight
|
|
||||||
font.family: ScreenPlay.settings.font
|
|
||||||
onClicked: {
|
|
||||||
root.decrementCurrentIndex()
|
|
||||||
root.wizardExited()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Button {
|
|
||||||
id: btnSave
|
|
||||||
text: qsTr("Save")
|
|
||||||
enabled: false
|
|
||||||
Material.background: Material.accent
|
|
||||||
Material.foreground: "white"
|
|
||||||
Layout.alignment: Qt.AlignRight
|
|
||||||
font.family: ScreenPlay.settings.font
|
|
||||||
onClicked: {
|
|
||||||
btnSave.enabled = false
|
|
||||||
savePopup.open()
|
|
||||||
var tags = tagSelector.getTags()
|
|
||||||
ScreenPlay.create.createQMLWallpaper(
|
|
||||||
ScreenPlay.globalVariables.localStoragePath,
|
|
||||||
tfTitle.text, previewSelector.imageSource,
|
|
||||||
cbLicense.currentText, tags)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*##^##
|
/*##^##
|
||||||
Designer {
|
Designer {
|
||||||
D{i:0;autoSize:true;height:480;width:640}
|
D{i:0;autoSize:true;height:480;width:640}
|
||||||
|
@ -84,7 +84,7 @@ WizardPage {
|
|||||||
Common.TextField {
|
Common.TextField {
|
||||||
id: tfCreatedBy
|
id: tfCreatedBy
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
placeholderText: qsTr("Copyright owner")
|
placeholderText: qsTr("Created by")
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
import QtQuick 2.12
|
import QtQuick 2.12
|
||||||
import QtGraphicalEffects 1.0
|
import QtGraphicalEffects 1.0
|
||||||
import QtQuick.Controls 2.2
|
import QtQuick.Controls 2.15
|
||||||
import QtQuick.Controls.Material 2.3
|
import QtQuick.Controls.Material 2.3
|
||||||
import QtQuick.Layouts 1.12
|
import QtQuick.Layouts 1.12
|
||||||
|
import QtQuick.Window 2.12
|
||||||
|
|
||||||
import ScreenPlay 1.0
|
import ScreenPlay 1.0
|
||||||
import ScreenPlay.Create 1.0
|
import ScreenPlay.Create 1.0
|
||||||
@ -12,17 +13,21 @@ FocusScope {
|
|||||||
|
|
||||||
signal wizardStarted
|
signal wizardStarted
|
||||||
signal wizardExited
|
signal wizardExited
|
||||||
|
signal saveClicked
|
||||||
|
signal saveFinished
|
||||||
|
signal cancelClicked
|
||||||
|
|
||||||
property Component sourceComponent
|
property Component sourceComponent
|
||||||
property alias savePopup: savePopup
|
property alias savePopup: savePopup
|
||||||
|
property bool ready: false
|
||||||
|
|
||||||
ScrollView {
|
ScrollView {
|
||||||
anchors {
|
anchors {
|
||||||
topMargin: 20
|
margins: 20
|
||||||
top:parent.top
|
top: parent.top
|
||||||
right:parent.right
|
right: parent.right
|
||||||
bottom: parent.bottom
|
bottom: footer.top
|
||||||
left:parent.left
|
left: parent.left
|
||||||
}
|
}
|
||||||
|
|
||||||
contentWidth: width
|
contentWidth: width
|
||||||
@ -30,8 +35,8 @@ FocusScope {
|
|||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
id: loader
|
id: loader
|
||||||
width: Math.min(parent.width, 800)
|
width: parent.width
|
||||||
height: item.childrenRect.height
|
Component.onCompleted: height = item.childrenRect.height
|
||||||
clip: true
|
clip: true
|
||||||
sourceComponent: root.sourceComponent
|
sourceComponent: root.sourceComponent
|
||||||
anchors {
|
anchors {
|
||||||
@ -41,13 +46,43 @@ FocusScope {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
id: footer
|
||||||
|
anchors {
|
||||||
|
right: parent.right
|
||||||
|
bottom: parent.bottom
|
||||||
|
left: parent.left
|
||||||
|
margins: 20
|
||||||
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
|
|
||||||
|
Button {
|
||||||
|
id: btnSave
|
||||||
|
text: qsTr("Save")
|
||||||
|
enabled: root.ready
|
||||||
|
Material.background: Material.accent
|
||||||
|
Material.foreground: "white"
|
||||||
|
Layout.alignment: Qt.AlignRight
|
||||||
|
font.family: ScreenPlay.settings.font
|
||||||
|
onClicked: {
|
||||||
|
btnSave.enabled = false
|
||||||
|
root.saveClicked()
|
||||||
|
loader.item.create()
|
||||||
|
savePopup.open()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Popup {
|
Popup {
|
||||||
id: savePopup
|
id: savePopup
|
||||||
modal: true
|
modal: true
|
||||||
focus: true
|
focus: true
|
||||||
width: 250
|
width: 250
|
||||||
height: 200
|
height: 200
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: Overlay.overlay
|
||||||
onOpened: timerSave.start()
|
onOpened: timerSave.start()
|
||||||
|
|
||||||
BusyIndicator {
|
BusyIndicator {
|
||||||
@ -57,6 +92,7 @@ FocusScope {
|
|||||||
|
|
||||||
Text {
|
Text {
|
||||||
text: qsTr("Saving...")
|
text: qsTr("Saving...")
|
||||||
|
color: Material.primaryHighlightedTextColor
|
||||||
font.family: ScreenPlay.settings.font
|
font.family: ScreenPlay.settings.font
|
||||||
anchors {
|
anchors {
|
||||||
horizontalCenter: parent.horizontalCenter
|
horizontalCenter: parent.horizontalCenter
|
||||||
|
@ -42,171 +42,6 @@ Create::Create()
|
|||||||
qmlRegisterType<Create>("ScreenPlay.Create", 1, 0, "Create");
|
qmlRegisterType<Create>("ScreenPlay.Create", 1, 0, "Create");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Creates a new widget.
|
|
||||||
*/
|
|
||||||
void Create::createWidget(const QString& localStoragePath, const QString& title, const QString& previewThumbnail, const QString& createdBy, const QString& license, const QString& type, const QVector<QString>& tags)
|
|
||||||
{
|
|
||||||
QtConcurrent::run([=]() {
|
|
||||||
QUrl localStoragePathUrl { localStoragePath };
|
|
||||||
QDir dir;
|
|
||||||
dir.cd(localStoragePathUrl.toLocalFile());
|
|
||||||
// Create a temp dir so we can later alter it to the workshop id
|
|
||||||
auto folderName = QString("_tmp_" + QTime::currentTime().toString()).replace(":", "");
|
|
||||||
QString workingPath = dir.path() + "/" + folderName;
|
|
||||||
|
|
||||||
if (!dir.mkdir(folderName)) {
|
|
||||||
qDebug() << "Could create folder: " << folderName;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QJsonObject obj;
|
|
||||||
obj.insert("license", license);
|
|
||||||
obj.insert("title", title);
|
|
||||||
obj.insert("createdBy", createdBy);
|
|
||||||
|
|
||||||
if (type == "QML") {
|
|
||||||
obj.insert("type", "qmlWidget");
|
|
||||||
obj.insert("file", "main.qml");
|
|
||||||
|
|
||||||
QFile fileMainQML(workingPath + "/main.qml");
|
|
||||||
if (!fileMainQML.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
|
||||||
qDebug() << "Could not open /main.qml";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QTextStream outMainQML(&fileMainQML);
|
|
||||||
outMainQML.setCodec("UTF-8");
|
|
||||||
outMainQML << "import QtQuick 2.14 \n\n Item {\n id:root \n}";
|
|
||||||
fileMainQML.close();
|
|
||||||
|
|
||||||
} else {
|
|
||||||
obj.insert("type", "htmlWidget");
|
|
||||||
obj.insert("file", "index.html");
|
|
||||||
|
|
||||||
QFile fileMainHTML(workingPath + "/index.html");
|
|
||||||
if (!fileMainHTML.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
|
||||||
qDebug() << "Could not open /index.html";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QTextStream outMainHTML(&fileMainHTML);
|
|
||||||
outMainHTML.setCodec("UTF-8");
|
|
||||||
outMainHTML << "<html>\n<head></head>\n<body></body>\n</html>";
|
|
||||||
fileMainHTML.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
QJsonArray tagsJsonArray;
|
|
||||||
for (const QString& tmp : tags) {
|
|
||||||
tagsJsonArray.append(tmp);
|
|
||||||
}
|
|
||||||
obj.insert("tags", tagsJsonArray);
|
|
||||||
|
|
||||||
QFile file(workingPath + "/project.json");
|
|
||||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
|
||||||
qDebug() << "Could not open /project.json";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QUrl previewThumbnailUrl { previewThumbnail };
|
|
||||||
QFileInfo previewImageFile(previewThumbnailUrl.toLocalFile());
|
|
||||||
|
|
||||||
if (!previewThumbnail.isEmpty()) {
|
|
||||||
obj.insert("previewThumbnail", previewImageFile.fileName());
|
|
||||||
obj.insert("preview", previewImageFile.fileName());
|
|
||||||
if (!QFile::copy(previewThumbnailUrl.toLocalFile(), workingPath + "/" + previewImageFile.fileName())) {
|
|
||||||
qDebug() << "Could not copy" << previewThumbnailUrl.toLocalFile() << " to " << workingPath + "/" + previewImageFile.fileName();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QTextStream out(&file);
|
|
||||||
out.setCodec("UTF-8");
|
|
||||||
QJsonDocument doc(obj);
|
|
||||||
out << doc.toJson();
|
|
||||||
file.close();
|
|
||||||
|
|
||||||
emit widgetCreatedSuccessful(workingPath);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Creates a HTML wallpaper.
|
|
||||||
*/
|
|
||||||
void Create::createHTMLWallpaper(
|
|
||||||
const QString& localStoragePath,
|
|
||||||
const QString& title,
|
|
||||||
const QString& previewThumbnail,
|
|
||||||
const QString& license,
|
|
||||||
const QVector<QString>& tags)
|
|
||||||
{
|
|
||||||
QtConcurrent::run([=]() {
|
|
||||||
QUrl localStoragePathUrl { localStoragePath };
|
|
||||||
QDir dir;
|
|
||||||
dir.cd(localStoragePathUrl.toLocalFile());
|
|
||||||
// Create a temp dir so we can later alter it to the workshop id
|
|
||||||
auto folderName = QString("_tmp_" + QTime::currentTime().toString()).replace(":", "");
|
|
||||||
QString workingPath = dir.path() + "/" + folderName;
|
|
||||||
|
|
||||||
if (!dir.mkdir(folderName)) {
|
|
||||||
qDebug() << "Could create folder: " << folderName;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QJsonObject obj;
|
|
||||||
obj.insert("license", license);
|
|
||||||
obj.insert("title", title);
|
|
||||||
|
|
||||||
obj.insert("type", "htmlWallpaper");
|
|
||||||
obj.insert("file", "index.html");
|
|
||||||
|
|
||||||
QFile fileMainHTML(workingPath + "/index.html");
|
|
||||||
if (!fileMainHTML.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
|
||||||
qDebug() << "Could not open /index.html";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QTextStream outMainHTML(&fileMainHTML);
|
|
||||||
outMainHTML.setCodec("UTF-8");
|
|
||||||
outMainHTML << "<html>\n<head></head>\n"
|
|
||||||
"<h1>This is an empty html Wallpaper!</h1>"
|
|
||||||
"<body></body>\n</html>";
|
|
||||||
fileMainHTML.close();
|
|
||||||
|
|
||||||
QJsonArray tagsJsonArray;
|
|
||||||
for (const QString& tmp : tags) {
|
|
||||||
tagsJsonArray.append(tmp);
|
|
||||||
}
|
|
||||||
obj.insert("tags", tagsJsonArray);
|
|
||||||
|
|
||||||
QFile file(workingPath + "/project.json");
|
|
||||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
|
||||||
qDebug() << "Could not open /project.json";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QUrl previewThumbnailUrl { previewThumbnail };
|
|
||||||
QFileInfo previewImageFile(previewThumbnailUrl.toLocalFile());
|
|
||||||
|
|
||||||
if (!previewThumbnail.isEmpty()) {
|
|
||||||
obj.insert("previewThumbnail", previewImageFile.fileName());
|
|
||||||
obj.insert("preview", previewImageFile.fileName());
|
|
||||||
if (!QFile::copy(previewThumbnailUrl.toLocalFile(), workingPath + "/" + previewImageFile.fileName())) {
|
|
||||||
qDebug() << "Could not copy" << previewThumbnailUrl.toLocalFile() << " to " << workingPath + "/" + previewImageFile.fileName();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QTextStream out(&file);
|
|
||||||
out.setCodec("UTF-8");
|
|
||||||
QJsonDocument doc(obj);
|
|
||||||
out << doc.toJson();
|
|
||||||
file.close();
|
|
||||||
|
|
||||||
emit widgetCreatedSuccessful(workingPath);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Starts the process.
|
\brief Starts the process.
|
||||||
*/
|
*/
|
||||||
@ -228,11 +63,7 @@ void Create::createWallpaperStart(QString videoPath, Create::VideoCodec codec)
|
|||||||
}
|
}
|
||||||
setWorkingDir(dir.path() + "/" + folderName);
|
setWorkingDir(dir.path() + "/" + folderName);
|
||||||
QStringList codecs;
|
QStringList codecs;
|
||||||
if (codec == Create::VideoCodec::VP8) {
|
codecs.append(codec == Create::VideoCodec::VP8 ? "vp8" : "vp9");
|
||||||
codecs.append("vp8");
|
|
||||||
} else {
|
|
||||||
codecs.append("vp9");
|
|
||||||
}
|
|
||||||
|
|
||||||
m_createImportVideoThread = new QThread(this);
|
m_createImportVideoThread = new QThread(this);
|
||||||
m_createImportVideo = new CreateImportVideo(videoPath, workingDir(), codecs);
|
m_createImportVideo = new CreateImportVideo(videoPath, workingDir(), codecs);
|
||||||
@ -293,17 +124,19 @@ void Create::saveWallpaper(QString title, QString description, QString filePath,
|
|||||||
}
|
}
|
||||||
emit createWallpaperStateChanged(CreateImportVideo::ImportVideoState::CopyFilesFinished);
|
emit createWallpaperStateChanged(CreateImportVideo::ImportVideoState::CopyFilesFinished);
|
||||||
emit createWallpaperStateChanged(CreateImportVideo::ImportVideoState::CreateProjectFile);
|
emit createWallpaperStateChanged(CreateImportVideo::ImportVideoState::CreateProjectFile);
|
||||||
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("youtube", youtube);
|
||||||
if (codec == Create::VideoCodec::VP8) {
|
obj.insert("videoCodec", codec == Create::VideoCodec::VP8 ? "vp8" : "vp9");
|
||||||
obj.insert("videoCodec", "vp8");
|
obj.insert("file", filePathFile.baseName() + ".webm");
|
||||||
} else {
|
obj.insert("previewGIF", "preview.gif");
|
||||||
obj.insert("videoCodec", "vp9");
|
obj.insert("previewWEBM", "preview.webm");
|
||||||
}
|
obj.insert("preview", previewImageFile.exists() ? previewImageFile.fileName() : "preview.jpg");
|
||||||
|
obj.insert("previewThumbnail", "previewThumbnail.jpg");
|
||||||
|
obj.insert("type", "videoWallpaper");
|
||||||
|
obj.insert("tags", Util::fillArray(tags));
|
||||||
|
|
||||||
QFile audioFile { m_workingDir + "/audio.mp3" };
|
QFile audioFile { m_workingDir + "/audio.mp3" };
|
||||||
if (audioFile.exists() && audioFile.size() > 0) {
|
if (audioFile.exists() && audioFile.size() > 0) {
|
||||||
@ -311,43 +144,14 @@ void Create::saveWallpaper(QString title, QString description, QString filePath,
|
|||||||
obj.insert("audioCodec", "mp3");
|
obj.insert("audioCodec", "mp3");
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the input file is a webm we don't need to convert it
|
if (!Util::writeSettings(std::move(obj), m_workingDir + "/project.json")) {
|
||||||
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()) {
|
|
||||||
obj.insert("preview", previewImageFile.fileName());
|
|
||||||
} else {
|
|
||||||
obj.insert("preview", "preview.jpg");
|
|
||||||
}
|
|
||||||
obj.insert("previewThumbnail", "previewThumbnail.jpg");
|
|
||||||
obj.insert("type", "videoWallpaper");
|
|
||||||
|
|
||||||
QJsonArray tagsJsonArray;
|
|
||||||
for (const QString& tmp : tags) {
|
|
||||||
tagsJsonArray.append(tmp);
|
|
||||||
}
|
|
||||||
obj.insert("tags", tagsJsonArray);
|
|
||||||
|
|
||||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
|
||||||
qDebug() << "Could not open /project.json";
|
|
||||||
emit createWallpaperStateChanged(CreateImportVideo::ImportVideoState::CreateProjectFileError);
|
emit createWallpaperStateChanged(CreateImportVideo::ImportVideoState::CreateProjectFileError);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QTextStream out(&file);
|
|
||||||
out.setCodec("UTF-8");
|
|
||||||
QJsonDocument doc(obj);
|
|
||||||
|
|
||||||
out << doc.toJson();
|
|
||||||
|
|
||||||
file.close();
|
|
||||||
emit createWallpaperStateChanged(CreateImportVideo::ImportVideoState::CreateProjectFileFinished);
|
emit createWallpaperStateChanged(CreateImportVideo::ImportVideoState::CreateProjectFileFinished);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief .
|
\brief .
|
||||||
*/
|
*/
|
||||||
@ -384,4 +188,6 @@ void Create::abortAndCleanup()
|
|||||||
});
|
});
|
||||||
m_createImportVideoThread->requestInterruption();
|
m_createImportVideoThread->requestInterruption();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -73,6 +73,7 @@ public:
|
|||||||
explicit Create(
|
explicit Create(
|
||||||
const std::shared_ptr<GlobalVariables>& globalVariables,
|
const std::shared_ptr<GlobalVariables>& globalVariables,
|
||||||
QObject* parent = nullptr);
|
QObject* parent = nullptr);
|
||||||
|
|
||||||
Create();
|
Create();
|
||||||
|
|
||||||
enum class VideoCodec {
|
enum class VideoCodec {
|
||||||
@ -107,24 +108,9 @@ signals:
|
|||||||
void htmlWallpaperCreatedSuccessful(QString path);
|
void htmlWallpaperCreatedSuccessful(QString path);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
void createWallpaperStart(QString videoPath, Create::VideoCodec codec);
|
void createWallpaperStart(QString videoPath, Create::VideoCodec codec);
|
||||||
|
|
||||||
void createWidget(
|
|
||||||
const QString& localStoragePath,
|
|
||||||
const QString& title,
|
|
||||||
const QString& previewThumbnail,
|
|
||||||
const QString& createdBy,
|
|
||||||
const QString& license,
|
|
||||||
const QString& type,
|
|
||||||
const QVector<QString>& tags);
|
|
||||||
|
|
||||||
void createHTMLWallpaper(
|
|
||||||
const QString& localStoragePath,
|
|
||||||
const QString& title,
|
|
||||||
const QString& previewThumbnail,
|
|
||||||
const QString& license,
|
|
||||||
const QVector<QString>& tags);
|
|
||||||
|
|
||||||
void saveWallpaper(
|
void saveWallpaper(
|
||||||
QString title,
|
QString title,
|
||||||
QString description,
|
QString description,
|
||||||
|
282
ScreenPlay/src/wizards.cpp
Normal file
282
ScreenPlay/src/wizards.cpp
Normal file
@ -0,0 +1,282 @@
|
|||||||
|
#include "wizards.h"
|
||||||
|
|
||||||
|
namespace ScreenPlay {
|
||||||
|
/*!
|
||||||
|
\class ScreenPlay::Wizards
|
||||||
|
\inmodule ScreenPlay
|
||||||
|
\brief Baseclass for all wizards. Mostly for copying and creating project files.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Constructor.
|
||||||
|
*/
|
||||||
|
Wizards::Wizards(const std::shared_ptr<GlobalVariables>& globalVariables, QObject* parent)
|
||||||
|
: QObject(parent)
|
||||||
|
, m_globalVariables(globalVariables)
|
||||||
|
{
|
||||||
|
qRegisterMetaType<Wizards::WizardResult>("Wizards::WizardResult");
|
||||||
|
qmlRegisterUncreatableType<Wizards>("ScreenPlay.Wizards", 1, 0, "WizardResult", "Error only for enums");
|
||||||
|
qmlRegisterType<Wizards>("ScreenPlay.Wizards", 1, 0, "Wizards");
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Creates a new widget.
|
||||||
|
*/
|
||||||
|
void Wizards::createQMLWidget(const QString& localStoragePath, const QString& title, const QString& previewThumbnail, const QString& createdBy, const QString& license, const QVector<QString>& tags)
|
||||||
|
{
|
||||||
|
QtConcurrent::run([=]() {
|
||||||
|
QUrl localStoragePathUrl { localStoragePath };
|
||||||
|
QDir dir;
|
||||||
|
dir.cd(localStoragePathUrl.toLocalFile());
|
||||||
|
// Create a temp dir so we can later alter it to the workshop id
|
||||||
|
auto folderName = QString("_tmp_" + QTime::currentTime().toString()).replace(":", "");
|
||||||
|
QString workingPath = dir.path() + "/" + folderName;
|
||||||
|
|
||||||
|
if (!dir.mkdir(folderName)) {
|
||||||
|
qDebug() << "Could create folder: " << folderName;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QJsonObject obj;
|
||||||
|
obj.insert("license", license);
|
||||||
|
obj.insert("title", title);
|
||||||
|
obj.insert("tags", Util::fillArray(tags));
|
||||||
|
obj.insert("createdBy", createdBy);
|
||||||
|
obj.insert("type", "qmlWidget");
|
||||||
|
obj.insert("file", "main.qml");
|
||||||
|
|
||||||
|
QFile fileMainQML(workingPath + "/main.qml");
|
||||||
|
if (!fileMainQML.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||||
|
qDebug() << "Could not open /main.qml";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTextStream outMainQML(&fileMainQML);
|
||||||
|
outMainQML.setCodec("UTF-8");
|
||||||
|
outMainQML << "import QtQuick 2.14 \n\n Item {\n id:root \n}";
|
||||||
|
fileMainQML.close();
|
||||||
|
|
||||||
|
QFile file(workingPath + "/project.json");
|
||||||
|
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||||
|
qDebug() << "Could not open /project.json";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QUrl previewThumbnailUrl { previewThumbnail };
|
||||||
|
QFileInfo previewImageFile(previewThumbnailUrl.toLocalFile());
|
||||||
|
|
||||||
|
if (!previewThumbnail.isEmpty()) {
|
||||||
|
obj.insert("previewThumbnail", previewImageFile.fileName());
|
||||||
|
obj.insert("preview", previewImageFile.fileName());
|
||||||
|
if (!QFile::copy(previewThumbnailUrl.toLocalFile(), workingPath + "/" + previewImageFile.fileName())) {
|
||||||
|
qDebug() << "Could not copy" << previewThumbnailUrl.toLocalFile() << " to " << workingPath + "/" + previewImageFile.fileName();
|
||||||
|
emit widgetCreationFinished(WizardResult::CopyError);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QTextStream out(&file);
|
||||||
|
out.setCodec("UTF-8");
|
||||||
|
QJsonDocument doc(obj);
|
||||||
|
out << doc.toJson();
|
||||||
|
file.close();
|
||||||
|
|
||||||
|
emit widgetCreationFinished(WizardResult::Ok, workingPath);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Creates a new widget.
|
||||||
|
*/
|
||||||
|
void Wizards::createHTMLWidget(const QString& localStoragePath, const QString& title, const QString& previewThumbnail, const QString& createdBy, const QString& license, const QVector<QString>& tags)
|
||||||
|
{
|
||||||
|
QtConcurrent::run([=]() {
|
||||||
|
QUrl localStoragePathUrl { localStoragePath };
|
||||||
|
QDir dir;
|
||||||
|
dir.cd(localStoragePathUrl.toLocalFile());
|
||||||
|
// Create a temp dir so we can later alter it to the workshop id
|
||||||
|
auto folderName = QString("_tmp_" + QTime::currentTime().toString()).replace(":", "");
|
||||||
|
QString workingPath = dir.path() + "/" + folderName;
|
||||||
|
|
||||||
|
if (!dir.mkdir(folderName)) {
|
||||||
|
qDebug() << "Could create folder: " << folderName;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QJsonObject obj;
|
||||||
|
obj.insert("license", license);
|
||||||
|
obj.insert("title", title);
|
||||||
|
obj.insert("tags", Util::fillArray(tags));
|
||||||
|
obj.insert("createdBy", createdBy);
|
||||||
|
obj.insert("type", "htmlWidget");
|
||||||
|
obj.insert("file", "index.html");
|
||||||
|
|
||||||
|
QFile fileMainHTML(workingPath + "/index.html");
|
||||||
|
if (!fileMainHTML.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||||
|
qDebug() << "Could not open /index.html";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTextStream outMainHTML(&fileMainHTML);
|
||||||
|
outMainHTML.setCodec("UTF-8");
|
||||||
|
outMainHTML << "<html>\n<head></head>\n<body></body>\n</html>";
|
||||||
|
fileMainHTML.close();
|
||||||
|
|
||||||
|
QFile file(workingPath + "/project.json");
|
||||||
|
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||||
|
qDebug() << "Could not open /project.json";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QUrl previewThumbnailUrl { previewThumbnail };
|
||||||
|
QFileInfo previewImageFile(previewThumbnailUrl.toLocalFile());
|
||||||
|
|
||||||
|
if (!previewThumbnail.isEmpty()) {
|
||||||
|
obj.insert("previewThumbnail", previewImageFile.fileName());
|
||||||
|
obj.insert("preview", previewImageFile.fileName());
|
||||||
|
if (!QFile::copy(previewThumbnailUrl.toLocalFile(), workingPath + "/" + previewImageFile.fileName())) {
|
||||||
|
qDebug() << "Could not copy" << previewThumbnailUrl.toLocalFile() << " to " << workingPath + "/" + previewImageFile.fileName();
|
||||||
|
emit widgetCreationFinished(WizardResult::CopyError);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QTextStream out(&file);
|
||||||
|
out.setCodec("UTF-8");
|
||||||
|
QJsonDocument doc(obj);
|
||||||
|
out << doc.toJson();
|
||||||
|
file.close();
|
||||||
|
|
||||||
|
emit widgetCreationFinished(WizardResult::Ok, workingPath);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Creates a HTML wallpaper.
|
||||||
|
*/
|
||||||
|
void Wizards::createHTMLWallpaper(
|
||||||
|
const QString& localStoragePath,
|
||||||
|
const QString& title,
|
||||||
|
const QString& previewThumbnail,
|
||||||
|
const QString& license,
|
||||||
|
const QVector<QString>& tags)
|
||||||
|
{
|
||||||
|
QtConcurrent::run([=]() {
|
||||||
|
QUrl localStoragePathUrl { localStoragePath };
|
||||||
|
QDir dir;
|
||||||
|
dir.cd(localStoragePathUrl.toLocalFile());
|
||||||
|
// Create a temp dir so we can later alter it to the workshop id
|
||||||
|
auto folderName = QString("_tmp_" + QTime::currentTime().toString()).replace(":", "");
|
||||||
|
QString workingPath = dir.path() + "/" + folderName;
|
||||||
|
|
||||||
|
if (!dir.mkdir(folderName)) {
|
||||||
|
qDebug() << "Could create folder: " << folderName;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QJsonObject obj;
|
||||||
|
obj.insert("license", license);
|
||||||
|
obj.insert("title", title);
|
||||||
|
obj.insert("tags", Util::fillArray(tags));
|
||||||
|
obj.insert("type", "htmlWallpaper");
|
||||||
|
obj.insert("file", "index.html");
|
||||||
|
|
||||||
|
QFile fileMainHTML(workingPath + "/index.html");
|
||||||
|
if (!fileMainHTML.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||||
|
qDebug() << "Could not open /index.html";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTextStream outMainHTML(&fileMainHTML);
|
||||||
|
outMainHTML.setCodec("UTF-8");
|
||||||
|
outMainHTML << "<html>\n<head></head>\n"
|
||||||
|
"<h1>This is an empty html Wallpaper!</h1>"
|
||||||
|
"<body></body>\n</html>";
|
||||||
|
fileMainHTML.close();
|
||||||
|
|
||||||
|
QUrl previewThumbnailUrl { previewThumbnail };
|
||||||
|
QFileInfo previewImageFile(previewThumbnailUrl.toLocalFile());
|
||||||
|
|
||||||
|
if (!previewThumbnail.isEmpty()) {
|
||||||
|
obj.insert("previewThumbnail", previewImageFile.fileName());
|
||||||
|
obj.insert("preview", previewImageFile.fileName());
|
||||||
|
if (!QFile::copy(previewThumbnailUrl.toLocalFile(), workingPath + "/" + previewImageFile.fileName())) {
|
||||||
|
qDebug() << "Could not copy" << previewThumbnailUrl.toLocalFile() << " to " << workingPath + "/" + previewImageFile.fileName();
|
||||||
|
emit widgetCreationFinished(WizardResult::CopyPreviewThumbnailError);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Util::writeSettings(obj, dir.path() + "/project.json")) {
|
||||||
|
emit widgetCreationFinished(WizardResult::WriteProjectFileError);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
emit widgetCreationFinished(WizardResult::Ok, workingPath);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief .
|
||||||
|
*/
|
||||||
|
void Wizards::createQMLWallpaper(const QString& title, const QString& previewThumbnail, const QString& license, const QVector<QString>& tags)
|
||||||
|
{
|
||||||
|
QtConcurrent::run([=]() {
|
||||||
|
std::optional<QString> folderName = createTemporaryFolder();
|
||||||
|
|
||||||
|
if (!folderName.has_value()) {
|
||||||
|
emit widgetCreationFinished(WizardResult::CreateProjectFolderError);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString workingPath = Util::toLocal(m_globalVariables->localStoragePath().toString() + "/" + folderName.value());
|
||||||
|
|
||||||
|
QJsonObject obj;
|
||||||
|
obj.insert("license", license);
|
||||||
|
obj.insert("title", title);
|
||||||
|
obj.insert("tags", Util::fillArray(tags));
|
||||||
|
obj.insert("type", "qmlWallpaper");
|
||||||
|
obj.insert("file", "main.qml");
|
||||||
|
|
||||||
|
if (!previewThumbnail.isEmpty()) {
|
||||||
|
QUrl previewThumbnailUrl { previewThumbnail };
|
||||||
|
if (!Util::copyPreviewThumbnail(obj, workingPath + "/" + previewThumbnailUrl.fileName(), workingPath)) {
|
||||||
|
emit widgetCreationFinished(WizardResult::CopyPreviewThumbnailError);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Util::writeSettings(obj, workingPath + "/project.json")) {
|
||||||
|
emit widgetCreationFinished(WizardResult::WriteProjectFileError);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Util::writeFile("import QtQuick 2.14 \n\nItem {\n id:root \n}", workingPath + "/main.qml")) {
|
||||||
|
emit widgetCreationFinished(WizardResult::WriteProjectFileError);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
emit widgetCreationFinished(WizardResult::Ok, workingPath);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief .
|
||||||
|
*/
|
||||||
|
const std::optional<QString> Wizards::createTemporaryFolder() const
|
||||||
|
{
|
||||||
|
QUrl localStoragePathUrl { m_globalVariables->localStoragePath() };
|
||||||
|
QDir dir;
|
||||||
|
dir.cd(localStoragePathUrl.toLocalFile());
|
||||||
|
|
||||||
|
// Create a temp dir so we can later alter it to the workshop id
|
||||||
|
const QString folderName = QString("_tmp_" + QTime::currentTime().toString()).replace(":", "");
|
||||||
|
|
||||||
|
if (!dir.mkdir(folderName)) {
|
||||||
|
qWarning() << "Could create folder: " << folderName;
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
return folderName;
|
||||||
|
}
|
||||||
|
}
|
121
ScreenPlay/src/wizards.h
Normal file
121
ScreenPlay/src/wizards.h
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2020 Elias Steurer (Kelteseth)
|
||||||
|
** Contact: https://screen-play.app
|
||||||
|
**
|
||||||
|
** This file is part of ScreenPlay. ScreenPlay is licensed under a dual license in
|
||||||
|
** order to ensure its sustainability. When you contribute to ScreenPlay
|
||||||
|
** you accept that your work will be available under the two following licenses:
|
||||||
|
**
|
||||||
|
** $SCREENPLAY_BEGIN_LICENSE$
|
||||||
|
**
|
||||||
|
** #### Affero General Public License Usage (AGPLv3)
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Affero
|
||||||
|
** General Public License version 3 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file "ScreenPlay License.md" included in the
|
||||||
|
** packaging of this App. Please review the following information to
|
||||||
|
** ensure the GNU Affero Lesser General Public License version 3 requirements
|
||||||
|
** will be met: https://www.gnu.org/licenses/agpl-3.0.en.html.
|
||||||
|
**
|
||||||
|
** #### Commercial License
|
||||||
|
** This code is owned by Elias Steurer. By changing/adding to the code you agree to the
|
||||||
|
** terms written in:
|
||||||
|
** * Legal/corporate_contributor_license_agreement.md - For corporate contributors
|
||||||
|
** * Legal/individual_contributor_license_agreement.md - For individual contributors
|
||||||
|
**
|
||||||
|
** #### Additional Limitations to the AGPLv3 and Commercial Lincese
|
||||||
|
** This License does not grant any rights in the trademarks,
|
||||||
|
** service marks, or logos.
|
||||||
|
**
|
||||||
|
**
|
||||||
|
** $SCREENPLAY_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QDir>
|
||||||
|
#include <QFile>
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QFuture>
|
||||||
|
#include <QFutureWatcher>
|
||||||
|
#include <QJsonArray>
|
||||||
|
#include <QJsonDocument>
|
||||||
|
#include <QJsonObject>
|
||||||
|
#include <QJsonParseError>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QProcess>
|
||||||
|
#include <QQmlEngine>
|
||||||
|
#include <QScopedPointer>
|
||||||
|
#include <QString>
|
||||||
|
#include <QStringList>
|
||||||
|
#include <QTime>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QUrl>
|
||||||
|
#include <QtMath>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
|
#include "createimportvideo.h"
|
||||||
|
#include "globalvariables.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
namespace ScreenPlay {
|
||||||
|
|
||||||
|
class Wizards : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit Wizards(const std::shared_ptr<GlobalVariables>& globalVariables, QObject* parent = nullptr);
|
||||||
|
Wizards() { }
|
||||||
|
|
||||||
|
enum class WizardResult {
|
||||||
|
Ok,
|
||||||
|
CopyError,
|
||||||
|
WriteProjectFileError,
|
||||||
|
CreateProjectFolderError,
|
||||||
|
CopyPreviewThumbnailError,
|
||||||
|
};
|
||||||
|
Q_ENUM(WizardResult)
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void createQMLWidget(
|
||||||
|
const QString& localStoragePath,
|
||||||
|
const QString& title,
|
||||||
|
const QString& previewThumbnail,
|
||||||
|
const QString& createdBy,
|
||||||
|
const QString& license,
|
||||||
|
const QVector<QString>& tags);
|
||||||
|
|
||||||
|
void createHTMLWidget(
|
||||||
|
const QString& localStoragePath,
|
||||||
|
const QString& title,
|
||||||
|
const QString& previewThumbnail,
|
||||||
|
const QString& createdBy,
|
||||||
|
const QString& license,
|
||||||
|
const QVector<QString>& tags);
|
||||||
|
|
||||||
|
void createHTMLWallpaper(
|
||||||
|
const QString& localStoragePath,
|
||||||
|
const QString& title,
|
||||||
|
const QString& previewThumbnail,
|
||||||
|
const QString& license,
|
||||||
|
const QVector<QString>& tags);
|
||||||
|
|
||||||
|
void createQMLWallpaper(
|
||||||
|
const QString& title,
|
||||||
|
const QString& previewThumbnail,
|
||||||
|
const QString& license,
|
||||||
|
const QVector<QString>& tags);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void widgetCreationFinished(const Wizards::WizardResult result);
|
||||||
|
void widgetCreationFinished(const Wizards::WizardResult result, const QVariant value);
|
||||||
|
|
||||||
|
private:
|
||||||
|
const std::shared_ptr<GlobalVariables> m_globalVariables;
|
||||||
|
const std::optional<QString> createTemporaryFolder() const;
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user