Update home path and fix wrong setting fix for scene and chapter count on welcome dialog
This commit is contained in:
@@ -178,7 +178,7 @@ class BuildSettings:
|
|||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
self._name = ""
|
self._name = ""
|
||||||
self._uuid = str(uuid.uuid4())
|
self._uuid = str(uuid.uuid4())
|
||||||
self._path = Path.home()
|
self._path = CONFIG.homePath()
|
||||||
self._build = ""
|
self._build = ""
|
||||||
self._order = 0
|
self._order = 0
|
||||||
self._format = nwBuildFmt.ODT
|
self._format = nwBuildFmt.ODT
|
||||||
@@ -220,7 +220,7 @@ class BuildSettings:
|
|||||||
"""The last used build path."""
|
"""The last used build path."""
|
||||||
if self._path.is_dir():
|
if self._path.is_dir():
|
||||||
return self._path
|
return self._path
|
||||||
return Path.home()
|
return CONFIG.homePath()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def lastBuildName(self) -> str:
|
def lastBuildName(self) -> str:
|
||||||
@@ -297,7 +297,7 @@ class BuildSettings:
|
|||||||
if isinstance(path, Path) and path.is_dir():
|
if isinstance(path, Path) and path.is_dir():
|
||||||
self._path = path
|
self._path = path
|
||||||
else:
|
else:
|
||||||
self._path = Path.home()
|
self._path = CONFIG.homePath()
|
||||||
self._changed = True
|
self._changed = True
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ class GuiWordList(QDialog):
|
|||||||
))
|
))
|
||||||
ffilter = formatFileFilter(["*.txt", "*"])
|
ffilter = formatFileFilter(["*.txt", "*"])
|
||||||
path, _ = QFileDialog.getOpenFileName(
|
path, _ = QFileDialog.getOpenFileName(
|
||||||
self, self.tr("Import File"), str(Path.home()), filter=ffilter
|
self, self.tr("Import File"), str(CONFIG.homePath()), filter=ffilter
|
||||||
)
|
)
|
||||||
if path:
|
if path:
|
||||||
try:
|
try:
|
||||||
@@ -207,7 +207,7 @@ class GuiWordList(QDialog):
|
|||||||
def _exportWords(self) -> None:
|
def _exportWords(self) -> None:
|
||||||
"""Export words to file."""
|
"""Export words to file."""
|
||||||
path, _ = QFileDialog.getSaveFileName(
|
path, _ = QFileDialog.getSaveFileName(
|
||||||
self, self.tr("Export File"), str(Path.home())
|
self, self.tr("Export File"), str(CONFIG.homePath())
|
||||||
)
|
)
|
||||||
if path:
|
if path:
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -560,7 +560,7 @@ class _NewProjectForm(QWidget):
|
|||||||
def __init__(self, parent: QWidget) -> None:
|
def __init__(self, parent: QWidget) -> None:
|
||||||
super().__init__(parent=parent)
|
super().__init__(parent=parent)
|
||||||
|
|
||||||
self._basePath = CONFIG.lastPath()
|
self._basePath = CONFIG.homePath()
|
||||||
self._fillMode = self.FILL_BLANK
|
self._fillMode = self.FILL_BLANK
|
||||||
self._copyPath = None
|
self._copyPath = None
|
||||||
|
|
||||||
@@ -638,11 +638,11 @@ class _NewProjectForm(QWidget):
|
|||||||
self.chapterBox = NWrappedWidgetBox(
|
self.chapterBox = NWrappedWidgetBox(
|
||||||
self.tr("Add {0} chapter documents"), self.numChapters
|
self.tr("Add {0} chapter documents"), self.numChapters
|
||||||
)
|
)
|
||||||
self.chapterBox.addStretch(0)
|
self.chapterBox.addStretch(1)
|
||||||
|
|
||||||
self.numScenes = NSpinBox(self)
|
self.numScenes = NSpinBox(self)
|
||||||
self.numScenes.setRange(0, 200)
|
self.numScenes.setRange(0, 200)
|
||||||
self.numScenes.setValue(3)
|
self.numScenes.setValue(0)
|
||||||
|
|
||||||
self.sceneBox = NWrappedWidgetBox(
|
self.sceneBox = NWrappedWidgetBox(
|
||||||
self.tr("Add {0} scene documents (to each chapter)"), self.numScenes
|
self.tr("Add {0} scene documents (to each chapter)"), self.numScenes
|
||||||
@@ -742,7 +742,6 @@ class _NewProjectForm(QWidget):
|
|||||||
):
|
):
|
||||||
self._basePath = Path(projDir)
|
self._basePath = Path(projDir)
|
||||||
self._updateProjPath()
|
self._updateProjPath()
|
||||||
CONFIG.setLastPath(self._basePath)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import shutil
|
|||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
from novelwriter import CONFIG
|
||||||
from tools import C, buildTestProject
|
from tools import C, buildTestProject
|
||||||
from mocked import causeOSError
|
from mocked import causeOSError
|
||||||
|
|
||||||
@@ -58,7 +59,7 @@ def testCoreBuildSettings_ClassAttributes(fncPath: Path):
|
|||||||
build.setName("Test Build")
|
build.setName("Test Build")
|
||||||
assert build.name == "Test Build"
|
assert build.name == "Test Build"
|
||||||
|
|
||||||
# Only valid UUIDs are accpeted, anything else generates a new UUID
|
# Only valid UUIDs are accepted, anything else generates a new UUID
|
||||||
build.setBuildID("5cf45d24-f496-42c9-8733-529a9e52a62b")
|
build.setBuildID("5cf45d24-f496-42c9-8733-529a9e52a62b")
|
||||||
assert build.buildID == "5cf45d24-f496-42c9-8733-529a9e52a62b"
|
assert build.buildID == "5cf45d24-f496-42c9-8733-529a9e52a62b"
|
||||||
|
|
||||||
@@ -72,14 +73,14 @@ def testCoreBuildSettings_ClassAttributes(fncPath: Path):
|
|||||||
|
|
||||||
# Last path must be valid, if not it defaults to $HOME
|
# Last path must be valid, if not it defaults to $HOME
|
||||||
build.setLastPath("/path/to/nowhere")
|
build.setLastPath("/path/to/nowhere")
|
||||||
assert build.lastPath == Path.home()
|
assert build.lastPath == CONFIG.homePath()
|
||||||
|
|
||||||
build.setLastPath(None)
|
build.setLastPath(None)
|
||||||
assert build.lastPath == Path.home()
|
assert build.lastPath == CONFIG.homePath()
|
||||||
|
|
||||||
(fncPath / "test.txt").write_text("foobar")
|
(fncPath / "test.txt").write_text("foobar")
|
||||||
build.setLastPath(fncPath / "test.txt") # Can't be a file
|
build.setLastPath(fncPath / "test.txt") # Can't be a file
|
||||||
assert build.lastPath == Path.home()
|
assert build.lastPath == CONFIG.homePath()
|
||||||
|
|
||||||
build.setLastPath(fncPath)
|
build.setLastPath(fncPath)
|
||||||
assert build.lastPath == fncPath
|
assert build.lastPath == fncPath
|
||||||
@@ -93,7 +94,7 @@ def testCoreBuildSettings_ClassAttributes(fncPath: Path):
|
|||||||
build.setLastPath(testDir)
|
build.setLastPath(testDir)
|
||||||
assert build.lastPath == testDir
|
assert build.lastPath == testDir
|
||||||
testDir.rmdir()
|
testDir.rmdir()
|
||||||
assert build.lastPath == Path.home()
|
assert build.lastPath == CONFIG.homePath()
|
||||||
|
|
||||||
# Last build name
|
# Last build name
|
||||||
build.setLastBuildName(None) # type: ignore
|
build.setLastBuildName(None) # type: ignore
|
||||||
|
|||||||
Reference in New Issue
Block a user