From 329fcb4b9e740a11f8f85f9ac6dbdff494a1d033 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Sun, 23 Jan 2022 15:53:06 +0100 Subject: [PATCH] Re-enable switches for hidden or blank scene and section titles in builds --- novelwriter/core/options.py | 9 +++--- novelwriter/tools/build.py | 64 +++++++++++++++++++++++++------------ 2 files changed, 48 insertions(+), 25 deletions(-) diff --git a/novelwriter/core/options.py b/novelwriter/core/options.py index 7a37e7fc0..144ba4acb 100644 --- a/novelwriter/core/options.py +++ b/novelwriter/core/options.py @@ -42,10 +42,11 @@ }, "GuiDocSplit": {"spLevel"}, "GuiBuildNovel": { - "winWidth", "winHeight", "boxWidth", "docWidth", "addNovel", - "addNotes", "ignoreFlag", "justifyText", "excludeBody", "textFont", - "textSize", "lineHeight", "noStyling", "incSynopsis", "incComments", - "incKeywords", "incBodyText", "replaceTabs", "replaceUCode" + "winWidth", "winHeight", "boxWidth", "docWidth", "hideScene", + "hideSection", "addNovel", "addNotes", "ignoreFlag", "justifyText", + "excludeBody", "textFont", "textSize", "lineHeight", "noStyling", + "incSynopsis", "incComments", "incKeywords", "incBodyText", + "replaceTabs", "replaceUCode" }, "GuiOutline": {"headerOrder", "columnWidth", "columnHidden"}, "GuiProjectSettings": { diff --git a/novelwriter/tools/build.py b/novelwriter/tools/build.py index cf8842928..7ebed5722 100644 --- a/novelwriter/tools/build.py +++ b/novelwriter/tools/build.py @@ -172,6 +172,16 @@ def __init__(self, theParent): if langIdx != -1: self.buildLang.setCurrentIndex(langIdx) + self.hideScene = QSwitch(width=wS, height=hS) + self.hideScene.setChecked( + self.optState.getBool("GuiBuildNovel", "hideScene", False) + ) + + self.hideSection = QSwitch(width=wS, height=hS) + self.hideSection.setChecked( + self.optState.getBool("GuiBuildNovel", "hideSection", True) + ) + # Wrapper boxes due to QGridView and QLineEdit expand bug self.boxTitle = QHBoxLayout() self.boxTitle.addWidget(self.fmtTitle) @@ -184,25 +194,31 @@ def __init__(self, theParent): self.boxSection = QHBoxLayout() self.boxSection.addWidget(self.fmtSection) - titleLabel = QLabel(self.tr("Title")) - chapterLabel = QLabel(self.tr("Chapter")) - unnumbLabel = QLabel(self.tr("Unnumbered")) - sceneLabel = QLabel(self.tr("Scene")) - sectionLabel = QLabel(self.tr("Section")) - langLabel = QLabel(self.tr("Language")) - - self.titleForm.addWidget(titleLabel, 0, 0, 1, 1, Qt.AlignLeft) - self.titleForm.addLayout(self.boxTitle, 0, 1, 1, 1, Qt.AlignRight) - self.titleForm.addWidget(chapterLabel, 1, 0, 1, 1, Qt.AlignLeft) - self.titleForm.addLayout(self.boxChapter, 1, 1, 1, 1, Qt.AlignRight) - self.titleForm.addWidget(unnumbLabel, 2, 0, 1, 1, Qt.AlignLeft) - self.titleForm.addLayout(self.boxUnnumb, 2, 1, 1, 1, Qt.AlignRight) - self.titleForm.addWidget(sceneLabel, 3, 0, 1, 1, Qt.AlignLeft) - self.titleForm.addLayout(self.boxScene, 3, 1, 1, 1, Qt.AlignRight) - self.titleForm.addWidget(sectionLabel, 4, 0, 1, 1, Qt.AlignLeft) - self.titleForm.addLayout(self.boxSection, 4, 1, 1, 1, Qt.AlignRight) - self.titleForm.addWidget(langLabel, 5, 0, 1, 1, Qt.AlignLeft) - self.titleForm.addWidget(self.buildLang, 5, 1, 1, 1, Qt.AlignRight) + titleLabel = QLabel(self.tr("Title")) + chapterLabel = QLabel(self.tr("Chapter")) + unnumbLabel = QLabel(self.tr("Unnumbered")) + sceneLabel = QLabel(self.tr("Scene")) + sectionLabel = QLabel(self.tr("Section")) + langLabel = QLabel(self.tr("Language")) + hSceneLabel = QLabel(self.tr("Hide scene")) + hSectionLabel = QLabel(self.tr("Hide section")) + + self.titleForm.addWidget(titleLabel, 0, 0, 1, 1, Qt.AlignLeft) + self.titleForm.addLayout(self.boxTitle, 0, 1, 1, 1, Qt.AlignRight) + self.titleForm.addWidget(chapterLabel, 1, 0, 1, 1, Qt.AlignLeft) + self.titleForm.addLayout(self.boxChapter, 1, 1, 1, 1, Qt.AlignRight) + self.titleForm.addWidget(unnumbLabel, 2, 0, 1, 1, Qt.AlignLeft) + self.titleForm.addLayout(self.boxUnnumb, 2, 1, 1, 1, Qt.AlignRight) + self.titleForm.addWidget(sceneLabel, 3, 0, 1, 1, Qt.AlignLeft) + self.titleForm.addLayout(self.boxScene, 3, 1, 1, 1, Qt.AlignRight) + self.titleForm.addWidget(sectionLabel, 4, 0, 1, 1, Qt.AlignLeft) + self.titleForm.addLayout(self.boxSection, 4, 1, 1, 1, Qt.AlignRight) + self.titleForm.addWidget(langLabel, 5, 0, 1, 1, Qt.AlignLeft) + self.titleForm.addWidget(self.buildLang, 5, 1, 1, 1, Qt.AlignRight) + self.titleForm.addWidget(hSceneLabel, 6, 0, 1, 1, Qt.AlignLeft) + self.titleForm.addWidget(self.hideScene, 6, 1, 1, 1, Qt.AlignRight) + self.titleForm.addWidget(hSectionLabel, 7, 0, 1, 1, Qt.AlignLeft) + self.titleForm.addWidget(self.hideSection, 7, 1, 1, 1, Qt.AlignRight) self.titleForm.setColumnStretch(0, 0) self.titleForm.setColumnStretch(1, 1) @@ -643,6 +659,8 @@ def _doBuild(self, bldObj, isPreview=False, doConvert=True): fmtUnnumbered = self.fmtUnnumbered.text() fmtScene = self.fmtScene.text() fmtSection = self.fmtSection.text() + hideScene = self.hideScene.isChecked() + hideSection = self.hideSection.isChecked() textFont = self.textFont.text() textSize = self.textSize.value() lineHeight = self.lineHeight.value() @@ -670,8 +688,8 @@ def _doBuild(self, bldObj, isPreview=False, doConvert=True): bldObj.setTitleFormat(fmtTitle) bldObj.setChapterFormat(fmtChapter) bldObj.setUnNumberedFormat(fmtUnnumbered) - bldObj.setSceneFormat(fmtScene, False) - bldObj.setSectionFormat(fmtSection, fmtSection == "") + bldObj.setSceneFormat(fmtScene, hideScene) + bldObj.setSectionFormat(fmtSection, hideSection) bldObj.setFont(textFont, textSize, textFixed) bldObj.setJustify(justifyText) @@ -1115,6 +1133,8 @@ def _saveSettings(self): }) buildLang = self.buildLang.currentData() + hideScene = self.hideScene.isChecked() + hideSection = self.hideSection.isChecked() winWidth = self.mainConf.rpxInt(self.width()) winHeight = self.mainConf.rpxInt(self.height()) justifyText = self.justifyText.isChecked() @@ -1139,6 +1159,8 @@ def _saveSettings(self): self.theProject.setProjectLang(buildLang) # GUI Settings + self.optState.setValue("GuiBuildNovel", "hideScene", hideScene) + self.optState.setValue("GuiBuildNovel", "hideSection", hideSection) self.optState.setValue("GuiBuildNovel", "winWidth", winWidth) self.optState.setValue("GuiBuildNovel", "winHeight", winHeight) self.optState.setValue("GuiBuildNovel", "boxWidth", boxWidth)