9 #include <QTemporaryDir>
11 #include <QDirIterator>
13 #include <JlCompress.h>
14 #include <QJsonObject>
16 #include <QJsonDocument>
30 selectFile(
"hal_project_" + mProjectName +
".zip");
43 log_warning(
"gui",
"Failed to create temporary project export directory '{}'.", projTargetDir.
toStdString());
65 log_warning(
"gui",
"Project export found file '{}' not in project folder '{}'.",
69 dirsToCreate.
append(relPath);
75 filesToCopy.
append(relPath);
78 log_warning(
"gui",
"Project export ignored directory entry '{}' with unknown type.", relPath.
toStdString());
82 for (
QString dir : dirsToCreate)
85 if (!
QDir().mkpath(fullpath))
86 log_warning(
"gui",
"Failed to create directory '{}' in project export folder.", dir.toStdString());
90 for (
const QString& s : filesToCopy)
96 log_warning(
"gui",
"Failed to copy file '{}' into project export folder.", s.toStdString());
97 if (s ==
".project.json" || s.endsWith(
".hal") || s.endsWith(
".hgl"))
107 ProjectJson projFile(
QDir(projTargetDir).absoluteFilePath(
".project.json"));
117 copyExternalPython(projTargetDir);
119 if (JlCompress::compressDir( archiveFilename, tempDir.
path(),
true,
QDir::Hidden ))
128 void ExportProjectDialog::copyExternalPython(
const QString &projTempDir)
140 if (!obj.
contains(
"tabs") || !obj[
"tabs"].isArray())
return;
142 int replaceCount = 0;
147 int ntabs = oldTabs.
size();
148 for (
int itab = 0; itab < ntabs; itab++)
151 if (!tab.
contains(
"filename"))
continue;
152 QString absFilename = tab[
"filename"].toString();
163 tab.
insert(
"filename", relFilename);
172 obj.
insert(
"tabs", newTabs);
174 QFile fo(pyControlFileName);
ExportProjectDialog(QWidget *parent=nullptr)
static const std::string s_zip_warning_file
QString gateLibraryFilename() const
void setGateLibraryFilename(const QString &gl)
static ProjectManager * instance()
static std::string sControlFileName
static QString sPythonRelDir
#define log_warning(channel,...)
QString absoluteFilePath(const QString &fileName) const const
QFileInfo fileInfo() const const
bool hasNext() const const
bool copy(const QString &newName)
void setAcceptMode(QFileDialog::AcceptMode mode)
void setDefaultSuffix(const QString &suffix)
void selectFile(const QString &filename)
QStringList selectedFiles() const const
void setLabelText(QFileDialog::DialogLabel label, const QString &text)
QString absoluteFilePath() const const
QString baseName() const const
QString fileName() const const
bool isAbsolute() const const
bool isFile() const const
void append(const QJsonValue &value)
QJsonValue at(int i) const const
QJsonDocument fromJson(const QByteArray &json, QJsonParseError *error)
QJsonObject object() const const
bool contains(const QString &key) const const
QJsonObject::iterator insert(const QString &key, const QJsonValue &value)
void remove(const QString &key)
QJsonObject toObject() const const
void append(const T &value)
const T & at(int i) const const
QString fromStdString(const std::string &str)
QString & remove(int position, int n)
QString & replace(int position, int n, QChar after)
QString simplified() const const
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const const
std::string toStdString() const const
bool isValid() const const
QString path() const const