Git commit a38870eee771b71a09ffa600ee34bff42a338afc by Michel Ludwig. Committed on 31/12/2015 at 17:05. Pushed by mludwig into branch '2.1'. Remove freshly created directory after aborting the new project dialog Initial patch by Mateusz Krawiec. REVIEW: 126259 M +24 -22 src/dialogs/projectdialogs.cpp http://commits.kde.org/kile/a38870eee771b71a09ffa600ee34bff42a338afc diff --git a/src/dialogs/projectdialogs.cpp b/src/dialogs/projectdialogs.cpp index ddb38a1..799e158 100644 --- a/src/dialogs/projectdialogs.cpp +++ b/src/dialogs/projectdialogs.cpp @@ -348,57 +348,59 @@ void KileNewProjectDlg::slotButtonClicked(int button) return; } } + + const QString dirString =3D folder().trimmed(); + const QString fileString =3D file().trimmed(); = - if (folder().trimmed().isEmpty()){ + if (dirString.isEmpty()) { KMessageBox::error(this, i18n("Please enter the folder where the projec= t file should be saved to."), i18n("Empty Location")); return; } = - const QString dirString =3D folder().trimmed(); - if(!QDir::isAbsolutePath(dirString)) { - KMessageBox::error(this, i18n("Please enter an absolute (local) path to= the project folder."), i18n("Invalid Location")); + if (!QDir::isAbsolutePath(dirString)) { + KMessageBox::error(this, i18n("Please enter an absolute path to the pro= ject folder."), i18n("Invalid Location")); return; } = - QDir dir =3D QDir(dirString); - KILE_DEBUG() << "project location is " << dir.absolutePath() << endl; - = - if(!dir.exists()){ + if (createNewFile() && fileString.isEmpty()){ + KMessageBox::error(this, i18n("Please enter a filename for the file tha= t should be added to this project."), i18n("No File Name Given")); + return; + } + + QDir dir(dirString); + + if (!dir.exists()) { dir.mkpath(dir.absolutePath()); } - = - if(!dir.exists()){ - KMessageBox::error(this, i18n("Could not create the project folder, che= ck your permissions.")); + + if (!dir.exists()) { + KMessageBox::error(this, i18n("Could not create the project folder. Ple= ase check if you have write permission.")); return; } = QFileInfo fi(dir.absolutePath()); if (!fi.isDir() || !fi.isWritable()){ - KMessageBox::error(this, i18n("The project folder is not writable, chec= k your permissions.")); + KMessageBox::error(this, i18n("The project folder is not writable. Plea= se check the permissions of the project folder.")); return; } + const QString projectFilePath =3D dir.filePath(cleanProjectFile()); - if(QFileInfo(projectFilePath).exists()){ - KMessageBox::error(this, i18n("The project file alr= eady exists, please select another name. Delete the existing project file i= f your intention was to overwrite it."), i18n("Project File Already Exists"= )); + if (QFileInfo(projectFilePath).exists()) { // this can only happen when = the project dir existed already + KMessageBox::error(this, i18n("The project file already exists. Please = select another name."), i18n("Project File Already Exists")); return; } = if (createNewFile()) { - if (file().trimmed().isEmpty()){ - KMessageBox::error(this, i18n("Please enter a filename for the file th= at should be added to this project."), i18n("No File Name Given")); - return; - } - = //check for validity of name first, then check for existence (fixed by = tbraun) KUrl fileURL; - fileURL.setFileName(file()); + fileURL.setFileName(fileString); KUrl validURL =3D KileDocument::Info::makeValidTeXURL(fileURL, this, m_= extmanager->isTexFile(fileURL), true); if(validURL !=3D fileURL) { m_file->setText(validURL.fileName()); } = - if(QFileInfo(QDir(fi.path()) , file().trimmed()).exists()){ - if (KMessageBox::warningYesNo(this, i18n("The file \"%1\" already exis= ts, overwrite it?", file()), i18n("File Already Exists")) =3D=3D KMessageBo= x::No) { + if(QFileInfo(QDir(fi.path()), fileString).exists()){ + if (KMessageBox::warningYesNo(this, i18n("The file \"%1\" already exis= ts, overwrite it?", fileString), i18n("File Already Exists")) =3D=3D KMessa= geBox::No) { return; } }