Added title formatting settings to project file
This commit is contained in:
+31
-4
@@ -80,10 +80,9 @@ class NWProject():
|
|||||||
self.bookTitle = "" # The final title; should only be used for exports
|
self.bookTitle = "" # The final title; should only be used for exports
|
||||||
self.bookAuthors = [] # A list of book authors
|
self.bookAuthors = [] # A list of book authors
|
||||||
|
|
||||||
# Various
|
|
||||||
self.autoReplace = {} # Text to auto-replace on exports
|
|
||||||
|
|
||||||
# Project Settings
|
# Project Settings
|
||||||
|
self.autoReplace = {} # Text to auto-replace on exports
|
||||||
|
self.titleFormat = {} # The formatting of titles for exports
|
||||||
self.spellCheck = False # Controls the spellcheck-as-you-type feature
|
self.spellCheck = False # Controls the spellcheck-as-you-type feature
|
||||||
self.autoOutline = True # If true, the Project Outline is updated automatically
|
self.autoOutline = True # If true, the Project Outline is updated automatically
|
||||||
self.statusItems = None # Novel file progress status values
|
self.statusItems = None # Novel file progress status values
|
||||||
@@ -200,6 +199,15 @@ class NWProject():
|
|||||||
self.bookTitle = ""
|
self.bookTitle = ""
|
||||||
self.bookAuthors = []
|
self.bookAuthors = []
|
||||||
self.autoReplace = {}
|
self.autoReplace = {}
|
||||||
|
self.titleFormat = {
|
||||||
|
"title": "%title%",
|
||||||
|
"chapter": "Chapter %num%",
|
||||||
|
"chapterSub": "%title%",
|
||||||
|
"unnumbered": "%title%",
|
||||||
|
"scene": "",
|
||||||
|
"sceneSep": "* * *",
|
||||||
|
"section": "",
|
||||||
|
}
|
||||||
self.spellCheck = False
|
self.spellCheck = False
|
||||||
self.autoOutline = True
|
self.autoOutline = True
|
||||||
self.statusItems = NWStatus()
|
self.statusItems = NWStatus()
|
||||||
@@ -347,6 +355,11 @@ class NWProject():
|
|||||||
elif xItem.tag == "autoReplace":
|
elif xItem.tag == "autoReplace":
|
||||||
for xEntry in xItem:
|
for xEntry in xItem:
|
||||||
self.autoReplace[xEntry.tag] = checkString(xEntry.text, None, False)
|
self.autoReplace[xEntry.tag] = checkString(xEntry.text, None, False)
|
||||||
|
elif xItem.tag == "titleFormat":
|
||||||
|
titleFormat = self.titleFormat.copy()
|
||||||
|
for xEntry in xItem:
|
||||||
|
titleFormat[xEntry.tag] = checkString(xEntry.text, None, False)
|
||||||
|
self.setTitleFormat(titleFormat)
|
||||||
elif xChild.tag == "content":
|
elif xChild.tag == "content":
|
||||||
logger.debug("Found project content")
|
logger.debug("Found project content")
|
||||||
self.projTree.unpackXML(xChild)
|
self.projTree.unpackXML(xChild)
|
||||||
@@ -417,10 +430,16 @@ class NWProject():
|
|||||||
self._packProjectValue(xSettings, "lastEdited", self.lastEdited)
|
self._packProjectValue(xSettings, "lastEdited", self.lastEdited)
|
||||||
self._packProjectValue(xSettings, "lastViewed", self.lastViewed)
|
self._packProjectValue(xSettings, "lastViewed", self.lastViewed)
|
||||||
self._packProjectValue(xSettings, "lastWordCount", self.currWCount)
|
self._packProjectValue(xSettings, "lastWordCount", self.currWCount)
|
||||||
|
|
||||||
xAutoRep = etree.SubElement(xSettings, "autoReplace")
|
xAutoRep = etree.SubElement(xSettings, "autoReplace")
|
||||||
for aKey, aValue in self.autoReplace.items():
|
for aKey, aValue in self.autoReplace.items():
|
||||||
if len(aKey) > 0:
|
if len(aKey) > 0:
|
||||||
self._packProjectValue(xAutoRep,aKey,aValue)
|
self._packProjectValue(xAutoRep, aKey, aValue)
|
||||||
|
|
||||||
|
xTitleFmt = etree.SubElement(xSettings, "titleFormat")
|
||||||
|
for aKey, aValue in self.titleFormat.items():
|
||||||
|
if len(aKey) > 0:
|
||||||
|
self._packProjectValue(xTitleFmt, aKey, aValue)
|
||||||
|
|
||||||
xStatus = etree.SubElement(xSettings,"status")
|
xStatus = etree.SubElement(xSettings,"status")
|
||||||
self.statusItems.packEntries(xStatus)
|
self.statusItems.packEntries(xStatus)
|
||||||
@@ -695,6 +714,14 @@ class NWProject():
|
|||||||
self.autoReplace = autoReplace
|
self.autoReplace = autoReplace
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def setTitleFormat(self, titleFormat):
|
||||||
|
"""Set the formatting of titles in the project.
|
||||||
|
"""
|
||||||
|
for valKey in titleFormat:
|
||||||
|
if valKey in self.titleFormat:
|
||||||
|
self.titleFormat[valKey] = titleFormat[valKey]
|
||||||
|
return
|
||||||
|
|
||||||
def setProjectChanged(self, bValue):
|
def setProjectChanged(self, bValue):
|
||||||
"""Toggle the project changed flag, and propagate the
|
"""Toggle the project changed flag, and propagate the
|
||||||
information to the GUI statusbar.
|
information to the GUI statusbar.
|
||||||
|
|||||||
Reference in New Issue
Block a user