5 #include <QRegularExpression>
11 #include <QMessageBox>
12 #include <JlCompress.h>
16 :
QFrame(parent), mExistingDir(existingDir), mValid(false)
35 handleTextChanged(defaultEntry);
38 void FileSelectWidget::handleActivateFileDialog()
42 :
QFileDialog::getOpenFileName(this,
"Select file:", mEditor->text(),
"Zipped files (*.zip)");
46 void FileSelectWidget::handleTextChanged(
const QString &txt)
50 if (val == mValid)
return;
56 :
QDialog(parent), mStatus(NoImport)
75 mExtractProjectEdit =
new QLineEdit(
this);
84 handleSelectionStatusChanged();
87 void ImportProjectDialog::handleSelectionStatusChanged()
89 bool valid = mTargetDirectory->
valid() && mZippedFile->
valid();
94 int inx = zipFlist.
indexOf(reProj);
103 mTargetProjectName = match.
captured(1);
117 if (
QFileInfo(mExtractedProjectAbsolutePath).exists())
119 QMessageBox::warning(
this,
"Cannot Create Project",
"Direcotry " + mExtractedProjectAbsolutePath +
" already exists");
124 if (mExtractProjectEdit->
text() != mTargetProjectName)
128 extracted = JlCompress::extractDir(mZippedFile->
selection(),tempdir);
132 extracted = JlCompress::extractDir(mZippedFile->
selection(),mTargetDirectory->
selection());
135 if (extracted.
isEmpty())
return false;
139 extractedDir.
chop(1);
182 if (!
QFile::rename(extractedDir,mExtractedProjectAbsolutePath))
184 log_warning(
"gui",
"Failed to move decompressed archive to new location '{}'.", mExtractedProjectAbsolutePath.
toStdString());
190 deleteFilesRecursion(tempdir);
197 deleteFilesList(extracted);
204 void ImportProjectDialog::deleteFilesRecursion(
QString dir)
209 deleteFilesRecursion(finfo.absoluteFilePath());
219 auto it =
files.begin();
220 while (it !=
files.end())
226 it =
files.erase(it);
230 if (!
files.isEmpty())
236 if (it ==
files.begin())
Copyright The Montserrat Project in Original or Modified may be sold by itself Original or Modified Versions of the Font Software may be redistributed and or sold with any provided that each copy contains the above copyright notice and this license These can be included either as stand alone text files
static DirectoryStatus directoryStatus(const QString &pathname)
static QString suggestedProjectDir(const QString &filename)
ImportProjectDialog(QWidget *parent=nullptr)
#define log_warning(channel,...)
QIcon getStyledSvgIcon(const QString &from_to_colors_enabled, const QString &svg_path, QString from_to_colors_disabled=QString())
ushort unicode() const const
QString absoluteFilePath(const QString &fileName) const const
bool mkpath(const QString &dirPath) const const
bool rmdir(const QString &dirName) const const
bool rename(const QString &newName)
QString getExistingDirectory(QWidget *parent, const QString &caption, const QString &dir, QFileDialog::Options options)
bool exists() const const
void setFrameStyle(int style)
void setText(const QString &)
void textChanged(const QString &text)
const T & at(int i) const const
bool isEmpty() const const
QMessageBox::StandardButton warning(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton)
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QString captured(int nth) const const
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
bool isEmpty() const const
QString & remove(int position, int n)
std::string toStdString() const const
int indexOf(QStringView str, int from) const const