[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kile] src/dialogs: Remove freshly created directory after aborting the new project dialog
From: Michel Ludwig <michel.ludwig () kdemail ! net>
Date: 2015-12-31 17:24:18
Message-ID: E1aEgxW-000755-H4 () scm ! kde ! org
[Download RAW message or body]
Git commit 5d1a7ef5b8e32a6259abd20f5fb26b3363c219b7 by Michel Ludwig.
Committed on 31/12/2015 at 17:22.
Pushed by mludwig into branch 'master'.
Remove freshly created directory after aborting the new project dialog
Initial patch by Mateusz Krawiec (committed in 2.1 as \
a38870eee771b71a09ffa600ee34bff42a338afc).
REVIEW: 126259
M +22 -20 src/dialogs/projectdialogs.cpp
http://commits.kde.org/kile/5d1a7ef5b8e32a6259abd20f5fb26b3363c219b7
diff --git a/src/dialogs/projectdialogs.cpp b/src/dialogs/projectdialogs.cpp
index 4ec1c28..843f536 100644
--- a/src/dialogs/projectdialogs.cpp
+++ b/src/dialogs/projectdialogs.cpp
@@ -320,7 +320,7 @@ void KileNewProjectDialog::onAccepted()
if (projectTitle().trimmed().isEmpty()) {
if (KMessageBox::warningYesNo(this, i18n("You have not entered a project name. If \
you decide to proceed, the project name will be set to \
\"Untitled\".\n"
- "Do you want to create the project nevertheless?"), i18n("No Project \
Name Given")) == KMessageBox::Yes) { + "Do \
you want to create the project nevertheless?"), i18n("No Project Name Given")) == \
KMessageBox::Yes) { m_title->setText(i18n("Untitled"));
}
else {
@@ -328,46 +328,48 @@ void KileNewProjectDialog::onAccepted()
}
}
- if (folder().trimmed().isEmpty()){
+ const QString dirString = folder().trimmed();
+ const QString fileString = file().trimmed();
+
+ if (dirString.isEmpty()) {
KMessageBox::error(this, i18n("Please enter the folder where the project file \
should be saved to."), i18n("Empty Location")); return;
}
- const QString dirString = 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 project \
folder."), i18n("Invalid Location")); + return;
+ }
+
+ if (createNewFile() && fileString.isEmpty()){
+ KMessageBox::error(this, i18n("Please enter a filename for the file that should be \
added to this project."), i18n("No File Name Given")); return;
}
- QDir dir = QDir(dirString);
- KILE_DEBUG_MAIN << "project location is " << dir.absolutePath() << endl;
+ QDir dir(dirString);
- if(!dir.exists()){
+ if (!dir.exists()) {
dir.mkpath(dir.absolutePath());
}
- if(!dir.exists()){
- KMessageBox::error(this, i18n("Could not create the project folder, check your \
permissions.")); + if (!dir.exists()) {
+ KMessageBox::error(this, i18n("Could not create the project folder. Please 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, check your \
permissions.")); + KMessageBox::error(this, i18n("The project folder is not \
writable. Please check the permissions of the project folder.")); return;
}
+
const QString projectFilePath = dir.filePath(cleanProjectFile());
- if(QFileInfo(projectFilePath).exists()){
- KMessageBox::error(this, i18n("The project file already exists, please select \
another name. Delete the existing project file if 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 that 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)
QUrl fileURL;
fileURL = fileURL.adjusted(QUrl::RemoveFilename);
@@ -377,8 +379,8 @@ void KileNewProjectDialog::onAccepted()
m_file->setText(validURL.fileName());
}
- if(QFileInfo(QDir(fi.path()) , file().trimmed()).exists()){
- if (KMessageBox::warningYesNo(this, i18n("The file \"%1\" already exists, \
overwrite it?", file()), i18n("File Already Exists")) == KMessageBox::No) { \
+ if(QFileInfo(QDir(fi.path()), fileString).exists()){ + if \
(KMessageBox::warningYesNo(this, i18n("The file \"%1\" already exists, overwrite \
it?", fileString), i18n("File Already Exists")) == KMessageBox::No) { return;
}
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic