Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Qt Design Viewer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Design Studio
QML Viewer Projects
Qt Design Viewer
Commits
20dec5dd
Verified
Commit
20dec5dd
authored
6 months ago
by
Burak Hançerli
Browse files
Options
Downloads
Patches
Plain Diff
chore: remove zip support
parent
f36d67fc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!29
Remove zip support
Pipeline
#76296
passed
6 months ago
Changes
3
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/designviewer.cpp
+21
-45
21 additions, 45 deletions
src/designviewer.cpp
src/designviewer.h
+1
-1
1 addition, 1 deletion
src/designviewer.h
www/index.html
+2
-2
2 additions, 2 deletions
www/index.html
with
24 additions
and
48 deletions
src/designviewer.cpp
+
21
−
45
View file @
20dec5dd
...
@@ -33,7 +33,6 @@
...
@@ -33,7 +33,6 @@
#include
<QRandomGenerator>
#include
<QRandomGenerator>
#include
<QRegularExpression>
#include
<QRegularExpression>
#include
<QResource>
#include
<QResource>
#include
<QtCore/private/qzipreader_p.h>
DesignViewer
::
DesignViewer
()
DesignViewer
::
DesignViewer
()
{
{
...
@@ -62,58 +61,35 @@ void DesignViewer::fetchProject(QByteArray *data, QString *fileName)
...
@@ -62,58 +61,35 @@ void DesignViewer::fetchProject(QByteArray *data, QString *fileName)
*
fileName
=
QString
::
fromStdString
(
jsFileName
.
as
<
std
::
string
>
());
*
fileName
=
QString
::
fromStdString
(
jsFileName
.
as
<
std
::
string
>
());
}
}
QString
DesignViewer
::
unpackProject
(
const
QByteArray
&
project
,
bool
extractZip
)
QString
DesignViewer
::
unpackProject
(
const
QByteArray
&
project
)
{
{
QString
projectLocation
=
"/home/web_user/"
;
const
uchar
*
data
;
if
(
m_projectData
.
size
())
{
if
(
extractZip
)
{
qDebug
()
<<
"Unregistering the previous data from QRC system. Path: "
+
m_projectPath
QDir
().
mkpath
(
projectLocation
);
+
" Size: "
+
QString
::
number
(
m_projectData
.
size
())
+
" bytes."
;
QBuffer
buffer
;
buffer
.
setData
(
project
);
buffer
.
open
(
QIODevice
::
ReadOnly
);
QZipReader
reader
(
&
buffer
);
reader
.
extractAll
(
projectLocation
);
}
qDebug
()
<<
"Initial project location: "
+
projectLocation
;
QDir
projectLocationDir
(
projectLocation
);
// maybe it was not a zip file so try it as resource binary
if
(
projectLocationDir
.
isEmpty
())
{
if
(
extractZip
)
qDebug
()
<<
"File could not be extracted. Trying to open it as a resource file."
;
const
uchar
*
data
;
if
(
m_projectData
.
size
())
{
qDebug
()
<<
"Unregistering the previous data from QRC system. Path: "
+
m_projectPath
+
" Size: "
+
QString
::
number
(
m_projectData
.
size
())
+
" bytes."
;
data
=
reinterpret_cast
<
const
uchar
*>
(
m_projectData
.
data
());
if
(
!
QResource
::
unregisterResource
(
data
,
m_projectPath
))
{
qCritical
()
<<
"Cannot unregister the previous resource data."
;
}
}
m_projectData
=
project
;
data
=
reinterpret_cast
<
const
uchar
*>
(
m_projectData
.
data
());
data
=
reinterpret_cast
<
const
uchar
*>
(
m_projectData
.
data
());
qDebug
()
<<
"Registering resource data. Size: "
+
QString
::
number
(
m_projectData
.
size
());
if
(
!
QResource
::
unregisterResource
(
data
,
m_projectPath
))
{
qCritical
()
<<
"Cannot unregister the previous resource data."
;
}
}
const
QString
resourcePath
{
"/"
+
QString
::
number
(
QRandomGenerator
::
global
()
->
generate
())};
m_projectData
=
project
;
m_projectPath
=
resourcePath
;
data
=
reinterpret_cast
<
const
uchar
*>
(
m_projectData
.
data
());
qDebug
()
<<
"Registering resource data. Size: "
+
QString
::
number
(
m_projectData
.
size
());
if
(
!
QDir
(
resourcePath
).
removeRecursively
())
{
const
QString
resourcePath
{
"/"
+
QString
::
number
(
QRandomGenerator
::
global
()
->
generate
())};
qDebug
()
<<
"Could not remove resource path: "
+
resourcePath
;
m_projectPath
=
resourcePath
;
}
if
(
!
QResource
::
registerResource
(
data
,
resourcePath
))
{
if
(
!
QDir
(
resourcePath
).
removeRecursively
())
{
qCritical
()
<<
"Can not load the resource data."
;
qDebug
()
<<
"Could not remove resource path: "
+
resourcePath
;
return
""
;
}
}
projectLocation
=
":"
+
resourcePath
;
if
(
!
QResource
::
registerResource
(
data
,
resourcePath
))
{
qCritical
()
<<
"Can not load the resource data."
;
return
""
;
}
}
return
projectLocation
;
return
QString
(
resourcePath
).
prepend
(
":"
)
;
}
}
QString
DesignViewer
::
findFile
(
const
QString
&
dir
,
const
QString
&
filter
)
QString
DesignViewer
::
findFile
(
const
QString
&
dir
,
const
QString
&
filter
)
...
...
This diff is collapsed.
Click to expand it.
src/designviewer.h
+
1
−
1
View file @
20dec5dd
...
@@ -52,7 +52,7 @@ private:
...
@@ -52,7 +52,7 @@ private:
void
showAppWindow
();
void
showAppWindow
();
void
fetchProject
(
QByteArray
*
data
,
QString
*
fileName
);
void
fetchProject
(
QByteArray
*
data
,
QString
*
fileName
);
QString
unpackProject
(
const
QByteArray
&
project
,
bool
extractZip
=
false
);
QString
unpackProject
(
const
QByteArray
&
project
);
QString
findFile
(
const
QString
&
dir
,
const
QString
&
filter
);
QString
findFile
(
const
QString
&
dir
,
const
QString
&
filter
);
void
parseQmlprojectFile
(
const
QString
&
fileName
,
QString
*
mainFile
,
QStringList
*
importPaths
);
void
parseQmlprojectFile
(
const
QString
&
fileName
,
QString
*
mainFile
,
QStringList
*
importPaths
);
bool
runProject
(
const
QByteArray
&
projectData
,
const
QString
&
projectName
);
bool
runProject
(
const
QByteArray
&
projectData
,
const
QString
&
projectName
);
...
...
This diff is collapsed.
Click to expand it.
www/index.html
+
2
−
2
View file @
20dec5dd
...
@@ -76,7 +76,7 @@
...
@@ -76,7 +76,7 @@
</figure>
</figure>
<div
id=
"qtcontainer"
></div>
<div
id=
"qtcontainer"
></div>
<div
id=
"dropzone"
>
<div
id=
"dropzone"
>
<div
id=
"instruction"
>
Drop your qmlrc file
or zip file
here
</div>
<div
id=
"instruction"
>
Drop your qmlrc file here
</div>
<p>
<p>
(Package with a pure Qml project, containing either a .qmlproject file
(Package with a pure Qml project, containing either a .qmlproject file
or a main.qml)
or a main.qml)
...
@@ -86,7 +86,7 @@
...
@@ -86,7 +86,7 @@
><input
><input
id=
"fileinput"
id=
"fileinput"
type=
"file"
type=
"file"
accept=
".qmlrc
,.zip
"
accept=
".qmlrc"
style=
"display: none"
style=
"display: none"
/><img
/><img
src=
"resources/images/uploadIcon.svg"
src=
"resources/images/uploadIcon.svg"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment