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
ff9d0510
Commit
ff9d0510
authored
1 year ago
by
Burak Hançerli
Committed by
Thomas Hartmann
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
QDS-11394
DS templates are not working out of the box
parent
baae8244
No related branches found
No related tags found
1 merge request
!12
QDS-11394 DS templates are not working out of the box
Pipeline
#65525
passed
1 year ago
Stage: build
Stage: release
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/designviewer.cpp
+80
-4
80 additions, 4 deletions
src/designviewer.cpp
with
80 additions
and
4 deletions
src/designviewer.cpp
+
80
−
4
View file @
ff9d0510
...
...
@@ -163,7 +163,84 @@ QString DesignViewer::unpackProject(const QByteArray &project, bool extractZip)
projectLocation
=
":"
+
resourcePath
;
}
return
projectLocation
;
// create a temporary directory and copy the project there
QTemporaryDir
tempDir
;
tempDir
.
setAutoRemove
(
false
);
if
(
!
tempDir
.
isValid
())
{
printErr
(
"Could not create a temporary directory."
);
return
""
;
}
const
QString
tempDirPath
=
tempDir
.
path
();
printLog
(
"Temporary directory: "
+
tempDirPath
);
QDir
tempDirDir
(
tempDirPath
);
if
(
!
tempDirDir
.
exists
())
{
printErr
(
"Temporary directory does not exist."
);
return
""
;
}
if
(
!
QDir
(
projectLocation
).
exists
())
{
printErr
(
"Project directory does not exist."
);
return
""
;
}
// copy all files and directories from projectLocation to tempDirPath
QDirIterator
it
(
projectLocation
,
QDir
::
AllEntries
|
QDir
::
NoDotAndDotDot
,
QDirIterator
::
Subdirectories
);
printLog
(
"Files in project location: "
+
projectLocation
);
while
(
it
.
hasNext
())
{
const
QString
filePath
=
it
.
next
();
printLog
(
"Found file: "
+
filePath
);
const
QFileInfo
fileInfo
(
filePath
);
const
QString
relativeFilePath
=
fileInfo
.
filePath
().
remove
(
projectLocation
);
const
QString
newFilePath
=
tempDirPath
+
relativeFilePath
;
printLog
(
"Copying file: "
+
filePath
+
" to "
+
newFilePath
);
if
(
fileInfo
.
isDir
())
{
QDir
().
mkpath
(
newFilePath
);
}
else
if
(
!
QFile
::
copy
(
filePath
,
newFilePath
))
{
printErr
(
"Could not copy file: "
+
filePath
+
" to "
+
newFilePath
);
return
""
;
}
}
// find all .qml files in the temporary directory and remove the Qt versions from 6.5 to 6.9
// at the end of the import statements. example "import <modulename> 6.5" -> "import <modulename>"
QDirIterator
it2
(
tempDirPath
,
{
"*.qml"
},
QDir
::
Files
,
QDirIterator
::
Subdirectories
);
printLog
(
"Files in temporary directory: "
+
tempDirPath
);
while
(
it2
.
hasNext
())
{
const
QString
filePath
=
it2
.
next
();
QFile
file
(
filePath
);
// set file permissions to read and write
file
.
setPermissions
(
QFile
::
ReadOwner
|
QFile
::
WriteOwner
);
if
(
!
file
.
open
(
QIODevice
::
ReadWrite
))
{
printErr
(
"Could not open file: "
+
filePath
);
return
""
;
}
const
QRegularExpression
importRegExp
(
"import
\\
s+
\\
S+
\\
s+6
\\
.[5-9]"
);
QString
content
=
QString
::
fromUtf8
(
file
.
readAll
());
while
(
content
.
contains
(
importRegExp
))
{
const
QRegularExpressionMatch
match
=
importRegExp
.
match
(
content
);
const
QStringList
textList
=
match
.
capturedTexts
();
for
(
const
QString
&
text
:
textList
)
{
const
QString
newText
=
QString
(
text
).
remove
(
QRegularExpression
(
"
\\
s+6
\\
.[5-9]"
));
printLog
(
"Found text to replace: "
+
text
+
" with "
+
newText
+
" in file "
+
filePath
);
content
.
replace
(
text
,
newText
);
}
}
file
.
resize
(
0
);
file
.
write
(
content
.
toUtf8
());
file
.
close
();
}
// return the temporary directory path
return
tempDirPath
;
}
QString
DesignViewer
::
findFile
(
const
QString
&
dir
,
const
QString
&
filter
)
...
...
@@ -277,9 +354,8 @@ bool DesignViewer::runProject(const QByteArray &projectData, const QString &proj
printLog
(
"Found mainQmlFile: "
+
mainQmlFilePath
);
QUrl
mainQmlUrl
=
QUrl
::
fromUserInput
(
mainQmlFilePath
);
QFile
file
(
mainQmlUrl
.
path
().
prepend
(
":"
));
if
(
!
file
.
open
(
QIODevice
::
ReadOnly
))
{
QFile
file
(
mainQmlUrl
.
path
());
if
(
!
file
.
open
(
QIODevice
::
ReadOnly
))
{
printErr
(
"Could not open mainQmlfile for reading! "
+
file
.
fileName
()
+
": "
+
file
.
errorString
());
return
false
;
}
...
...
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