Skip to content
Snippets Groups Projects
Commit 1c1a7473 authored by Burak Hançerli's avatar Burak Hançerli :headphones:
Browse files

Remove zip support

parent 4b859af9
No related branches found
No related tags found
1 merge request!30Remove zip support
Pipeline #76715 passed
......@@ -33,7 +33,6 @@
#include <QRandomGenerator>
#include <QRegularExpression>
#include <QResource>
#include <QtCore/private/qzipreader_p.h>
DesignViewer::DesignViewer()
{
......@@ -62,58 +61,35 @@ void DesignViewer::fetchProject(QByteArray *data, QString *fileName)
*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/";
if (extractZip) {
QDir().mkpath(projectLocation);
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;
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());
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_projectPath = resourcePath;
m_projectData = project;
data = reinterpret_cast<const uchar *>(m_projectData.data());
qDebug() << "Registering resource data. Size: " + QString::number(m_projectData.size());
if (!QDir(resourcePath).removeRecursively()) {
qDebug() << "Could not remove resource path: " + resourcePath;
}
const QString resourcePath{"/" + QString::number(QRandomGenerator::global()->generate())};
m_projectPath = resourcePath;
if (!QResource::registerResource(data, resourcePath)) {
qCritical() << "Can not load the resource data.";
return "";
}
if (!QDir(resourcePath).removeRecursively()) {
qDebug() << "Could not remove resource path: " + resourcePath;
}
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)
......
......@@ -52,7 +52,7 @@ private:
void showAppWindow();
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);
void parseQmlprojectFile(const QString &fileName, QString *mainFile, QStringList *importPaths);
bool runProject(const QByteArray &projectData, const QString &projectName);
......
......@@ -76,7 +76,7 @@
</figure>
<div id="qtcontainer"></div>
<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>
(Package with a pure Qml project, containing either a .qmlproject file
or a main.qml)
......@@ -86,7 +86,7 @@
><input
id="fileinput"
type="file"
accept=".qmlrc,.zip"
accept=".qmlrc"
style="display: none"
/><img
src="resources/images/uploadIcon.svg"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment