[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kile/2.1] src/dialogs: Remove freshly created directory after aborting the new project dialog
From:       Michel Ludwig <michel.ludwig () kdemail ! net>
Date:       2015-12-31 17:07:02
Message-ID: E1aEggo-0000ND-FQ () scm ! kde ! org
[Download RAW message or body]

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 = folder().trimmed();
+		const QString fileString = file().trimmed();
 	
-		if (folder().trimmed().isEmpty()){
+		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;
 		}
 
-		QDir dir = 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 that 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, 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)
 			KUrl fileURL;
-			fileURL.setFileName(file());
+			fileURL.setFileName(fileString);
 			KUrl validURL = KileDocument::Info::makeValidTeXURL(fileURL, this, \
m_extmanager->isTexFile(fileURL), true);  if(validURL != fileURL) {
 				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