Moved a few settings around in the project xml, but retaining compatibility

This commit is contained in:
Veronica K. B. Olsen
2020-06-05 20:58:14 +02:00
parent a051e77be0
commit 50630df705
2 changed files with 24 additions and 10 deletions
+19 -5
View File
@@ -331,6 +331,8 @@ class NWProject():
hexVersion = xRoot.attrib["hexVersion"] hexVersion = xRoot.attrib["hexVersion"]
if "fileVersion" in xRoot.attrib: if "fileVersion" in xRoot.attrib:
fileVersion = xRoot.attrib["fileVersion"] fileVersion = xRoot.attrib["fileVersion"]
# The following are deprecated and will be removed
if "saveCount" in xRoot.attrib: if "saveCount" in xRoot.attrib:
self.saveCount = checkInt(xRoot.attrib["saveCount"], 0, False) self.saveCount = checkInt(xRoot.attrib["saveCount"], 0, False)
if "autoCount" in xRoot.attrib: if "autoCount" in xRoot.attrib:
@@ -409,6 +411,14 @@ class NWProject():
elif xItem.tag == "author": elif xItem.tag == "author":
logger.verbose("Author: '%s'" % xItem.text) logger.verbose("Author: '%s'" % xItem.text)
self.bookAuthors.append(xItem.text) self.bookAuthors.append(xItem.text)
elif xItem.tag == "saveCount":
self.saveCount = checkInt(xItem.text, 0)
elif xItem.tag == "autoCount":
self.autoCount = checkInt(xItem.text, 0)
elif xItem.tag == "editTime":
self.editTime = checkInt(xItem.text, 0)
# The following is deprecated, and will be removed
elif xItem.tag == "backup": elif xItem.tag == "backup":
self.doBackup = checkBool(xItem.text, False) self.doBackup = checkBool(xItem.text, False)
@@ -417,7 +427,9 @@ class NWProject():
for xItem in xChild: for xItem in xChild:
if xItem.text is None: if xItem.text is None:
continue continue
if xItem.tag == "spellCheck": if xItem.tag == "doBackup":
self.doBackup = checkBool(xItem.text, False)
elif xItem.tag == "spellCheck":
self.spellCheck = checkBool(xItem.text, False) self.spellCheck = checkBool(xItem.text, False)
elif xItem.tag == "autoOutline": elif xItem.tag == "autoOutline":
self.autoOutline = checkBool(xItem.text, True) self.autoOutline = checkBool(xItem.text, True)
@@ -489,21 +501,23 @@ class NWProject():
"appVersion" : str(nw.__version__), "appVersion" : str(nw.__version__),
"hexVersion" : str(nw.__hexversion__), "hexVersion" : str(nw.__hexversion__),
"fileVersion" : "1.1", "fileVersion" : "1.1",
"saveCount" : str(self.saveCount),
"autoCount" : str(self.autoCount),
"timeStamp" : formatTimeStamp(saveTime), "timeStamp" : formatTimeStamp(saveTime),
"editTime" : str(int(self.editTime + saveTime - self.projOpened)),
}) })
editTime = int(self.editTime + saveTime - self.projOpened)
# Save Project Meta # Save Project Meta
xProject = etree.SubElement(nwXML, "project") xProject = etree.SubElement(nwXML, "project")
self._packProjectValue(xProject, "name", self.projName, True) self._packProjectValue(xProject, "name", self.projName, True)
self._packProjectValue(xProject, "title", self.bookTitle, True) self._packProjectValue(xProject, "title", self.bookTitle, True)
self._packProjectValue(xProject, "author", self.bookAuthors) self._packProjectValue(xProject, "author", self.bookAuthors)
self._packProjectValue(xProject, "backup", self.doBackup) self._packProjectValue(xProject, "saveCount", str(self.saveCount))
self._packProjectValue(xProject, "autoCount", str(self.autoCount))
self._packProjectValue(xProject, "editTime", str(editTime))
# Save Project Settings # Save Project Settings
xSettings = etree.SubElement(nwXML, "settings") xSettings = etree.SubElement(nwXML, "settings")
self._packProjectValue(xSettings, "doBackup", self.doBackup)
self._packProjectValue(xSettings, "spellCheck", self.spellCheck) self._packProjectValue(xSettings, "spellCheck", self.spellCheck)
self._packProjectValue(xSettings, "autoOutline", self.autoOutline) self._packProjectValue(xSettings, "autoOutline", self.autoOutline)
self._packProjectValue(xSettings, "lastEdited", self.lastEdited) self._packProjectValue(xSettings, "lastEdited", self.lastEdited)
+5 -5
View File
@@ -1,13 +1,16 @@
<?xml version='1.0' encoding='utf-8'?> <?xml version='1.0' encoding='utf-8'?>
<novelWriterXML appVersion="0.8.0rc1" hexVersion="0x000800c1" fileVersion="1.1" saveCount="270" autoCount="40" timeStamp="2020-06-04 19:14:21" editTime="4118"> <novelWriterXML appVersion="0.8.0rc1" hexVersion="0x000800c1" fileVersion="1.1" timeStamp="2020-06-05 20:53:20">
<project> <project>
<name>Sample Project</name> <name>Sample Project</name>
<title>Sample Project</title> <title>Sample Project</title>
<author>Jane Smith</author> <author>Jane Smith</author>
<author>Jay Doh</author> <author>Jay Doh</author>
<backup>False</backup> <saveCount>273</saveCount>
<autoCount>40</autoCount>
<editTime>4125</editTime>
</project> </project>
<settings> <settings>
<doBackup>False</doBackup>
<spellCheck>True</spellCheck> <spellCheck>True</spellCheck>
<autoOutline>True</autoOutline> <autoOutline>True</autoOutline>
<lastEdited>636b6aa9b697b</lastEdited> <lastEdited>636b6aa9b697b</lastEdited>
@@ -24,9 +27,6 @@
<unnumbered>%title%</unnumbered> <unnumbered>%title%</unnumbered>
<scene>Scene %ch%.%sc%: %title%</scene> <scene>Scene %ch%.%sc%: %title%</scene>
<section></section> <section></section>
<withSynopsis>True</withSynopsis>
<withComments>True</withComments>
<withKeywords>False</withKeywords>
</titleFormat> </titleFormat>
<status> <status>
<entry blue="100" green="100" red="100">New</entry> <entry blue="100" green="100" red="100">New</entry>