Fixed a few issues

This commit is contained in:
Veronica K. B. Olsen
2020-08-09 20:20:10 +02:00
parent 3c1e2727ad
commit 10067921f6
2 changed files with 26 additions and 9 deletions
+15
View File
@@ -190,6 +190,13 @@ class NWProject():
if popSample:
return self.extractSampleProject(projData)
# Set the project path
if "projPath" in projData:
self.setProjectPath(projData["projPath"], newProject=True)
else:
logger.error("No project path set for the new project")
return False
# Project Title and Authors
if "projName" in projData:
self.setProjectName(projData["projName"])
@@ -293,6 +300,7 @@ class NWProject():
isSuccess = False
if path.isfile(pkgSample):
self.setProjectPath(projPath, newProject=True)
try:
unpack_archive(pkgSample, projPath)
isSuccess = True
@@ -303,6 +311,7 @@ class NWProject():
elif path.isdir(srcSample):
self.setProjectPath(projPath, newProject=True)
try:
srcProj = path.join(srcSample, nwFiles.PROJ_FILE)
dstProj = path.join(projPath, nwFiles.PROJ_FILE)
@@ -322,6 +331,12 @@ class NWProject():
["Failed to create a new example project.", str(e)], nwAlert.ERROR
)
else:
self.makeAlert((
"Failed to create a new example project. "
"Could not find the necessary files."
), nwAlert.ERROR)
if isSuccess:
self.clearProject()
self.theParent.openProject(projPath)
+11 -9
View File
@@ -265,6 +265,7 @@ class GuiMain(QMainWindow):
def newProject(self, projPath=None, forceNew=False):
"""Create new project with a few default files and folders.
The variable forceNew is used for testing.
"""
if self.hasProject:
msgBox = QMessageBox()
@@ -277,6 +278,8 @@ class GuiMain(QMainWindow):
projData = {}
if projPath is None:
projData = self.newProjectDialog()
if projData is None:
return False
if "projPath" in projData:
projPath = projData["projPath"]
@@ -292,15 +295,11 @@ class GuiMain(QMainWindow):
return False
logger.info("Creating new project")
if self.theProject.setProjectPath(projPath, newProject=True):
if self.theProject.newProject(projData):
self.rebuildTree()
self.saveProject()
self.hasProject = True
self.statusBar.setRefTime(self.theProject.projOpened)
else:
self.theProject.clearProject()
return False
if self.theProject.newProject(projData):
self.rebuildTree()
self.saveProject()
self.hasProject = True
self.statusBar.setRefTime(self.theProject.projOpened)
else:
self.theProject.clearProject()
return False
@@ -780,6 +779,9 @@ class GuiMain(QMainWindow):
newProj = GuiProjectWizard(self)
newProj.exec_()
if newProj.result() == QDialog.Rejected:
return None
projData = {
"projName": newProj.field("projName"),
"projTitle": newProj.field("projTitle"),