Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
9
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Open sidebar
Elias Steurer
ScreenPlay
Commits
a8620f15
Commit
a8620f15
authored
Jan 05, 2021
by
Elias Steurer
🇩🇪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix qml and html preview image copy
Add errors emit to all returns
parent
4c2b6dbd
Pipeline
#237619140
canceled with stages
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
20 deletions
+21
-20
ScreenPlay/src/util.cpp
ScreenPlay/src/util.cpp
+7
-6
ScreenPlay/src/util.h
ScreenPlay/src/util.h
+1
-1
ScreenPlay/src/wizards.cpp
ScreenPlay/src/wizards.cpp
+12
-13
ScreenPlay/src/wizards.h
ScreenPlay/src/wizards.h
+1
-0
No files found.
ScreenPlay/src/util.cpp
View file @
a8620f15
...
...
@@ -495,14 +495,15 @@ bool Util::writeFileFromQrc(const QString& qrcPath, const QString& absolutePath)
\brief Takes reference to \a obj. If the copy of the thumbnail is successful,
it adds the corresponding settings entry to the json object reference.
*/
bool
Util
::
copyPreviewThumbnail
(
QJsonObject
&
obj
,
const
QString
&
name
,
const
QString
&
destination
)
bool
Util
::
copyPreviewThumbnail
(
QJsonObject
&
obj
,
const
QString
&
previewThumbnail
,
const
QString
&
destination
)
{
QUrl
previewThumbnailUrl
{
name
};
QFileInfo
previewImageFile
(
previewThumbnailUrl
.
toLocalFile
());
const
QUrl
previewThumbnailUrl
{
previewThumbnail
};
const
QFileInfo
previewImageFile
(
previewThumbnailUrl
.
toString
());
const
QString
destinationFilePath
=
destination
+
"/"
+
previewImageFile
.
fileName
();
if
(
!
name
.
isEmpty
())
{
if
(
!
QFile
::
copy
(
previewThumbnailUrl
.
toLocalFile
(),
destination
))
{
qDebug
()
<<
"Could not copy"
<<
previewThumbnailUrl
.
toLocalFile
()
<<
" to "
<<
name
;
if
(
!
previewThumbnail
.
isEmpty
())
{
if
(
!
QFile
::
copy
(
previewThumbnailUrl
.
toLocalFile
(),
destination
FilePath
))
{
qDebug
()
<<
"Could not copy"
<<
previewThumbnailUrl
.
toLocalFile
()
<<
" to "
<<
destinationFilePath
;
return
false
;
}
}
...
...
ScreenPlay/src/util.h
View file @
a8620f15
...
...
@@ -118,7 +118,7 @@ public slots:
static
bool
writeSettings
(
const
QJsonObject
&
obj
,
const
QString
&
absolutePath
);
static
bool
writeFile
(
const
QString
&
text
,
const
QString
&
absolutePath
);
static
bool
writeFileFromQrc
(
const
QString
&
qrcPath
,
const
QString
&
absolutePath
);
static
bool
copyPreviewThumbnail
(
QJsonObject
&
obj
,
const
QString
&
name
,
const
QString
&
destination
);
static
bool
copyPreviewThumbnail
(
QJsonObject
&
obj
,
const
QString
&
previewThumbnail
,
const
QString
&
destination
);
static
QString
toString
(
const
QStringList
&
list
);
static
QString
toLocal
(
const
QString
&
url
);
static
QString
generateRandomString
(
quint32
length
=
32
);
...
...
ScreenPlay/src/wizards.cpp
View file @
a8620f15
...
...
@@ -49,11 +49,13 @@ void Wizards::createQMLWidget(const QString& title,
if
(
!
Util
::
writeFileFromQrc
(
":/assets/wizards/"
+
licenseFile
,
workingPath
+
"/"
+
licenseFile
))
{
qWarning
()
<<
"Could not write "
<<
licenseFile
;
emit
widgetCreationFinished
(
WizardResult
::
WriteLicenseFileError
);
return
;
}
if
(
!
Util
::
writeFileFromQrc
(
":/qml/Create/WizardsFiles/QMLWidgetMain.qml"
,
workingPath
+
"main.qml"
))
{
qWarning
()
<<
"Could not write main.qml"
;
emit
widgetCreationFinished
(
WizardResult
::
WriteProjectFileError
);
return
;
}
...
...
@@ -108,11 +110,13 @@ void Wizards::createHTMLWidget(const QString& title,
if
(
!
Util
::
writeFileFromQrc
(
":/assets/wizards/"
+
licenseFile
,
workingPath
+
"/"
+
licenseFile
))
{
qWarning
()
<<
"Could not write "
<<
licenseFile
;
emit
widgetCreationFinished
(
WizardResult
::
WriteLicenseFileError
);
return
;
}
if
(
!
Util
::
writeFileFromQrc
(
":/qml/Create/WizardsFiles/HTMLWidgetMain.html"
,
workingPath
+
"/index.html"
))
{
qWarning
()
<<
"Could not write HTMLWidgetMain.html"
;
emit
widgetCreationFinished
(
WizardResult
::
WriteProjectFileError
);
return
;
}
...
...
@@ -129,12 +133,6 @@ void Wizards::createHTMLWidget(const QString& title,
}
}
QFile
file
(
workingPath
+
"/project.json"
);
if
(
!
file
.
open
(
QIODevice
::
WriteOnly
|
QIODevice
::
Text
))
{
qWarning
()
<<
"Could not open /project.json"
;
return
;
}
if
(
!
Util
::
writeSettings
(
obj
,
workingPath
+
"/project.json"
))
{
emit
widgetCreationFinished
(
WizardResult
::
WriteProjectFileError
);
return
;
...
...
@@ -175,11 +173,13 @@ void Wizards::createHTMLWallpaper(
if
(
!
Util
::
writeFileFromQrc
(
":/assets/wizards/"
+
licenseFile
,
workingPath
+
"/"
+
licenseFile
))
{
qWarning
()
<<
"Could not write "
<<
licenseFile
;
emit
widgetCreationFinished
(
WizardResult
::
WriteLicenseFileError
);
return
;
}
if
(
!
Util
::
writeFileFromQrc
(
":/qml/Create/WizardsFiles/HTMLWallpaperMain.html"
,
workingPath
+
"/index.html"
))
{
qWarning
()
<<
"Could not write HTMLWallpaperMain.html"
;
emit
widgetCreationFinished
(
WizardResult
::
WriteProjectFileError
);
return
;
}
...
...
@@ -234,8 +234,7 @@ void Wizards::createQMLWallpaper(
obj
.
insert
(
"file"
,
"main.qml"
);
if
(
!
previewThumbnail
.
isEmpty
())
{
QUrl
previewThumbnailUrl
{
previewThumbnail
};
if
(
!
Util
::
copyPreviewThumbnail
(
obj
,
workingPath
+
"/"
+
previewThumbnailUrl
.
fileName
(),
workingPath
))
{
if
(
!
Util
::
copyPreviewThumbnail
(
obj
,
previewThumbnail
,
workingPath
))
{
emit
widgetCreationFinished
(
WizardResult
::
CopyPreviewThumbnailError
);
return
;
}
...
...
@@ -243,6 +242,7 @@ void Wizards::createQMLWallpaper(
if
(
!
Util
::
writeFileFromQrc
(
":/assets/wizards/"
+
licenseFile
,
workingPath
+
"/"
+
licenseFile
))
{
qWarning
()
<<
"Could not write "
<<
licenseFile
;
emit
widgetCreationFinished
(
WizardResult
::
WriteLicenseFileError
);
return
;
}
...
...
@@ -290,6 +290,7 @@ void Wizards::createGifWallpaper(
if
(
!
Util
::
writeFileFromQrc
(
":/assets/wizards/"
+
licenseFile
,
workingPath
+
"/"
+
licenseFile
))
{
qWarning
()
<<
"Could not write "
<<
licenseFile
;
emit
widgetCreationFinished
(
WizardResult
::
WriteLicenseFileError
);
return
;
}
...
...
@@ -334,8 +335,7 @@ void Wizards::createWebsiteWallpaper(
obj
.
insert
(
"url"
,
url
.
toString
());
if
(
!
previewThumbnail
.
isEmpty
())
{
QUrl
previewThumbnailUrl
{
previewThumbnail
};
if
(
!
Util
::
copyPreviewThumbnail
(
obj
,
workingPath
+
"/"
+
previewThumbnailUrl
.
fileName
(),
workingPath
))
{
if
(
!
Util
::
copyPreviewThumbnail
(
obj
,
previewThumbnail
,
workingPath
))
{
emit
widgetCreationFinished
(
WizardResult
::
CopyPreviewThumbnailError
);
return
;
}
...
...
@@ -355,9 +355,8 @@ void Wizards::createWebsiteWallpaper(
*/
const
std
::
optional
<
QString
>
Wizards
::
createTemporaryFolder
()
const
{
QUrl
localStoragePathUrl
{
m_globalVariables
->
localStoragePath
()
};
QDir
dir
;
dir
.
cd
(
localStoragePathUrl
.
toLocalFile
());
const
QUrl
localStoragePathUrl
{
m_globalVariables
->
localStoragePath
()
};
const
QDir
dir
{
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
(
":"
,
""
);
...
...
ScreenPlay/src/wizards.h
View file @
a8620f15
...
...
@@ -75,6 +75,7 @@ public:
Ok
,
CopyError
,
WriteProjectFileError
,
WriteLicenseFileError
,
CreateProjectFolderError
,
CopyPreviewThumbnailError
,
CopyFileError
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment