8 #include <QTemporaryDir>
10 #include <QDirIterator>
12 #include <JlCompress.h>
13 #include <QJsonObject>
15 #include <QJsonDocument>
29 selectFile(
"hal_project_" + mProjectName +
".zip");
42 log_warning(
"gui",
"Failed to create temporary project export directory '{}'.", projTargetDir.
toStdString());
64 log_warning(
"gui",
"Project export found file '{}' not in project folder '{}'.",
68 dirsToCreate.
append(relPath);
72 filesToCopy.
append(relPath);
75 log_warning(
"gui",
"Project export ignored directory entry '{}' with unknown type.", relPath.
toStdString());
79 for (
QString dir : dirsToCreate)
82 if (!
QDir().mkpath(fullpath))
83 log_warning(
"gui",
"Failed to create directory '{}' in project export folder.", dir.toStdString());
87 for (
const QString& s : filesToCopy)
93 log_warning(
"gui",
"Failed to copy file '{}' into project export folder.", s.toStdString());
94 if (s ==
".project.json" || s.endsWith(
".hal") || s.endsWith(
".hgl"))
104 ProjectJson projFile(
QDir(projTargetDir).absoluteFilePath(
".project.json"));
114 copyExternalPython(projTargetDir);
116 if (JlCompress::compressDir( archiveFilename, tempDir.
path(),
true,
QDir::Hidden ))
125 void ExportProjectDialog::copyExternalPython(
const QString &projTempDir)
137 if (!obj.
contains(
"tabs") || !obj[
"tabs"].isArray())
return;
139 int replaceCount = 0;
144 int ntabs = oldTabs.
size();
145 for (
int itab = 0; itab < ntabs; itab++)
148 if (!tab.
contains(
"filename"))
continue;
149 QString absFilename = tab[
"filename"].toString();
160 tab.
insert(
"filename", relFilename);
169 obj.
insert(
"tabs", newTabs);
171 QFile fo(pyControlFileName);
ExportProjectDialog(QWidget *parent=nullptr)
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