Ensure that all folders exist when a new project has been created, but also check that the project folder was empty
This commit is contained in:
+13
-1
@@ -179,6 +179,7 @@ class NWProject():
|
|||||||
hScene = self.newFile("New Scene", nwItemClass.NOVEL, hChapt)
|
hScene = self.newFile("New Scene", nwItemClass.NOVEL, hChapt)
|
||||||
self.projOpened = time()
|
self.projOpened = time()
|
||||||
self.setProjectChanged(True)
|
self.setProjectChanged(True)
|
||||||
|
self.saveProject(autoSave=True)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def clearProject(self):
|
def clearProject(self):
|
||||||
@@ -674,7 +675,7 @@ class NWProject():
|
|||||||
# Setters
|
# Setters
|
||||||
##
|
##
|
||||||
|
|
||||||
def setProjectPath(self, projPath):
|
def setProjectPath(self, projPath, newProject=False):
|
||||||
"""Set the project storage path, and also expand ~ to the user
|
"""Set the project storage path, and also expand ~ to the user
|
||||||
directory using the path library.
|
directory using the path library.
|
||||||
"""
|
"""
|
||||||
@@ -684,7 +685,18 @@ class NWProject():
|
|||||||
if projPath.startswith("~"):
|
if projPath.startswith("~"):
|
||||||
projPath = path.expanduser(projPath)
|
projPath = path.expanduser(projPath)
|
||||||
self.projPath = path.abspath(projPath)
|
self.projPath = path.abspath(projPath)
|
||||||
|
|
||||||
|
if newProject and self.mainConf.showGUI:
|
||||||
|
if listdir(self.projPath):
|
||||||
|
self.theParent.makeAlert((
|
||||||
|
"New project folder is not empty. "
|
||||||
|
"Each project requires a dedicated project folder."
|
||||||
|
), nwAlert.ERROR)
|
||||||
|
return False
|
||||||
|
|
||||||
|
self.ensureFolderStructure()
|
||||||
self.setProjectChanged(True)
|
self.setProjectChanged(True)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def setProjectName(self, projName):
|
def setProjectName(self, projName):
|
||||||
|
|||||||
+8
-6
@@ -294,12 +294,14 @@ class GuiMain(QMainWindow):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
logger.info("Creating new project")
|
logger.info("Creating new project")
|
||||||
self.theProject.newProject()
|
if self.theProject.setProjectPath(projPath, newProject=True):
|
||||||
self.theProject.setProjectPath(projPath)
|
self.theProject.newProject()
|
||||||
self.rebuildTree()
|
self.rebuildTree()
|
||||||
self.saveProject()
|
self.saveProject()
|
||||||
self.hasProject = True
|
self.hasProject = True
|
||||||
self.statusBar.setRefTime(self.theProject.projOpened)
|
self.statusBar.setRefTime(self.theProject.projOpened)
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user