Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow hiding scene and section titles in export builds #974

Merged
merged 1 commit into from
Jan 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions novelwriter/core/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
64 changes: 43 additions & 21 deletions novelwriter/tools/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand All @@ -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)
Expand Down