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.includeNotes": (bool, False),
"filter.includeInactive": (bool, False),
"headings.fmtTitle": (str, nwHeadFmt.TITLE),
"headings.fmtPart": (str, nwHeadFmt.TITLE),
"headings.fmtChapter": (str, nwHeadFmt.TITLE),
"headings.fmtUnnumbered": (str, nwHeadFmt.TITLE),
"headings.fmtScene": (str, "* * *"),
"headings.fmtAltScene": (str, ""),
"headings.fmtSection": (str, ""),
"headings.hideTitle": (bool, False),
"headings.hidePart": (bool, False),
"headings.hideChapter": (bool, False),
"headings.hideUnnumbered": (bool, False),
"headings.hideScene": (bool, False),
"headings.hideAltScene": (bool, False),
"headings.hideSection": (bool, True),
"headings.centerTitle": (bool, True),
"headings.centerPart": (bool, True),
"headings.centerChapter": (bool, False),
"headings.centerScene": (bool, False),
"headings.breakTitle": (bool, True),
"headings.breakPart": (bool, True),
"headings.breakChapter": (bool, True),
"headings.breakScene": (bool, False),
"text.includeSynopsis": (bool, False),
@@ -108,7 +108,7 @@ SETTINGS_LABELS = {
"filter.includeInactive": QT_TRANSLATE_NOOP("Builds", "Inactive Documents"),
"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.fmtUnnumbered": QT_TRANSLATE_NOOP("Builds", "Unnumbered Format"),
"headings.fmtScene": QT_TRANSLATE_NOOP("Builds", "Scene Format"),
@@ -147,12 +147,12 @@ SETTINGS_LABELS = {
"format.leftMargin": QT_TRANSLATE_NOOP("Builds", "Left 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.pageHeader": QT_TRANSLATE_NOOP("Builds", "Page Header"),
"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.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"))
bldObj.setFont(textFont)
bldObj.setTitleFormat(
self._build.getStr("headings.fmtTitle"),
self._build.getBool("headings.hideTitle")
bldObj.setPartitionFormat(
self._build.getStr("headings.fmtPart"),
self._build.getBool("headings.hidePart")
)
bldObj.setChapterFormat(
self._build.getStr("headings.fmtChapter"),
@@ -321,9 +321,9 @@ class NWBuildDocument:
self._build.getStr("headings.fmtSection"),
self._build.getBool("headings.hideSection")
)
bldObj.setTitleStyle(
self._build.getBool("headings.centerTitle"),
self._build.getBool("headings.breakTitle")
bldObj.setPartitionStyle(
self._build.getBool("headings.centerPart"),
self._build.getBool("headings.breakPart")
)
bldObj.setChapterStyle(
self._build.getBool("headings.centerChapter"),
+13 -13
View File
@@ -175,14 +175,14 @@ class Tokenizer(ABC):
self._marginSep = (1.168, 1.168)
# 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._fmtUnNum = nwHeadFmt.TITLE # Formatting for unnumbered chapters
self._fmtScene = nwHeadFmt.TITLE # Formatting for scenes
self._fmtHScene = nwHeadFmt.TITLE # Formatting for hard scenes
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._hideUnNum = False # Do not include unnumbered 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._titleStyle = self.A_CENTRE | self.A_PBB
self._partStyle = self.A_CENTRE | self.A_PBB
self._chapterStyle = self.A_PBB
self._sceneStyle = self.A_NONE
@@ -271,10 +271,10 @@ class Tokenizer(ABC):
# Setters
##
def setTitleFormat(self, hFormat: str, hide: bool = False) -> None:
"""Set the title format pattern."""
self._fmtTitle = hFormat.strip()
self._hideTitle = hide
def setPartitionFormat(self, hFormat: str, hide: bool = False) -> None:
"""Set the partition format pattern."""
self._fmtPart = hFormat.strip()
self._hidePart = hide
return
def setChapterFormat(self, hFormat: str, hide: bool = False) -> None:
@@ -307,9 +307,9 @@ class Tokenizer(ABC):
self._hideSection = hide
return
def setTitleStyle(self, center: bool, pageBreak: bool) -> None:
"""Set the title heading style."""
self._titleStyle = (
def setPartitionStyle(self, center: bool, pageBreak: bool) -> None:
"""Set the partition heading style."""
self._partStyle = (
(self.A_CENTRE if center else self.A_NONE) | (self.A_PBB if pageBreak else self.A_NONE)
)
return
@@ -664,15 +664,15 @@ class Tokenizer(ABC):
tText = aLine[2:].strip()
tType = self.T_HEAD1 if isPlain else self.T_TITLE
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 sHide:
tText = ""
tType = self.T_EMPTY
tStyle = self.A_NONE
elif isPlain:
tText = self._hFormatter.apply(self._fmtTitle, tText, nHead)
tStyle = self._titleStyle
tText = self._hFormatter.apply(self._fmtPart, tText, nHead)
tStyle = self._partStyle
if isPlain:
self._hFormatter.resetScene()
else:
+1 -1
View File
@@ -593,7 +593,7 @@ class _DetailsWidget(QWidget):
item.setText(1, "")
self.listView.addTopLevelItem(item)
for hFormat, hHide in [
("headings.fmtTitle", "headings.hideTitle"),
("headings.fmtPart", "headings.hidePart"),
("headings.fmtChapter", "headings.hideChapter"),
("headings.fmtUnnumbered", "headings.hideUnnumbered"),
("headings.fmtScene", "headings.hideScene"),
+30 -30
View File
@@ -585,20 +585,20 @@ class _HeadingsTab(NScrollablePage):
self.formatBox.setHorizontalSpacing(bSp)
# Title Heading
self.lblTitle = QLabel(self._build.getLabel("headings.fmtTitle"), self)
self.fmtTitle = QLineEdit("", self)
self.fmtTitle.setReadOnly(True)
self.btnTitle = NIconToolButton(self, iSz, "edit")
self.btnTitle.clicked.connect(lambda: self._editHeading(self.EDIT_TITLE))
self.hdeTitle = QLabel(trHide, self)
self.hdeTitle.setIndent(bSp)
self.swtTitle = NSwitch(self, height=iPx)
self.lblPart = QLabel(self._build.getLabel("headings.fmtPart"), self)
self.fmtPart = QLineEdit("", self)
self.fmtPart.setReadOnly(True)
self.btnPart = NIconToolButton(self, iSz, "edit")
self.btnPart.clicked.connect(lambda: self._editHeading(self.EDIT_TITLE))
self.hdePart = QLabel(trHide, self)
self.hdePart.setIndent(bSp)
self.swtPart = NSwitch(self, height=iPx)
self.formatBox.addWidget(self.lblTitle, 0, 0)
self.formatBox.addWidget(self.fmtTitle, 0, 1)
self.formatBox.addWidget(self.btnTitle, 0, 2)
self.formatBox.addWidget(self.hdeTitle, 0, 3)
self.formatBox.addWidget(self.swtTitle, 0, 4)
self.formatBox.addWidget(self.lblPart, 0, 0)
self.formatBox.addWidget(self.fmtPart, 0, 1)
self.formatBox.addWidget(self.btnPart, 0, 2)
self.formatBox.addWidget(self.hdePart, 0, 3)
self.formatBox.addWidget(self.swtPart, 0, 4)
# Chapter Heading
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.layoutMatrix.addWidget(self.layoutHeading, 0, 0, 1, 5)
# Title Layout
self.mtxTitle = QLabel(self._build.getLabel("headings.fmtTitle"), self)
self.centerTitle = NSwitch(self, height=iPx)
self.breakTitle = NSwitch(self, height=iPx)
# Partition Layout
self.mtxTitle = QLabel(self._build.getLabel("headings.fmtPart"), self)
self.centerPart = NSwitch(self, height=iPx)
self.breakPart = NSwitch(self, height=iPx)
lblCenterT = QLabel(self.tr("Centre"), self)
lblCenterT.setIndent(sSp)
lblBreakT = QLabel(self.tr("Page Break"), self)
@@ -749,9 +749,9 @@ class _HeadingsTab(NScrollablePage):
self.layoutMatrix.addWidget(self.mtxTitle, 1, 0)
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(self.breakTitle, 1, 4)
self.layoutMatrix.addWidget(self.breakPart, 1, 4)
# Chapter Layout
self.mtxChapter = QLabel(self._build.getLabel("headings.fmtChapter"), self)
@@ -802,41 +802,41 @@ class _HeadingsTab(NScrollablePage):
def loadContent(self) -> None:
"""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.fmtUnnumbered.setText(self._build.getStr("headings.fmtUnnumbered"))
self.fmtScene.setText(self._build.getStr("headings.fmtScene"))
self.fmtAScene.setText(self._build.getStr("headings.fmtAltScene"))
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.swtUnnumbered.setChecked(self._build.getBool("headings.hideUnnumbered"))
self.swtScene.setChecked(self._build.getBool("headings.hideScene"))
self.swtAScene.setChecked(self._build.getBool("headings.hideAltScene"))
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.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.breakScene.setChecked(self._build.getBool("headings.breakScene"))
return
def saveContent(self) -> None:
"""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.hideUnnumbered", self.swtUnnumbered.isChecked())
self._build.setValue("headings.hideScene", self.swtScene.isChecked())
self._build.setValue("headings.hideAltScene", self.swtAScene.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.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.breakScene", self.breakScene.isChecked())
return
@@ -858,8 +858,8 @@ class _HeadingsTab(NScrollablePage):
self._editing = heading
self.editTextBox.setEnabled(True)
if heading == self.EDIT_TITLE:
text = self.fmtTitle.text()
label = self._build.getLabel("headings.fmtTitle")
text = self.fmtPart.text()
label = self._build.getLabel("headings.fmtPart")
elif heading == self.EDIT_CHAPTER:
text = self.fmtChapter.text()
label = self._build.getLabel("headings.fmtChapter")
@@ -896,8 +896,8 @@ class _HeadingsTab(NScrollablePage):
heading = self._editing
text = self.editTextBox.toPlainText().strip().replace("\n", nwHeadFmt.BR)
if heading == self.EDIT_TITLE:
self.fmtTitle.setText(text)
self._build.setValue("headings.fmtTitle", text)
self.fmtPart.setText(text)
self._build.setValue("headings.fmtPart", text)
elif heading == self.EDIT_CHAPTER:
self.fmtChapter.setText(text)
self._build.setValue("headings.fmtChapter", text)