Skip to content

Commit

Permalink
Display build details in Manuscript tool (#1516)
Browse files Browse the repository at this point in the history
  • Loading branch information
vkbo authored Sep 1, 2023
2 parents 746bd4b + 856e504 commit 3eb49d3
Show file tree
Hide file tree
Showing 6 changed files with 323 additions and 49 deletions.
60 changes: 44 additions & 16 deletions i18n/nw_base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1986,53 +1986,53 @@
<context>
<name>GuiManuscript</name>
<message>
<location filename="../novelwriter/tools/manuscript.py" line="80" />
<location filename="../novelwriter/tools/manuscript.py" line="82" />
<source>Build Manuscript</source>
<translation type="unfinished" />
</message>
<message>
<location filename="../novelwriter/tools/manuscript.py" line="110" />
<location filename="../novelwriter/tools/manuscript.py" line="112" />
<source>Add New Build</source>
<translation type="unfinished" />
</message>
<message>
<location filename="../novelwriter/tools/manuscript.py" line="117" />
<location filename="../novelwriter/tools/manuscript.py" line="119" />
<source>Delete Selected Build</source>
<translation type="unfinished" />
</message>
<message>
<location filename="../novelwriter/tools/manuscript.py" line="124" />
<location filename="../novelwriter/tools/manuscript.py" line="126" />
<source>Edit Selected Build</source>
<translation type="unfinished" />
</message>
<message>
<location filename="../novelwriter/tools/manuscript.py" line="128" />
<location filename="../novelwriter/tools/manuscript.py" line="130" />
<source>Builds</source>
<translation type="unfinished" />
</message>
<message>
<location filename="../novelwriter/tools/manuscript.py" line="145" />
<location filename="../novelwriter/tools/manuscript.py" line="164" />
<source>Preview</source>
<translation type="unfinished" />
</message>
<message>
<location filename="../novelwriter/tools/manuscript.py" line="148" />
<location filename="../novelwriter/tools/manuscript.py" line="167" />
<source>Print</source>
<translation type="unfinished" />
</message>
<message>
<location filename="../novelwriter/tools/manuscript.py" line="151" />
<location filename="../novelwriter/tools/manuscript.py" line="170" />
<source>Build</source>
<translation type="unfinished" />
</message>
<message>
<location filename="../novelwriter/tools/manuscript.py" line="154" />
<location filename="../novelwriter/tools/manuscript.py" line="173" />
<source>Close</source>
<translation type="unfinished" />
</message>
<message>
<location filename="../novelwriter/tools/manuscript.py" line="254" />
<location filename="../novelwriter/tools/manuscript.py" line="207" />
<location filename="../novelwriter/tools/manuscript.py" line="278" />
<location filename="../novelwriter/tools/manuscript.py" line="226" />
<source>My Manuscript</source>
<translation type="unfinished" />
</message>
Expand Down Expand Up @@ -4487,6 +4487,34 @@
<translation type="unfinished" />
</message>
</context>
<context>
<name>_DetailsWidget</name>
<message>
<location filename="../novelwriter/tools/manuscript.py" line="504" />
<source>Setting</source>
<translation type="unfinished" />
</message>
<message>
<location filename="../novelwriter/tools/manuscript.py" line="504" />
<source>Value</source>
<translation type="unfinished" />
</message>
<message>
<location filename="../novelwriter/tools/manuscript.py" line="573" />
<source>Name</source>
<translation type="unfinished" />
</message>
<message>
<location filename="../novelwriter/tools/manuscript.py" line="579" />
<source>Selection</source>
<translation type="unfinished" />
</message>
<message>
<location filename="../novelwriter/tools/manuscript.py" line="595" />
<source>Title</source>
<translation type="unfinished" />
</message>
</context>
<context>
<name>_FilterTab</name>
<message>
Expand Down Expand Up @@ -4625,27 +4653,27 @@
<context>
<name>_PreviewWidget</name>
<message>
<location filename="../novelwriter/tools/manuscript.py" line="467" />
<location filename="../novelwriter/tools/manuscript.py" line="659" />
<source>Press the "Build Preview" button to generate ...</source>
<translation type="unfinished" />
</message>
<message>
<location filename="../novelwriter/tools/manuscript.py" line="565" />
<location filename="../novelwriter/tools/manuscript.py" line="757" />
<source>Processing ...</source>
<translation type="unfinished" />
</message>
<message>
<location filename="../novelwriter/tools/manuscript.py" line="594" />
<location filename="../novelwriter/tools/manuscript.py" line="786" />
<source>Done</source>
<translation type="unfinished" />
</message>
<message>
<location filename="../novelwriter/tools/manuscript.py" line="637" />
<location filename="../novelwriter/tools/manuscript.py" line="829" />
<source>Unknown</source>
<translation type="unfinished" />
</message>
<message>
<location filename="../novelwriter/tools/manuscript.py" line="638" />
<location filename="../novelwriter/tools/manuscript.py" line="830" />
<source>Built</source>
<translation type="unfinished" />
</message>
Expand Down
55 changes: 50 additions & 5 deletions novelwriter/core/buildsettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,6 @@ def setValue(self, key: str, value: str | int | bool | float) -> bool:
value = min(max(value, definition[2]), definition[3])
self._changed = value != self._settings[key]
self._settings[key] = value
logger.debug(f"Build Setting '{key}' set to: {value}")
return True

##
Expand Down Expand Up @@ -457,6 +456,8 @@ class BuildCollection:
def __init__(self, project: NWProject) -> None:
self._project = project
self._builds = {}
self._lastBuild = ""
self._defaultBuild = ""
self._loadCollection()
return

Expand All @@ -465,7 +466,21 @@ def __len__(self) -> int:
return len(self._builds)

##
# Methods
# Properties
##

@property
def lastBuild(self) -> str:
"""Return the last active build."""
return self._lastBuild

@property
def defaultBuild(self) -> str:
"""Return the default build."""
return self._defaultBuild

##
# Getters
##

def getBuild(self, buildID: str) -> BuildSettings | None:
Expand All @@ -476,6 +491,24 @@ def getBuild(self, buildID: str) -> BuildSettings | None:
build.unpack(self._builds[buildID])
return build

##
# Setters
##

def setLastBuild(self, buildID: str) -> None:
"""Set the last active build id."""
if buildID != self._lastBuild:
self._lastBuild = buildID
self._saveCollection()
return

def setDefaultBuild(self, buildID: str) -> None:
"""Set the default build id."""
if buildID != self._defaultBuild:
self._defaultBuild = buildID
self._saveCollection()
return

def setBuild(self, build: BuildSettings) -> None:
"""Set build settings data in the collection."""
if isinstance(build, BuildSettings):
Expand All @@ -484,6 +517,10 @@ def setBuild(self, build: BuildSettings) -> None:
self._saveCollection()
return

##
# Methods
##

def removeBuild(self, buildID: str) -> None:
"""Remove the a build from the collection."""
self._builds.pop(buildID, None)
Expand Down Expand Up @@ -527,7 +564,11 @@ def _loadCollection(self) -> bool:
return False

for key, entry in builds.items():
if isinstance(entry, dict):
if key == "lastBuild":
self._lastBuild = str(entry)
elif key == "defaultBuild":
self._defaultBuild = str(entry)
elif isinstance(entry, dict):
self._builds[key] = entry

return True
Expand All @@ -540,9 +581,13 @@ def _saveCollection(self) -> bool:

logger.debug("Saving builds file")
try:
data = {"novelWriter.builds": self._builds}
data = {
"lastBuild": self._lastBuild,
"defaultBuild": self._defaultBuild,
}
data.update(self._builds)
with open(buildsFile, mode="w+", encoding="utf-8") as outFile:
outFile.write(jsonEncode(data, nmax=4))
outFile.write(jsonEncode({"novelWriter.builds": data}, nmax=4))
except Exception:
logger.error("Failed to save builds file")
logException()
Expand Down
7 changes: 4 additions & 3 deletions novelwriter/core/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,14 @@
"GuiWordList": {"winWidth", "winHeight"},
"GuiNovelView": {"lastCol", "lastColSize"},
"GuiBuildSettings": {
"winWidth", "winHeight", "treeWidth", "filterWidth"
"winWidth", "winHeight", "treeWidth", "filterWidth",
},
"GuiManuscript": {
"winWidth", "winHeight", "optsWidth", "viewWidth"
"winWidth", "winHeight", "optsWidth", "viewWidth", "listHeight",
"detailsHeight", "detailsWidth", "detailsExpanded",
},
"GuiManuscriptBuild": {
"winWidth", "winHeight", "fmtWidth", "sumWidth"
"winWidth", "winHeight", "fmtWidth", "sumWidth",
},
}

Expand Down
2 changes: 1 addition & 1 deletion novelwriter/core/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ def _loadProjectLocalisation(self) -> bool:
self._langData = json.load(inFile)
logger.debug("Loaded project language file: %s", langFile.name)
except Exception:
logger.error("Failed to project language file")
logger.error("Failed to load project language file")
logException()
return False

Expand Down
Loading

0 comments on commit 3eb49d3

Please sign in to comment.