Allow hiding any header level in novels
This commit is contained in:
@@ -49,50 +49,53 @@ logger = logging.getLogger(__name__)
|
||||
# (type, default, [min value, max value])
|
||||
|
||||
SETTINGS_TEMPLATE = {
|
||||
"filter.includeNovel": (bool, True),
|
||||
"filter.includeNotes": (bool, False),
|
||||
"filter.includeInactive": (bool, False),
|
||||
"headings.fmtTitle": (str, nwHeadFmt.TITLE),
|
||||
"headings.fmtChapter": (str, nwHeadFmt.TITLE),
|
||||
"headings.fmtUnnumbered": (str, nwHeadFmt.TITLE),
|
||||
"headings.fmtScene": (str, "* * *"),
|
||||
"headings.fmtHardScene": (str, ""),
|
||||
"headings.fmtSection": (str, ""),
|
||||
"headings.hideScene": (bool, False),
|
||||
"headings.hideHardScene": (bool, False),
|
||||
"headings.hideSection": (bool, True),
|
||||
"headings.centerTitle": (bool, True),
|
||||
"headings.centerChapter": (bool, False),
|
||||
"headings.centerScene": (bool, False),
|
||||
"headings.breakTitle": (bool, True),
|
||||
"headings.breakChapter": (bool, True),
|
||||
"headings.breakScene": (bool, False),
|
||||
"text.includeSynopsis": (bool, False),
|
||||
"text.includeComments": (bool, False),
|
||||
"text.includeKeywords": (bool, False),
|
||||
"text.includeBodyText": (bool, True),
|
||||
"text.ignoredKeywords": (str, ""),
|
||||
"text.addNoteHeadings": (bool, True),
|
||||
"format.textFont": (str, CONFIG.textFont),
|
||||
"format.textSize": (int, 12),
|
||||
"format.lineHeight": (float, 1.15, 0.75, 3.0),
|
||||
"format.justifyText": (bool, False),
|
||||
"format.stripUnicode": (bool, False),
|
||||
"format.replaceTabs": (bool, False),
|
||||
"format.pageUnit": (str, "cm"),
|
||||
"format.pageSize": (str, "A4"),
|
||||
"format.pageWidth": (float, 21.0),
|
||||
"format.pageHeight": (float, 29.7),
|
||||
"format.topMargin": (float, 2.0),
|
||||
"format.bottomMargin": (float, 2.0),
|
||||
"format.leftMargin": (float, 2.0),
|
||||
"format.rightMargin": (float, 2.0),
|
||||
"odt.addColours": (bool, True),
|
||||
"odt.pageHeader": (str, nwHeadFmt.ODT_AUTO),
|
||||
"odt.pageCountOffset": (int, 0),
|
||||
"md.preserveBreaks": (bool, True),
|
||||
"html.addStyles": (bool, True),
|
||||
"html.preserveTabs": (bool, False),
|
||||
"filter.includeNovel": (bool, True),
|
||||
"filter.includeNotes": (bool, False),
|
||||
"filter.includeInactive": (bool, False),
|
||||
"headings.fmtTitle": (str, nwHeadFmt.TITLE),
|
||||
"headings.fmtChapter": (str, nwHeadFmt.TITLE),
|
||||
"headings.fmtUnnumbered": (str, nwHeadFmt.TITLE),
|
||||
"headings.fmtScene": (str, "* * *"),
|
||||
"headings.fmtHardScene": (str, ""),
|
||||
"headings.fmtSection": (str, ""),
|
||||
"headings.hideTitle": (bool, False),
|
||||
"headings.hideChapter": (bool, False),
|
||||
"headings.hideUnnumbered": (bool, False),
|
||||
"headings.hideScene": (bool, False),
|
||||
"headings.hideHardScene": (bool, False),
|
||||
"headings.hideSection": (bool, True),
|
||||
"headings.centerTitle": (bool, True),
|
||||
"headings.centerChapter": (bool, False),
|
||||
"headings.centerScene": (bool, False),
|
||||
"headings.breakTitle": (bool, True),
|
||||
"headings.breakChapter": (bool, True),
|
||||
"headings.breakScene": (bool, False),
|
||||
"text.includeSynopsis": (bool, False),
|
||||
"text.includeComments": (bool, False),
|
||||
"text.includeKeywords": (bool, False),
|
||||
"text.includeBodyText": (bool, True),
|
||||
"text.ignoredKeywords": (str, ""),
|
||||
"text.addNoteHeadings": (bool, True),
|
||||
"format.textFont": (str, CONFIG.textFont),
|
||||
"format.textSize": (int, 12),
|
||||
"format.lineHeight": (float, 1.15, 0.75, 3.0),
|
||||
"format.justifyText": (bool, False),
|
||||
"format.stripUnicode": (bool, False),
|
||||
"format.replaceTabs": (bool, False),
|
||||
"format.pageUnit": (str, "cm"),
|
||||
"format.pageSize": (str, "A4"),
|
||||
"format.pageWidth": (float, 21.0),
|
||||
"format.pageHeight": (float, 29.7),
|
||||
"format.topMargin": (float, 2.0),
|
||||
"format.bottomMargin": (float, 2.0),
|
||||
"format.leftMargin": (float, 2.0),
|
||||
"format.rightMargin": (float, 2.0),
|
||||
"odt.addColours": (bool, True),
|
||||
"odt.pageHeader": (str, nwHeadFmt.ODT_AUTO),
|
||||
"odt.pageCountOffset": (int, 0),
|
||||
"md.preserveBreaks": (bool, True),
|
||||
"html.addStyles": (bool, True),
|
||||
"html.preserveTabs": (bool, False),
|
||||
}
|
||||
|
||||
SETTINGS_LABELS = {
|
||||
@@ -108,9 +111,6 @@ SETTINGS_LABELS = {
|
||||
"headings.fmtScene": QT_TRANSLATE_NOOP("Builds", "Scene Format"),
|
||||
"headings.fmtHardScene": QT_TRANSLATE_NOOP("Builds", "Hard Scene Format"),
|
||||
"headings.fmtSection": QT_TRANSLATE_NOOP("Builds", "Section Format"),
|
||||
"headings.hideScene": QT_TRANSLATE_NOOP("Builds", "Hide Scene Breaks"),
|
||||
"headings.hideHardScene": QT_TRANSLATE_NOOP("Builds", "Hide Hard Scene Breaks"),
|
||||
"headings.hideSection": QT_TRANSLATE_NOOP("Builds", "Hide Section Breaks"),
|
||||
|
||||
"text.grpContent": QT_TRANSLATE_NOOP("Builds", "Text Content"),
|
||||
"text.includeSynopsis": QT_TRANSLATE_NOOP("Builds", "Include Synopsis"),
|
||||
|
||||
@@ -275,9 +275,18 @@ class NWBuildDocument:
|
||||
fontInfo = QFontInfo(bldFont)
|
||||
textFixed = fontInfo.fixedPitch()
|
||||
|
||||
bldObj.setTitleFormat(self._build.getStr("headings.fmtTitle"))
|
||||
bldObj.setChapterFormat(self._build.getStr("headings.fmtChapter"))
|
||||
bldObj.setUnNumberedFormat(self._build.getStr("headings.fmtUnnumbered"))
|
||||
bldObj.setTitleFormat(
|
||||
self._build.getStr("headings.fmtTitle"),
|
||||
self._build.getBool("headings.hideTitle")
|
||||
)
|
||||
bldObj.setChapterFormat(
|
||||
self._build.getStr("headings.fmtChapter"),
|
||||
self._build.getBool("headings.hideChapter")
|
||||
)
|
||||
bldObj.setUnNumberedFormat(
|
||||
self._build.getStr("headings.fmtUnnumbered"),
|
||||
self._build.getBool("headings.hideUnnumbered")
|
||||
)
|
||||
bldObj.setSceneFormat(
|
||||
self._build.getStr("headings.fmtScene"),
|
||||
self._build.getBool("headings.hideScene")
|
||||
|
||||
@@ -158,6 +158,9 @@ class Tokenizer(ABC):
|
||||
self._fmtHScene = nwHeadFmt.TITLE # Formatting for hard scenes
|
||||
self._fmtSection = nwHeadFmt.TITLE # Formatting for sections
|
||||
|
||||
self._hideTitle = False # Do not include title 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
|
||||
self._hideHScene = False # Do not include hard scene headings
|
||||
self._hideSection = False # Do not include section headings
|
||||
@@ -234,34 +237,37 @@ class Tokenizer(ABC):
|
||||
# Setters
|
||||
##
|
||||
|
||||
def setTitleFormat(self, hFormat: str) -> None:
|
||||
def setTitleFormat(self, hFormat: str, hide: bool = False) -> None:
|
||||
"""Set the title format pattern."""
|
||||
self._fmtTitle = hFormat.strip()
|
||||
self._hideTitle = hide
|
||||
return
|
||||
|
||||
def setChapterFormat(self, hFormat: str) -> None:
|
||||
def setChapterFormat(self, hFormat: str, hide: bool = False) -> None:
|
||||
"""Set the chapter format pattern."""
|
||||
self._fmtChapter = hFormat.strip()
|
||||
self._hideChapter = hide
|
||||
return
|
||||
|
||||
def setUnNumberedFormat(self, hFormat: str) -> None:
|
||||
def setUnNumberedFormat(self, hFormat: str, hide: bool = False) -> None:
|
||||
"""Set the unnumbered format pattern."""
|
||||
self._fmtUnNum = hFormat.strip()
|
||||
self._hideUnNum = hide
|
||||
return
|
||||
|
||||
def setSceneFormat(self, hFormat: str, hide: bool) -> None:
|
||||
def setSceneFormat(self, hFormat: str, hide: bool = False) -> None:
|
||||
"""Set the scene format pattern and hidden status."""
|
||||
self._fmtScene = hFormat.strip()
|
||||
self._hideScene = hide
|
||||
return
|
||||
|
||||
def setHardSceneFormat(self, hFormat: str, hide: bool) -> None:
|
||||
def setHardSceneFormat(self, hFormat: str, hide: bool = False) -> None:
|
||||
"""Set the hard scene format pattern and hidden status."""
|
||||
self._fmtHScene = hFormat.strip()
|
||||
self._hideHScene = hide
|
||||
return
|
||||
|
||||
def setSectionFormat(self, hFormat: str, hide: bool) -> None:
|
||||
def setSectionFormat(self, hFormat: str, hide: bool = False) -> None:
|
||||
"""Set the section format pattern and hidden status."""
|
||||
self._fmtSection = hFormat.strip()
|
||||
self._hideSection = hide
|
||||
@@ -578,10 +584,16 @@ 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
|
||||
if self._isNovel:
|
||||
if isPlain:
|
||||
if sHide:
|
||||
tText = ""
|
||||
tType = self.T_EMPTY
|
||||
tStyle = self.A_NONE
|
||||
elif isPlain:
|
||||
tText = self._hFormatter.apply(self._fmtTitle, tText, nHead)
|
||||
tStyle = self._titleStyle
|
||||
if isPlain:
|
||||
self._hFormatter.resetScene()
|
||||
else:
|
||||
self._hFormatter.resetAll()
|
||||
@@ -606,18 +618,24 @@ class Tokenizer(ABC):
|
||||
|
||||
nHead += 1
|
||||
tText = aLine[3:].strip()
|
||||
tType = self.T_HEAD2
|
||||
tStyle = self.A_NONE
|
||||
sHide = self._hideChapter if isPlain else self._hideUnNum
|
||||
tFormat = self._fmtChapter if isPlain else self._fmtUnNum
|
||||
if self._isNovel:
|
||||
if isPlain:
|
||||
self._hFormatter.incChapter()
|
||||
tText = self._hFormatter.apply(tFormat, tText, nHead)
|
||||
tStyle = self._chapterStyle
|
||||
self._noSep = True
|
||||
if sHide:
|
||||
tText = ""
|
||||
tType = self.T_EMPTY
|
||||
else:
|
||||
tText = self._hFormatter.apply(tFormat, tText, nHead)
|
||||
tStyle = self._chapterStyle
|
||||
self._hFormatter.resetScene()
|
||||
self._noSep = True
|
||||
|
||||
self._tokens.append((
|
||||
self.T_HEAD2, nHead, tText, [], tStyle
|
||||
tType, nHead, tText, [], tStyle
|
||||
))
|
||||
if self._keepMarkdown:
|
||||
tmpMarkdown.append(f"{aLine}\n")
|
||||
|
||||
@@ -605,23 +605,26 @@ class _DetailsWidget(QWidget):
|
||||
hFmt.resetScene()
|
||||
hFmt.incScene()
|
||||
title = self.tr("Title")
|
||||
hidden = self.tr("Hidden")
|
||||
|
||||
item = QTreeWidgetItem()
|
||||
item.setText(0, build.getLabel("headings"))
|
||||
item.setText(1, "")
|
||||
self.listView.addTopLevelItem(item)
|
||||
for key in [
|
||||
"headings.fmtTitle", "headings.fmtChapter", "headings.fmtUnnumbered",
|
||||
"headings.fmtScene", "headings.fmtHardScene", "headings.fmtSection"
|
||||
for hFormat, hHide in [
|
||||
("headings.fmtTitle", "headings.hideTitle"),
|
||||
("headings.fmtChapter", "headings.hideChapter"),
|
||||
("headings.fmtUnnumbered", "headings.hideUnnumbered"),
|
||||
("headings.fmtScene", "headings.hideScene"),
|
||||
("headings.fmtHardScene", "headings.hideHardScene"),
|
||||
("headings.fmtSection", "headings.hideSection"),
|
||||
]:
|
||||
sub = QTreeWidgetItem()
|
||||
sub.setText(0, build.getLabel(key))
|
||||
sub.setText(1, hFmt.apply(build.getStr(key), title, 0))
|
||||
item.addChild(sub)
|
||||
for key in ["headings.hideScene", "headings.hideHardScene", "headings.hideSection"]:
|
||||
sub = QTreeWidgetItem()
|
||||
sub.setText(0, build.getLabel(key))
|
||||
sub.setIcon(1, on if build.getBool(key) else off)
|
||||
sub.setText(0, build.getLabel(hFormat))
|
||||
if build.getBool(hHide):
|
||||
sub.setText(1, f"[{hidden}]")
|
||||
else:
|
||||
sub.setText(1, hFmt.apply(build.getStr(hFormat), title, 0))
|
||||
item.addChild(sub)
|
||||
|
||||
# Text Content
|
||||
|
||||
@@ -601,7 +601,7 @@ class _HeadingsTab(NScrollablePage):
|
||||
# Format Boxes
|
||||
# ============
|
||||
self.formatBox = QGridLayout()
|
||||
self.formatBox.setHorizontalSpacing(vSp)
|
||||
self.formatBox.setHorizontalSpacing(bSp)
|
||||
|
||||
# Title Heading
|
||||
self.lblTitle = QLabel(self._build.getLabel("headings.fmtTitle"), self)
|
||||
@@ -610,14 +610,15 @@ class _HeadingsTab(NScrollablePage):
|
||||
self.btnTitle = QToolButton(self)
|
||||
self.btnTitle.setIcon(SHARED.theme.getIcon("edit"))
|
||||
self.btnTitle.clicked.connect(lambda: self._editHeading(self.EDIT_TITLE))
|
||||
|
||||
wrapTitle = QHBoxLayout()
|
||||
wrapTitle.addWidget(self.fmtTitle)
|
||||
wrapTitle.addWidget(self.btnTitle)
|
||||
wrapTitle.setSpacing(bSp)
|
||||
self.hdeTitle = QLabel(self.tr("Hide"), self)
|
||||
self.hdeTitle.setIndent(bSp)
|
||||
self.swtTitle = NSwitch(self, height=iPx)
|
||||
|
||||
self.formatBox.addWidget(self.lblTitle, 0, 0)
|
||||
self.formatBox.addLayout(wrapTitle, 0, 1)
|
||||
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)
|
||||
|
||||
# Chapter Heading
|
||||
self.lblChapter = QLabel(self._build.getLabel("headings.fmtChapter"), self)
|
||||
@@ -626,14 +627,15 @@ class _HeadingsTab(NScrollablePage):
|
||||
self.btnChapter = QToolButton(self)
|
||||
self.btnChapter.setIcon(SHARED.theme.getIcon("edit"))
|
||||
self.btnChapter.clicked.connect(lambda: self._editHeading(self.EDIT_CHAPTER))
|
||||
|
||||
wrapChapter = QHBoxLayout()
|
||||
wrapChapter.addWidget(self.fmtChapter)
|
||||
wrapChapter.addWidget(self.btnChapter)
|
||||
wrapChapter.setSpacing(bSp)
|
||||
self.hdeChapter = QLabel(self.tr("Hide"), self)
|
||||
self.hdeChapter.setIndent(bSp)
|
||||
self.swtChapter = NSwitch(self, height=iPx)
|
||||
|
||||
self.formatBox.addWidget(self.lblChapter, 1, 0)
|
||||
self.formatBox.addLayout(wrapChapter, 1, 1)
|
||||
self.formatBox.addWidget(self.fmtChapter, 1, 1)
|
||||
self.formatBox.addWidget(self.btnChapter, 1, 2)
|
||||
self.formatBox.addWidget(self.hdeChapter, 1, 3)
|
||||
self.formatBox.addWidget(self.swtChapter, 1, 4)
|
||||
|
||||
# Unnumbered Chapter Heading
|
||||
self.lblUnnumbered = QLabel(self._build.getLabel("headings.fmtUnnumbered"), self)
|
||||
@@ -642,95 +644,66 @@ class _HeadingsTab(NScrollablePage):
|
||||
self.btnUnnumbered = QToolButton(self)
|
||||
self.btnUnnumbered.setIcon(SHARED.theme.getIcon("edit"))
|
||||
self.btnUnnumbered.clicked.connect(lambda: self._editHeading(self.EDIT_UNNUM))
|
||||
|
||||
wrapUnnumbered = QHBoxLayout()
|
||||
wrapUnnumbered.addWidget(self.fmtUnnumbered)
|
||||
wrapUnnumbered.addWidget(self.btnUnnumbered)
|
||||
wrapUnnumbered.setSpacing(bSp)
|
||||
self.hdeUnnumbered = QLabel(self.tr("Hide"), self)
|
||||
self.hdeUnnumbered.setIndent(bSp)
|
||||
self.swtUnnumbered = NSwitch(self, height=iPx)
|
||||
|
||||
self.formatBox.addWidget(self.lblUnnumbered, 2, 0)
|
||||
self.formatBox.addLayout(wrapUnnumbered, 2, 1)
|
||||
self.formatBox.addWidget(self.fmtUnnumbered, 2, 1)
|
||||
self.formatBox.addWidget(self.btnUnnumbered, 2, 2)
|
||||
self.formatBox.addWidget(self.hdeUnnumbered, 2, 3)
|
||||
self.formatBox.addWidget(self.swtUnnumbered, 2, 4)
|
||||
|
||||
# Scene Heading
|
||||
sceneHideTip = self._build.getLabel("headings.hideScene")
|
||||
self.lblScene = QLabel(self._build.getLabel("headings.fmtScene"), self)
|
||||
self.fmtScene = QLineEdit("", self)
|
||||
self.fmtScene.setReadOnly(True)
|
||||
self.btnScene = QToolButton(self)
|
||||
self.btnScene.setIcon(SHARED.theme.getIcon("edit"))
|
||||
self.btnScene.clicked.connect(lambda: self._editHeading(self.EDIT_SCENE))
|
||||
self.hdeScene = QLabel(self.tr("Hide"))
|
||||
self.hdeScene.setToolTip(sceneHideTip)
|
||||
self.hdeScene = QLabel(self.tr("Hide"), self)
|
||||
self.hdeScene.setIndent(bSp)
|
||||
self.swtScene = NSwitch(self, height=iPx)
|
||||
self.swtScene.setToolTip(sceneHideTip)
|
||||
|
||||
wrapScene = QHBoxLayout()
|
||||
wrapScene.addWidget(self.fmtScene)
|
||||
wrapScene.addWidget(self.btnScene)
|
||||
wrapScene.setSpacing(bSp)
|
||||
|
||||
wrapSceneHide = QHBoxLayout()
|
||||
wrapSceneHide.addWidget(self.hdeScene)
|
||||
wrapSceneHide.addWidget(self.swtScene)
|
||||
wrapSceneHide.setSpacing(bSp)
|
||||
|
||||
self.formatBox.addWidget(self.lblScene, 3, 0)
|
||||
self.formatBox.addLayout(wrapScene, 3, 1)
|
||||
self.formatBox.addLayout(wrapSceneHide, 3, 2)
|
||||
self.formatBox.addWidget(self.fmtScene, 3, 1)
|
||||
self.formatBox.addWidget(self.btnScene, 3, 2)
|
||||
self.formatBox.addWidget(self.hdeScene, 3, 3)
|
||||
self.formatBox.addWidget(self.swtScene, 3, 4)
|
||||
|
||||
# Alt Scene Heading
|
||||
hardSceneHideTip = self._build.getLabel("headings.hideHardScene")
|
||||
self.lblHScene = QLabel(self._build.getLabel("headings.fmtHardScene"), self)
|
||||
self.fmtHScene = QLineEdit("", self)
|
||||
self.fmtHScene.setReadOnly(True)
|
||||
self.btnHScene = QToolButton(self)
|
||||
self.btnHScene.setIcon(SHARED.theme.getIcon("edit"))
|
||||
self.btnHScene.clicked.connect(lambda: self._editHeading(self.EDIT_HSCENE))
|
||||
self.hdeHScene = QLabel(self.tr("Hide"))
|
||||
self.hdeHScene.setToolTip(hardSceneHideTip)
|
||||
self.hdeHScene = QLabel(self.tr("Hide"), self)
|
||||
self.hdeHScene.setIndent(bSp)
|
||||
self.swtHScene = NSwitch(self, height=iPx)
|
||||
self.swtHScene.setToolTip(hardSceneHideTip)
|
||||
|
||||
wrapHScene = QHBoxLayout()
|
||||
wrapHScene.addWidget(self.fmtHScene)
|
||||
wrapHScene.addWidget(self.btnHScene)
|
||||
wrapHScene.setSpacing(bSp)
|
||||
|
||||
wrapHSceneHide = QHBoxLayout()
|
||||
wrapHSceneHide.addWidget(self.hdeHScene)
|
||||
wrapHSceneHide.addWidget(self.swtHScene)
|
||||
wrapHSceneHide.setSpacing(bSp)
|
||||
|
||||
self.formatBox.addWidget(self.lblHScene, 4, 0)
|
||||
self.formatBox.addLayout(wrapHScene, 4, 1)
|
||||
self.formatBox.addLayout(wrapHSceneHide, 4, 2)
|
||||
self.formatBox.addWidget(self.fmtHScene, 4, 1)
|
||||
self.formatBox.addWidget(self.btnHScene, 4, 2)
|
||||
self.formatBox.addWidget(self.hdeHScene, 4, 3)
|
||||
self.formatBox.addWidget(self.swtHScene, 4, 4)
|
||||
|
||||
# Section Heading
|
||||
sectionHideTip = self._build.getLabel("headings.hideSection")
|
||||
self.lblSection = QLabel(self._build.getLabel("headings.fmtSection"), self)
|
||||
self.fmtSection = QLineEdit("", self)
|
||||
self.fmtSection.setReadOnly(True)
|
||||
self.btnSection = QToolButton(self)
|
||||
self.btnSection.setIcon(SHARED.theme.getIcon("edit"))
|
||||
self.btnSection.clicked.connect(lambda: self._editHeading(self.EDIT_SECTION))
|
||||
self.hdeSection = QLabel(self.tr("Hide"))
|
||||
self.hdeSection.setToolTip(sectionHideTip)
|
||||
self.hdeSection = QLabel(self.tr("Hide"), self)
|
||||
self.hdeSection.setIndent(bSp)
|
||||
self.swtSection = NSwitch(self, height=iPx)
|
||||
self.swtSection.setToolTip(sectionHideTip)
|
||||
|
||||
wrapSection = QHBoxLayout()
|
||||
wrapSection.addWidget(self.fmtSection)
|
||||
wrapSection.addWidget(self.btnSection)
|
||||
wrapSection.setSpacing(bSp)
|
||||
|
||||
wrapSectionHide = QHBoxLayout()
|
||||
wrapSectionHide.addWidget(self.hdeSection)
|
||||
wrapSectionHide.addWidget(self.swtSection)
|
||||
wrapSectionHide.setSpacing(bSp)
|
||||
|
||||
self.formatBox.addWidget(self.lblSection, 5, 0)
|
||||
self.formatBox.addLayout(wrapSection, 5, 1)
|
||||
self.formatBox.addLayout(wrapSectionHide, 5, 2)
|
||||
self.formatBox.addWidget(self.fmtSection, 5, 1)
|
||||
self.formatBox.addWidget(self.btnSection, 5, 2)
|
||||
self.formatBox.addWidget(self.hdeSection, 5, 3)
|
||||
self.formatBox.addWidget(self.swtSection, 5, 4)
|
||||
|
||||
# Edit Form
|
||||
# =========
|
||||
@@ -860,9 +833,14 @@ class _HeadingsTab(NScrollablePage):
|
||||
self.fmtScene.setText(self._build.getStr("headings.fmtScene"))
|
||||
self.fmtHScene.setText(self._build.getStr("headings.fmtHardScene"))
|
||||
self.fmtSection.setText(self._build.getStr("headings.fmtSection"))
|
||||
|
||||
self.swtTitle.setChecked(self._build.getBool("headings.hideTitle"))
|
||||
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.swtHScene.setChecked(self._build.getBool("headings.hideHardScene"))
|
||||
self.swtSection.setChecked(self._build.getBool("headings.hideSection"))
|
||||
|
||||
self.centerTitle.setChecked(self._build.getBool("headings.centerTitle"))
|
||||
self.centerChapter.setChecked(self._build.getBool("headings.centerChapter"))
|
||||
self.centerScene.setChecked(self._build.getBool("headings.centerScene"))
|
||||
@@ -873,9 +851,13 @@ class _HeadingsTab(NScrollablePage):
|
||||
|
||||
def saveContent(self) -> None:
|
||||
"""Save choices back into build object."""
|
||||
self._build.setValue("headings.hideTitle", self.swtTitle.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.hideHardScene", self.swtHScene.isChecked())
|
||||
self._build.setValue("headings.hideSection", self.swtSection.isChecked())
|
||||
|
||||
self._build.setValue("headings.centerTitle", self.centerTitle.isChecked())
|
||||
self._build.setValue("headings.centerChapter", self.centerChapter.isChecked())
|
||||
self._build.setValue("headings.centerScene", self.centerScene.isChecked())
|
||||
|
||||
@@ -71,9 +71,9 @@ def testCoreToken_Setters(mockGUI):
|
||||
assert tokens._doKeywords is False
|
||||
|
||||
# Set new values
|
||||
tokens.setTitleFormat(f"T: {nwHeadFmt.TITLE}")
|
||||
tokens.setChapterFormat(f"C: {nwHeadFmt.TITLE}")
|
||||
tokens.setUnNumberedFormat(f"U: {nwHeadFmt.TITLE}")
|
||||
tokens.setTitleFormat(f"T: {nwHeadFmt.TITLE}", True)
|
||||
tokens.setChapterFormat(f"C: {nwHeadFmt.TITLE}", True)
|
||||
tokens.setUnNumberedFormat(f"U: {nwHeadFmt.TITLE}", True)
|
||||
tokens.setSceneFormat(f"S: {nwHeadFmt.TITLE}", True)
|
||||
tokens.setHardSceneFormat(f"H: {nwHeadFmt.TITLE}", True)
|
||||
tokens.setSectionFormat(f"X: {nwHeadFmt.TITLE}", True)
|
||||
@@ -114,6 +114,9 @@ def testCoreToken_Setters(mockGUI):
|
||||
assert tokens._marginHead4 == (2.0, 2.0)
|
||||
assert tokens._marginText == (2.0, 2.0)
|
||||
assert tokens._marginMeta == (2.0, 2.0)
|
||||
assert tokens._hideTitle is True
|
||||
assert tokens._hideChapter is True
|
||||
assert tokens._hideUnNum is True
|
||||
assert tokens._hideScene is True
|
||||
assert tokens._hideSection is True
|
||||
assert tokens._linkHeaders is True
|
||||
|
||||
Reference in New Issue
Block a user