Fixed a few issues
This commit is contained in:
@@ -190,6 +190,13 @@ class NWProject():
|
|||||||
if popSample:
|
if popSample:
|
||||||
return self.extractSampleProject(projData)
|
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
|
# Project Title and Authors
|
||||||
if "projName" in projData:
|
if "projName" in projData:
|
||||||
self.setProjectName(projData["projName"])
|
self.setProjectName(projData["projName"])
|
||||||
@@ -293,6 +300,7 @@ class NWProject():
|
|||||||
isSuccess = False
|
isSuccess = False
|
||||||
if path.isfile(pkgSample):
|
if path.isfile(pkgSample):
|
||||||
|
|
||||||
|
self.setProjectPath(projPath, newProject=True)
|
||||||
try:
|
try:
|
||||||
unpack_archive(pkgSample, projPath)
|
unpack_archive(pkgSample, projPath)
|
||||||
isSuccess = True
|
isSuccess = True
|
||||||
@@ -303,6 +311,7 @@ class NWProject():
|
|||||||
|
|
||||||
elif path.isdir(srcSample):
|
elif path.isdir(srcSample):
|
||||||
|
|
||||||
|
self.setProjectPath(projPath, newProject=True)
|
||||||
try:
|
try:
|
||||||
srcProj = path.join(srcSample, nwFiles.PROJ_FILE)
|
srcProj = path.join(srcSample, nwFiles.PROJ_FILE)
|
||||||
dstProj = path.join(projPath, 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
|
["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:
|
if isSuccess:
|
||||||
self.clearProject()
|
self.clearProject()
|
||||||
self.theParent.openProject(projPath)
|
self.theParent.openProject(projPath)
|
||||||
|
|||||||
+11
-9
@@ -265,6 +265,7 @@ class GuiMain(QMainWindow):
|
|||||||
|
|
||||||
def newProject(self, projPath=None, forceNew=False):
|
def newProject(self, projPath=None, forceNew=False):
|
||||||
"""Create new project with a few default files and folders.
|
"""Create new project with a few default files and folders.
|
||||||
|
The variable forceNew is used for testing.
|
||||||
"""
|
"""
|
||||||
if self.hasProject:
|
if self.hasProject:
|
||||||
msgBox = QMessageBox()
|
msgBox = QMessageBox()
|
||||||
@@ -277,6 +278,8 @@ class GuiMain(QMainWindow):
|
|||||||
projData = {}
|
projData = {}
|
||||||
if projPath is None:
|
if projPath is None:
|
||||||
projData = self.newProjectDialog()
|
projData = self.newProjectDialog()
|
||||||
|
if projData is None:
|
||||||
|
return False
|
||||||
if "projPath" in projData:
|
if "projPath" in projData:
|
||||||
projPath = projData["projPath"]
|
projPath = projData["projPath"]
|
||||||
|
|
||||||
@@ -292,15 +295,11 @@ class GuiMain(QMainWindow):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
logger.info("Creating new project")
|
logger.info("Creating new project")
|
||||||
if self.theProject.setProjectPath(projPath, newProject=True):
|
if self.theProject.newProject(projData):
|
||||||
if self.theProject.newProject(projData):
|
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:
|
|
||||||
self.theProject.clearProject()
|
|
||||||
return False
|
|
||||||
else:
|
else:
|
||||||
self.theProject.clearProject()
|
self.theProject.clearProject()
|
||||||
return False
|
return False
|
||||||
@@ -780,6 +779,9 @@ class GuiMain(QMainWindow):
|
|||||||
newProj = GuiProjectWizard(self)
|
newProj = GuiProjectWizard(self)
|
||||||
newProj.exec_()
|
newProj.exec_()
|
||||||
|
|
||||||
|
if newProj.result() == QDialog.Rejected:
|
||||||
|
return None
|
||||||
|
|
||||||
projData = {
|
projData = {
|
||||||
"projName": newProj.field("projName"),
|
"projName": newProj.field("projName"),
|
||||||
"projTitle": newProj.field("projTitle"),
|
"projTitle": newProj.field("projTitle"),
|
||||||
|
|||||||
Reference in New Issue
Block a user