Rename title format settings to partition

This commit is contained in:
Veronica Berglyd Olsen
2024-10-01 12:14:39 +02:00
parent 57e739c3ef
commit 0f1401eb71
5 changed files with 57 additions and 57 deletions
+7 -7
View File
@@ -52,22 +52,22 @@ SETTINGS_TEMPLATE = {
"filter.includeNovel": (bool, True), "filter.includeNovel": (bool, True),
"filter.includeNotes": (bool, False), "filter.includeNotes": (bool, False),
"filter.includeInactive": (bool, False), "filter.includeInactive": (bool, False),
"headings.fmtTitle": (str, nwHeadFmt.TITLE), "headings.fmtPart": (str, nwHeadFmt.TITLE),
"headings.fmtChapter": (str, nwHeadFmt.TITLE), "headings.fmtChapter": (str, nwHeadFmt.TITLE),
"headings.fmtUnnumbered": (str, nwHeadFmt.TITLE), "headings.fmtUnnumbered": (str, nwHeadFmt.TITLE),
"headings.fmtScene": (str, "* * *"), "headings.fmtScene": (str, "* * *"),
"headings.fmtAltScene": (str, ""), "headings.fmtAltScene": (str, ""),
"headings.fmtSection": (str, ""), "headings.fmtSection": (str, ""),
"headings.hideTitle": (bool, False), "headings.hidePart": (bool, False),
"headings.hideChapter": (bool, False), "headings.hideChapter": (bool, False),
"headings.hideUnnumbered": (bool, False), "headings.hideUnnumbered": (bool, False),
"headings.hideScene": (bool, False), "headings.hideScene": (bool, False),
"headings.hideAltScene": (bool, False), "headings.hideAltScene": (bool, False),
"headings.hideSection": (bool, True), "headings.hideSection": (bool, True),
"headings.centerTitle": (bool, True), "headings.centerPart": (bool, True),
"headings.centerChapter": (bool, False), "headings.centerChapter": (bool, False),
"headings.centerScene": (bool, False), "headings.centerScene": (bool, False),
"headings.breakTitle": (bool, True), "headings.breakPart": (bool, True),
"headings.breakChapter": (bool, True), "headings.breakChapter": (bool, True),
"headings.breakScene": (bool, False), "headings.breakScene": (bool, False),
"text.includeSynopsis": (bool, False), "text.includeSynopsis": (bool, False),
@@ -108,7 +108,7 @@ SETTINGS_LABELS = {
"filter.includeInactive": QT_TRANSLATE_NOOP("Builds", "Inactive Documents"), "filter.includeInactive": QT_TRANSLATE_NOOP("Builds", "Inactive Documents"),
"headings": QT_TRANSLATE_NOOP("Builds", "Headings"), "headings": QT_TRANSLATE_NOOP("Builds", "Headings"),
"headings.fmtTitle": QT_TRANSLATE_NOOP("Builds", "Partition Format"), "headings.fmtPart": QT_TRANSLATE_NOOP("Builds", "Partition Format"),
"headings.fmtChapter": QT_TRANSLATE_NOOP("Builds", "Chapter Format"), "headings.fmtChapter": QT_TRANSLATE_NOOP("Builds", "Chapter Format"),
"headings.fmtUnnumbered": QT_TRANSLATE_NOOP("Builds", "Unnumbered Format"), "headings.fmtUnnumbered": QT_TRANSLATE_NOOP("Builds", "Unnumbered Format"),
"headings.fmtScene": QT_TRANSLATE_NOOP("Builds", "Scene Format"), "headings.fmtScene": QT_TRANSLATE_NOOP("Builds", "Scene Format"),
@@ -147,12 +147,12 @@ SETTINGS_LABELS = {
"format.leftMargin": QT_TRANSLATE_NOOP("Builds", "Left Margin"), "format.leftMargin": QT_TRANSLATE_NOOP("Builds", "Left Margin"),
"format.rightMargin": QT_TRANSLATE_NOOP("Builds", "Right Margin"), "format.rightMargin": QT_TRANSLATE_NOOP("Builds", "Right Margin"),
"odt": QT_TRANSLATE_NOOP("Builds", "ODT Documents"), "odt": QT_TRANSLATE_NOOP("Builds", "ODT Options"),
"odt.addColours": QT_TRANSLATE_NOOP("Builds", "Add Highlight Colours"), "odt.addColours": QT_TRANSLATE_NOOP("Builds", "Add Highlight Colours"),
"odt.pageHeader": QT_TRANSLATE_NOOP("Builds", "Page Header"), "odt.pageHeader": QT_TRANSLATE_NOOP("Builds", "Page Header"),
"odt.pageCountOffset": QT_TRANSLATE_NOOP("Builds", "Page Counter Offset"), "odt.pageCountOffset": QT_TRANSLATE_NOOP("Builds", "Page Counter Offset"),
"html": QT_TRANSLATE_NOOP("Builds", "HTML Document"), "html": QT_TRANSLATE_NOOP("Builds", "HTML Options"),
"html.addStyles": QT_TRANSLATE_NOOP("Builds", "Add CSS Styles"), "html.addStyles": QT_TRANSLATE_NOOP("Builds", "Add CSS Styles"),
"html.preserveTabs": QT_TRANSLATE_NOOP("Builds", "Preserve Tab Characters"), "html.preserveTabs": QT_TRANSLATE_NOOP("Builds", "Preserve Tab Characters"),
} }
+6 -6
View File
@@ -297,9 +297,9 @@ class NWBuildDocument:
textFont.fromString(self._build.getStr("format.textFont")) textFont.fromString(self._build.getStr("format.textFont"))
bldObj.setFont(textFont) bldObj.setFont(textFont)
bldObj.setTitleFormat( bldObj.setPartitionFormat(
self._build.getStr("headings.fmtTitle"), self._build.getStr("headings.fmtPart"),
self._build.getBool("headings.hideTitle") self._build.getBool("headings.hidePart")
) )
bldObj.setChapterFormat( bldObj.setChapterFormat(
self._build.getStr("headings.fmtChapter"), self._build.getStr("headings.fmtChapter"),
@@ -321,9 +321,9 @@ class NWBuildDocument:
self._build.getStr("headings.fmtSection"), self._build.getStr("headings.fmtSection"),
self._build.getBool("headings.hideSection") self._build.getBool("headings.hideSection")
) )
bldObj.setTitleStyle( bldObj.setPartitionStyle(
self._build.getBool("headings.centerTitle"), self._build.getBool("headings.centerPart"),
self._build.getBool("headings.breakTitle") self._build.getBool("headings.breakPart")
) )
bldObj.setChapterStyle( bldObj.setChapterStyle(
self._build.getBool("headings.centerChapter"), self._build.getBool("headings.centerChapter"),
+13 -13
View File
@@ -175,14 +175,14 @@ class Tokenizer(ABC):
self._marginSep = (1.168, 1.168) self._marginSep = (1.168, 1.168)
# Title Formats # Title Formats
self._fmtTitle = nwHeadFmt.TITLE # Formatting for titles self._fmtPart = nwHeadFmt.TITLE # Formatting for partitions
self._fmtChapter = nwHeadFmt.TITLE # Formatting for numbered chapters self._fmtChapter = nwHeadFmt.TITLE # Formatting for numbered chapters
self._fmtUnNum = nwHeadFmt.TITLE # Formatting for unnumbered chapters self._fmtUnNum = nwHeadFmt.TITLE # Formatting for unnumbered chapters
self._fmtScene = nwHeadFmt.TITLE # Formatting for scenes self._fmtScene = nwHeadFmt.TITLE # Formatting for scenes
self._fmtHScene = nwHeadFmt.TITLE # Formatting for hard scenes self._fmtHScene = nwHeadFmt.TITLE # Formatting for hard scenes
self._fmtSection = nwHeadFmt.TITLE # Formatting for sections self._fmtSection = nwHeadFmt.TITLE # Formatting for sections
self._hideTitle = False # Do not include title headings self._hidePart = False # Do not include partition headings
self._hideChapter = False # Do not include chapter headings self._hideChapter = False # Do not include chapter headings
self._hideUnNum = False # Do not include unnumbered headings self._hideUnNum = False # Do not include unnumbered headings
self._hideScene = False # Do not include scene headings self._hideScene = False # Do not include scene headings
@@ -191,7 +191,7 @@ class Tokenizer(ABC):
self._linkHeadings = False # Add an anchor before headings self._linkHeadings = False # Add an anchor before headings
self._titleStyle = self.A_CENTRE | self.A_PBB self._partStyle = self.A_CENTRE | self.A_PBB
self._chapterStyle = self.A_PBB self._chapterStyle = self.A_PBB
self._sceneStyle = self.A_NONE self._sceneStyle = self.A_NONE
@@ -271,10 +271,10 @@ class Tokenizer(ABC):
# Setters # Setters
## ##
def setTitleFormat(self, hFormat: str, hide: bool = False) -> None: def setPartitionFormat(self, hFormat: str, hide: bool = False) -> None:
"""Set the title format pattern.""" """Set the partition format pattern."""
self._fmtTitle = hFormat.strip() self._fmtPart = hFormat.strip()
self._hideTitle = hide self._hidePart = hide
return return
def setChapterFormat(self, hFormat: str, hide: bool = False) -> None: def setChapterFormat(self, hFormat: str, hide: bool = False) -> None:
@@ -307,9 +307,9 @@ class Tokenizer(ABC):
self._hideSection = hide self._hideSection = hide
return return
def setTitleStyle(self, center: bool, pageBreak: bool) -> None: def setPartitionStyle(self, center: bool, pageBreak: bool) -> None:
"""Set the title heading style.""" """Set the partition heading style."""
self._titleStyle = ( self._partStyle = (
(self.A_CENTRE if center else self.A_NONE) | (self.A_PBB if pageBreak else self.A_NONE) (self.A_CENTRE if center else self.A_NONE) | (self.A_PBB if pageBreak else self.A_NONE)
) )
return return
@@ -664,15 +664,15 @@ class Tokenizer(ABC):
tText = aLine[2:].strip() tText = aLine[2:].strip()
tType = self.T_HEAD1 if isPlain else self.T_TITLE tType = self.T_HEAD1 if isPlain else self.T_TITLE
tStyle = self.A_NONE if isPlain else (self.A_PBB | self.A_CENTRE) tStyle = self.A_NONE if isPlain else (self.A_PBB | self.A_CENTRE)
sHide = self._hideTitle if isPlain else False sHide = self._hidePart if isPlain else False
if self._isNovel: if self._isNovel:
if sHide: if sHide:
tText = "" tText = ""
tType = self.T_EMPTY tType = self.T_EMPTY
tStyle = self.A_NONE tStyle = self.A_NONE
elif isPlain: elif isPlain:
tText = self._hFormatter.apply(self._fmtTitle, tText, nHead) tText = self._hFormatter.apply(self._fmtPart, tText, nHead)
tStyle = self._titleStyle tStyle = self._partStyle
if isPlain: if isPlain:
self._hFormatter.resetScene() self._hFormatter.resetScene()
else: else:
+1 -1
View File
@@ -593,7 +593,7 @@ class _DetailsWidget(QWidget):
item.setText(1, "") item.setText(1, "")
self.listView.addTopLevelItem(item) self.listView.addTopLevelItem(item)
for hFormat, hHide in [ for hFormat, hHide in [
("headings.fmtTitle", "headings.hideTitle"), ("headings.fmtPart", "headings.hidePart"),
("headings.fmtChapter", "headings.hideChapter"), ("headings.fmtChapter", "headings.hideChapter"),
("headings.fmtUnnumbered", "headings.hideUnnumbered"), ("headings.fmtUnnumbered", "headings.hideUnnumbered"),
("headings.fmtScene", "headings.hideScene"), ("headings.fmtScene", "headings.hideScene"),
+30 -30
View File
@@ -585,20 +585,20 @@ class _HeadingsTab(NScrollablePage):
self.formatBox.setHorizontalSpacing(bSp) self.formatBox.setHorizontalSpacing(bSp)
# Title Heading # Title Heading
self.lblTitle = QLabel(self._build.getLabel("headings.fmtTitle"), self) self.lblPart = QLabel(self._build.getLabel("headings.fmtPart"), self)
self.fmtTitle = QLineEdit("", self) self.fmtPart = QLineEdit("", self)
self.fmtTitle.setReadOnly(True) self.fmtPart.setReadOnly(True)
self.btnTitle = NIconToolButton(self, iSz, "edit") self.btnPart = NIconToolButton(self, iSz, "edit")
self.btnTitle.clicked.connect(lambda: self._editHeading(self.EDIT_TITLE)) self.btnPart.clicked.connect(lambda: self._editHeading(self.EDIT_TITLE))
self.hdeTitle = QLabel(trHide, self) self.hdePart = QLabel(trHide, self)
self.hdeTitle.setIndent(bSp) self.hdePart.setIndent(bSp)
self.swtTitle = NSwitch(self, height=iPx) self.swtPart = NSwitch(self, height=iPx)
self.formatBox.addWidget(self.lblTitle, 0, 0) self.formatBox.addWidget(self.lblPart, 0, 0)
self.formatBox.addWidget(self.fmtTitle, 0, 1) self.formatBox.addWidget(self.fmtPart, 0, 1)
self.formatBox.addWidget(self.btnTitle, 0, 2) self.formatBox.addWidget(self.btnPart, 0, 2)
self.formatBox.addWidget(self.hdeTitle, 0, 3) self.formatBox.addWidget(self.hdePart, 0, 3)
self.formatBox.addWidget(self.swtTitle, 0, 4) self.formatBox.addWidget(self.swtPart, 0, 4)
# Chapter Heading # Chapter Heading
self.lblChapter = QLabel(self._build.getLabel("headings.fmtChapter"), self) self.lblChapter = QLabel(self._build.getLabel("headings.fmtChapter"), self)
@@ -738,10 +738,10 @@ class _HeadingsTab(NScrollablePage):
self.layoutHeading = QLabel("<b>{0}</b>".format(self.tr("Additional Styling")), self) self.layoutHeading = QLabel("<b>{0}</b>".format(self.tr("Additional Styling")), self)
self.layoutMatrix.addWidget(self.layoutHeading, 0, 0, 1, 5) self.layoutMatrix.addWidget(self.layoutHeading, 0, 0, 1, 5)
# Title Layout # Partition Layout
self.mtxTitle = QLabel(self._build.getLabel("headings.fmtTitle"), self) self.mtxTitle = QLabel(self._build.getLabel("headings.fmtPart"), self)
self.centerTitle = NSwitch(self, height=iPx) self.centerPart = NSwitch(self, height=iPx)
self.breakTitle = NSwitch(self, height=iPx) self.breakPart = NSwitch(self, height=iPx)
lblCenterT = QLabel(self.tr("Centre"), self) lblCenterT = QLabel(self.tr("Centre"), self)
lblCenterT.setIndent(sSp) lblCenterT.setIndent(sSp)
lblBreakT = QLabel(self.tr("Page Break"), self) lblBreakT = QLabel(self.tr("Page Break"), self)
@@ -749,9 +749,9 @@ class _HeadingsTab(NScrollablePage):
self.layoutMatrix.addWidget(self.mtxTitle, 1, 0) self.layoutMatrix.addWidget(self.mtxTitle, 1, 0)
self.layoutMatrix.addWidget(lblCenterT, 1, 1) self.layoutMatrix.addWidget(lblCenterT, 1, 1)
self.layoutMatrix.addWidget(self.centerTitle, 1, 2) self.layoutMatrix.addWidget(self.centerPart, 1, 2)
self.layoutMatrix.addWidget(lblBreakT, 1, 3) self.layoutMatrix.addWidget(lblBreakT, 1, 3)
self.layoutMatrix.addWidget(self.breakTitle, 1, 4) self.layoutMatrix.addWidget(self.breakPart, 1, 4)
# Chapter Layout # Chapter Layout
self.mtxChapter = QLabel(self._build.getLabel("headings.fmtChapter"), self) self.mtxChapter = QLabel(self._build.getLabel("headings.fmtChapter"), self)
@@ -802,41 +802,41 @@ class _HeadingsTab(NScrollablePage):
def loadContent(self) -> None: def loadContent(self) -> None:
"""Populate the widgets.""" """Populate the widgets."""
self.fmtTitle.setText(self._build.getStr("headings.fmtTitle")) self.fmtPart.setText(self._build.getStr("headings.fmtPart"))
self.fmtChapter.setText(self._build.getStr("headings.fmtChapter")) self.fmtChapter.setText(self._build.getStr("headings.fmtChapter"))
self.fmtUnnumbered.setText(self._build.getStr("headings.fmtUnnumbered")) self.fmtUnnumbered.setText(self._build.getStr("headings.fmtUnnumbered"))
self.fmtScene.setText(self._build.getStr("headings.fmtScene")) self.fmtScene.setText(self._build.getStr("headings.fmtScene"))
self.fmtAScene.setText(self._build.getStr("headings.fmtAltScene")) self.fmtAScene.setText(self._build.getStr("headings.fmtAltScene"))
self.fmtSection.setText(self._build.getStr("headings.fmtSection")) self.fmtSection.setText(self._build.getStr("headings.fmtSection"))
self.swtTitle.setChecked(self._build.getBool("headings.hideTitle")) self.swtPart.setChecked(self._build.getBool("headings.hidePart"))
self.swtChapter.setChecked(self._build.getBool("headings.hideChapter")) self.swtChapter.setChecked(self._build.getBool("headings.hideChapter"))
self.swtUnnumbered.setChecked(self._build.getBool("headings.hideUnnumbered")) self.swtUnnumbered.setChecked(self._build.getBool("headings.hideUnnumbered"))
self.swtScene.setChecked(self._build.getBool("headings.hideScene")) self.swtScene.setChecked(self._build.getBool("headings.hideScene"))
self.swtAScene.setChecked(self._build.getBool("headings.hideAltScene")) self.swtAScene.setChecked(self._build.getBool("headings.hideAltScene"))
self.swtSection.setChecked(self._build.getBool("headings.hideSection")) self.swtSection.setChecked(self._build.getBool("headings.hideSection"))
self.centerTitle.setChecked(self._build.getBool("headings.centerTitle")) self.centerPart.setChecked(self._build.getBool("headings.centerPart"))
self.centerChapter.setChecked(self._build.getBool("headings.centerChapter")) self.centerChapter.setChecked(self._build.getBool("headings.centerChapter"))
self.centerScene.setChecked(self._build.getBool("headings.centerScene")) self.centerScene.setChecked(self._build.getBool("headings.centerScene"))
self.breakTitle.setChecked(self._build.getBool("headings.breakTitle")) self.breakPart.setChecked(self._build.getBool("headings.breakPart"))
self.breakChapter.setChecked(self._build.getBool("headings.breakChapter")) self.breakChapter.setChecked(self._build.getBool("headings.breakChapter"))
self.breakScene.setChecked(self._build.getBool("headings.breakScene")) self.breakScene.setChecked(self._build.getBool("headings.breakScene"))
return return
def saveContent(self) -> None: def saveContent(self) -> None:
"""Save choices back into build object.""" """Save choices back into build object."""
self._build.setValue("headings.hideTitle", self.swtTitle.isChecked()) self._build.setValue("headings.hidePart", self.swtPart.isChecked())
self._build.setValue("headings.hideChapter", self.swtChapter.isChecked()) self._build.setValue("headings.hideChapter", self.swtChapter.isChecked())
self._build.setValue("headings.hideUnnumbered", self.swtUnnumbered.isChecked()) self._build.setValue("headings.hideUnnumbered", self.swtUnnumbered.isChecked())
self._build.setValue("headings.hideScene", self.swtScene.isChecked()) self._build.setValue("headings.hideScene", self.swtScene.isChecked())
self._build.setValue("headings.hideAltScene", self.swtAScene.isChecked()) self._build.setValue("headings.hideAltScene", self.swtAScene.isChecked())
self._build.setValue("headings.hideSection", self.swtSection.isChecked()) self._build.setValue("headings.hideSection", self.swtSection.isChecked())
self._build.setValue("headings.centerTitle", self.centerTitle.isChecked()) self._build.setValue("headings.centerPart", self.centerPart.isChecked())
self._build.setValue("headings.centerChapter", self.centerChapter.isChecked()) self._build.setValue("headings.centerChapter", self.centerChapter.isChecked())
self._build.setValue("headings.centerScene", self.centerScene.isChecked()) self._build.setValue("headings.centerScene", self.centerScene.isChecked())
self._build.setValue("headings.breakTitle", self.breakTitle.isChecked()) self._build.setValue("headings.breakPart", self.breakPart.isChecked())
self._build.setValue("headings.breakChapter", self.breakChapter.isChecked()) self._build.setValue("headings.breakChapter", self.breakChapter.isChecked())
self._build.setValue("headings.breakScene", self.breakScene.isChecked()) self._build.setValue("headings.breakScene", self.breakScene.isChecked())
return return
@@ -858,8 +858,8 @@ class _HeadingsTab(NScrollablePage):
self._editing = heading self._editing = heading
self.editTextBox.setEnabled(True) self.editTextBox.setEnabled(True)
if heading == self.EDIT_TITLE: if heading == self.EDIT_TITLE:
text = self.fmtTitle.text() text = self.fmtPart.text()
label = self._build.getLabel("headings.fmtTitle") label = self._build.getLabel("headings.fmtPart")
elif heading == self.EDIT_CHAPTER: elif heading == self.EDIT_CHAPTER:
text = self.fmtChapter.text() text = self.fmtChapter.text()
label = self._build.getLabel("headings.fmtChapter") label = self._build.getLabel("headings.fmtChapter")
@@ -896,8 +896,8 @@ class _HeadingsTab(NScrollablePage):
heading = self._editing heading = self._editing
text = self.editTextBox.toPlainText().strip().replace("\n", nwHeadFmt.BR) text = self.editTextBox.toPlainText().strip().replace("\n", nwHeadFmt.BR)
if heading == self.EDIT_TITLE: if heading == self.EDIT_TITLE:
self.fmtTitle.setText(text) self.fmtPart.setText(text)
self._build.setValue("headings.fmtTitle", text) self._build.setValue("headings.fmtPart", text)
elif heading == self.EDIT_CHAPTER: elif heading == self.EDIT_CHAPTER:
self.fmtChapter.setText(text) self.fmtChapter.setText(text)
self._build.setValue("headings.fmtChapter", text) self._build.setValue("headings.fmtChapter", text)