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:
|
||||
self._name = ""
|
||||
self._uuid = str(uuid.uuid4())
|
||||
self._path = Path.home()
|
||||
self._path = CONFIG.homePath()
|
||||
self._build = ""
|
||||
self._order = 0
|
||||
self._format = nwBuildFmt.ODT
|
||||
@@ -220,7 +220,7 @@ class BuildSettings:
|
||||
"""The last used build path."""
|
||||
if self._path.is_dir():
|
||||
return self._path
|
||||
return Path.home()
|
||||
return CONFIG.homePath()
|
||||
|
||||
@property
|
||||
def lastBuildName(self) -> str:
|
||||
@@ -297,7 +297,7 @@ class BuildSettings:
|
||||
if isinstance(path, Path) and path.is_dir():
|
||||
self._path = path
|
||||
else:
|
||||
self._path = Path.home()
|
||||
self._path = CONFIG.homePath()
|
||||
self._changed = True
|
||||
return
|
||||
|
||||
|
||||
@@ -190,7 +190,7 @@ class GuiWordList(QDialog):
|
||||
))
|
||||
ffilter = formatFileFilter(["*.txt", "*"])
|
||||
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:
|
||||
try:
|
||||
@@ -207,7 +207,7 @@ class GuiWordList(QDialog):
|
||||
def _exportWords(self) -> None:
|
||||
"""Export words to file."""
|
||||
path, _ = QFileDialog.getSaveFileName(
|
||||
self, self.tr("Export File"), str(Path.home())
|
||||
self, self.tr("Export File"), str(CONFIG.homePath())
|
||||
)
|
||||
if path:
|
||||
try:
|
||||
|
||||
@@ -560,7 +560,7 @@ class _NewProjectForm(QWidget):
|
||||
def __init__(self, parent: QWidget) -> None:
|
||||
super().__init__(parent=parent)
|
||||
|
||||
self._basePath = CONFIG.lastPath()
|
||||
self._basePath = CONFIG.homePath()
|
||||
self._fillMode = self.FILL_BLANK
|
||||
self._copyPath = None
|
||||
|
||||
@@ -638,11 +638,11 @@ class _NewProjectForm(QWidget):
|
||||
self.chapterBox = NWrappedWidgetBox(
|
||||
self.tr("Add {0} chapter documents"), self.numChapters
|
||||
)
|
||||
self.chapterBox.addStretch(0)
|
||||
self.chapterBox.addStretch(1)
|
||||
|
||||
self.numScenes = NSpinBox(self)
|
||||
self.numScenes.setRange(0, 200)
|
||||
self.numScenes.setValue(3)
|
||||
self.numScenes.setValue(0)
|
||||
|
||||
self.sceneBox = NWrappedWidgetBox(
|
||||
self.tr("Add {0} scene documents (to each chapter)"), self.numScenes
|
||||
@@ -742,7 +742,6 @@ class _NewProjectForm(QWidget):
|
||||
):
|
||||
self._basePath = Path(projDir)
|
||||
self._updateProjPath()
|
||||
CONFIG.setLastPath(self._basePath)
|
||||
return
|
||||
|
||||
@pyqtSlot()
|
||||
|
||||
@@ -27,6 +27,7 @@ import shutil
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from novelwriter import CONFIG
|
||||
from tools import C, buildTestProject
|
||||
from mocked import causeOSError
|
||||
|
||||
@@ -58,7 +59,7 @@ def testCoreBuildSettings_ClassAttributes(fncPath: Path):
|
||||
build.setName("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")
|
||||
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
|
||||
build.setLastPath("/path/to/nowhere")
|
||||
assert build.lastPath == Path.home()
|
||||
assert build.lastPath == CONFIG.homePath()
|
||||
|
||||
build.setLastPath(None)
|
||||
assert build.lastPath == Path.home()
|
||||
assert build.lastPath == CONFIG.homePath()
|
||||
|
||||
(fncPath / "test.txt").write_text("foobar")
|
||||
build.setLastPath(fncPath / "test.txt") # Can't be a file
|
||||
assert build.lastPath == Path.home()
|
||||
assert build.lastPath == CONFIG.homePath()
|
||||
|
||||
build.setLastPath(fncPath)
|
||||
assert build.lastPath == fncPath
|
||||
@@ -93,7 +94,7 @@ def testCoreBuildSettings_ClassAttributes(fncPath: Path):
|
||||
build.setLastPath(testDir)
|
||||
assert build.lastPath == testDir
|
||||
testDir.rmdir()
|
||||
assert build.lastPath == Path.home()
|
||||
assert build.lastPath == CONFIG.homePath()
|
||||
|
||||
# Last build name
|
||||
build.setLastBuildName(None) # type: ignore
|
||||
|
||||
Reference in New Issue
Block a user