From afd4aa5d1f4a0eca331f904f259d5b6316faddfe Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Sat, 13 Apr 2024 00:13:20 +0200 Subject: [PATCH] Update home path and fix wrong setting fix for scene and chapter count on welcome dialog --- novelwriter/core/buildsettings.py | 6 +++--- novelwriter/dialogs/wordlist.py | 4 ++-- novelwriter/tools/welcome.py | 7 +++---- tests/test_core/test_core_buildsettings.py | 11 ++++++----- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/novelwriter/core/buildsettings.py b/novelwriter/core/buildsettings.py index 3957ed27..b68dd97d 100644 --- a/novelwriter/core/buildsettings.py +++ b/novelwriter/core/buildsettings.py @@ -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 diff --git a/novelwriter/dialogs/wordlist.py b/novelwriter/dialogs/wordlist.py index c82ca3d6..54ec2f2f 100644 --- a/novelwriter/dialogs/wordlist.py +++ b/novelwriter/dialogs/wordlist.py @@ -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: diff --git a/novelwriter/tools/welcome.py b/novelwriter/tools/welcome.py index bff031ac..ce37539b 100644 --- a/novelwriter/tools/welcome.py +++ b/novelwriter/tools/welcome.py @@ -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() diff --git a/tests/test_core/test_core_buildsettings.py b/tests/test_core/test_core_buildsettings.py index bccccae1..10c63253 100644 --- a/tests/test_core/test_core_buildsettings.py +++ b/tests/test_core/test_core_buildsettings.py @@ -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