Remove the old project wizard
This commit is contained in:
+1
-90
@@ -58,16 +58,13 @@ from novelwriter.dialogs.projdetails import GuiProjectDetails
|
||||
from novelwriter.dialogs.projsettings import GuiProjectSettings
|
||||
from novelwriter.tools.welcome import GuiWelcome
|
||||
from novelwriter.tools.manuscript import GuiManuscript
|
||||
from novelwriter.tools.projwizard import GuiProjectWizard
|
||||
from novelwriter.tools.dictionaries import GuiDictionaries
|
||||
from novelwriter.tools.writingstats import GuiWritingStats
|
||||
from novelwriter.core.coretools import ProjectBuilder
|
||||
|
||||
from novelwriter.enum import (
|
||||
nwDocAction, nwDocInsert, nwDocMode, nwItemType, nwItemClass, nwWidget, nwView
|
||||
nwDocAction, nwDocInsert, nwDocMode, nwItemType, nwWidget, nwView
|
||||
)
|
||||
from novelwriter.common import hexToInt
|
||||
from novelwriter.constants import nwFiles
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -373,42 +370,6 @@ class GuiMain(QMainWindow):
|
||||
# Project Actions
|
||||
##
|
||||
|
||||
def newProject(self, projData: dict | None = None) -> bool:
|
||||
"""Create a new project via the new project wizard."""
|
||||
if SHARED.hasProject:
|
||||
if not self.closeProject():
|
||||
SHARED.error(self.tr(
|
||||
"Cannot create a new project when another project is open."
|
||||
))
|
||||
return False
|
||||
|
||||
if projData is None:
|
||||
projData = self.showNewProjectDialog()
|
||||
|
||||
if projData is None:
|
||||
return False
|
||||
|
||||
projPath = projData.get("projPath", None)
|
||||
if projPath is None or projData is None:
|
||||
logger.error("No projData or projPath set")
|
||||
return False
|
||||
|
||||
if (Path(projPath) / nwFiles.PROJ_FILE).is_file():
|
||||
SHARED.error(self.tr(
|
||||
"A project already exists in that location. "
|
||||
"Please choose another folder."
|
||||
))
|
||||
return False
|
||||
|
||||
logger.info("Creating new project")
|
||||
nwProject = ProjectBuilder()
|
||||
if nwProject.buildProject(projData):
|
||||
self.openProject(projPath)
|
||||
else:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def closeProject(self, isYes: bool = False) -> bool:
|
||||
"""Close the project if one is open. isYes is passed on from the
|
||||
close application event so the user doesn't get prompted twice
|
||||
@@ -850,8 +811,6 @@ class GuiMain(QMainWindow):
|
||||
if dlgProj.result() == QDialog.Accepted:
|
||||
if dlgProj.openState == GuiProjectLoad.OPEN_STATE:
|
||||
self.openProject(dlgProj.openPath)
|
||||
elif dlgProj.openState == GuiProjectLoad.NEW_STATE:
|
||||
self.newProject()
|
||||
return
|
||||
|
||||
@pyqtSlot()
|
||||
@@ -862,16 +821,6 @@ class GuiMain(QMainWindow):
|
||||
dialog.exec_()
|
||||
return
|
||||
|
||||
def showNewProjectDialog(self) -> dict | None:
|
||||
"""Open the wizard and assemble a project options dict."""
|
||||
newProj = GuiProjectWizard(self)
|
||||
newProj.exec_()
|
||||
|
||||
if newProj.result() == QDialog.Accepted:
|
||||
return self._assembleProjectWizardData(newProj)
|
||||
|
||||
return None
|
||||
|
||||
@pyqtSlot()
|
||||
def showPreferencesDialog(self) -> None:
|
||||
"""Open the preferences dialog."""
|
||||
@@ -1472,44 +1421,6 @@ class GuiMain(QMainWindow):
|
||||
self.setWindowTitle(winTitle)
|
||||
return
|
||||
|
||||
def _assembleProjectWizardData(self, newProj: GuiProjectWizard) -> dict:
|
||||
"""Extract the user choices from the New Project Wizard and
|
||||
store them in a dictionary.
|
||||
"""
|
||||
projData = {
|
||||
"projName": newProj.field("projName"),
|
||||
"projTitle": newProj.field("projTitle"),
|
||||
"projAuthor": newProj.field("projAuthor"),
|
||||
"projPath": newProj.field("projPath"),
|
||||
"popSample": newProj.field("popSample"),
|
||||
"popMinimal": newProj.field("popMinimal"),
|
||||
"popCustom": newProj.field("popCustom"),
|
||||
"addRoots": [],
|
||||
"addNotes": False,
|
||||
"numChapters": 0,
|
||||
"numScenes": 0,
|
||||
}
|
||||
if newProj.field("popCustom"):
|
||||
addRoots = []
|
||||
if newProj.field("addPlot"):
|
||||
addRoots.append(nwItemClass.PLOT)
|
||||
if newProj.field("addChar"):
|
||||
addRoots.append(nwItemClass.CHARACTER)
|
||||
if newProj.field("addWorld"):
|
||||
addRoots.append(nwItemClass.WORLD)
|
||||
projData["addRoots"] = addRoots
|
||||
projData["addNotes"] = newProj.field("addNotes")
|
||||
projData["numChapters"] = newProj.field("numChapters")
|
||||
projData["numScenes"] = newProj.field("numScenes")
|
||||
|
||||
try:
|
||||
langIdx = newProj.field("projLang")
|
||||
projData["projLang"] = CONFIG.listLanguages(CONFIG.LANG_PROJ)[langIdx][0]
|
||||
except Exception:
|
||||
projData["projLang"] = "en_GB"
|
||||
|
||||
return projData
|
||||
|
||||
def _getTagSource(self, tag: str) -> tuple[str | None, str | None]:
|
||||
"""Handle the index lookup of a tag and display an alert if the
|
||||
tag cannot be found.
|
||||
|
||||
Reference in New Issue
Block a user