Add a setting for nested ToC in Epub files

This commit is contained in:
Veronica Berglyd Olsen
2026-11-02 21:25:54 +01:00
parent 8a89fb604b
commit 6d931dc89b
2 changed files with 23 additions and 16 deletions

View File

@@ -138,6 +138,8 @@ SETTINGS_TEMPLATE: dict[str, tuple[type, T_BuildValue]] = {
"doc.pageCountOffset": (int, 0),
"doc.metaLanguage": (str, ""),
"epub.nestedToc": (bool, False),
"html.addStyles": (bool, True),
"html.preserveTabs": (bool, False),
}
@@ -213,6 +215,9 @@ SETTINGS_LABELS = {
"doc.pageCountOffset": QT_TRANSLATE_NOOP("Builds", "Page counter offset"),
"doc.metaLanguage": QT_TRANSLATE_NOOP("Builds", "Override document language"),
"epub": QT_TRANSLATE_NOOP("Builds", "EPUB Options"),
"epub.nestedToc": QT_TRANSLATE_NOOP("Builds", "Nested table of contents"),
"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"),

View File

@@ -1524,6 +1524,18 @@ class _FormattingTab(NScrollableForm):
self.addRow(self._build.getLabel("doc.metaLanguage"), [self.lblMetaLanguage, 8, self.metaLanguage])
# EPUB Document
# =============
title = self._build.getLabel("epub")
section += 1
self._sidebar.addButton(title, section)
self.addGroupLabel(title, section)
self.nestedToc = NSwitch(self, height=iPx)
self.addRow(self._build.getLabel("epub.nestedToc"), self.nestedToc)
# HTML Document
# =============
@@ -1597,8 +1609,6 @@ class _FormattingTab(NScrollableForm):
def loadContent(self) -> None:
"""Populate the widgets."""
# Text Content
# ============
self.incBodyText.setChecked(self._build.getBool("text.includeBodyText"))
self.incSynopsis.setChecked(self._build.getBool("text.includeSynopsis"))
self.incComments.setChecked(self._build.getBool("text.includeComments"))
@@ -1610,8 +1620,6 @@ class _FormattingTab(NScrollableForm):
self._updateIgnoredKeywords()
# Text Format
# ===========
font = QFont()
font.fromString(self._build.getStr("format.textFont"))
self._textFont = fontMatcher(font)
@@ -1629,23 +1637,17 @@ class _FormattingTab(NScrollableForm):
self.showDialogue.setChecked(self._build.getBool("format.showDialogue"))
# Heading Format
# ==============
self.colorHeadings.setChecked(self._build.getBool("format.colorHeadings"))
self.boldHeadings.setChecked(self._build.getBool("format.boldHeadings"))
self.upperHeadings.setChecked(self._build.getBool("format.upperHeadings"))
self.showStatus.setChecked(self._build.getBool("format.showStatus"))
# First Line Indent
# =================
self.firstIndent.setChecked(self._build.getBool("format.firstLineIndent"))
self.indentWidth.setValue(self._build.getFloat("format.firstIndentWidth"))
self.indentFirstPar.setChecked(self._build.getBool("format.indentFirstPar"))
# Text Margins
# ============
self.titleSize.setValue(self._build.getFloat("format.titleSize"))
self.h1Size.setValue(self._build.getFloat("format.h1Size"))
self.h2Size.setValue(self._build.getFloat("format.h2Size"))
@@ -1673,8 +1675,6 @@ class _FormattingTab(NScrollableForm):
self._updateTextMarginState()
# Page Layout
# ===========
pageUnit = self._build.getStr("format.pageUnit")
index = self.pageUnit.findData(pageUnit)
if index >= 0:
@@ -1703,8 +1703,6 @@ class _FormattingTab(NScrollableForm):
self.pageSize.currentIndexChanged.connect(self._changePageSize)
# Document
# ========
self.metaLanguage.setText(processLangCode(self._build.getStr("doc.metaLanguage")))
self.pageHeader.setText(self._build.getStr("doc.pageHeader"))
self.pageHeader.setCursorPosition(0)
@@ -1712,9 +1710,10 @@ class _FormattingTab(NScrollableForm):
self.pageHeaderEven.setCursorPosition(0)
self.pageCountOffset.setValue(self._build.getInt("doc.pageCountOffset"))
# HTML Document
# =============
# EPUB Document
self.nestedToc.setChecked(self._build.getBool("epub.nestedToc"))
# HTML Document
self.htmlAddStyles.setChecked(self._build.getBool("html.addStyles"))
self.htmlPreserveTabs.setChecked(self._build.getBool("html.preserveTabs"))
@@ -1801,6 +1800,9 @@ class _FormattingTab(NScrollableForm):
self.metaLanguage.setText(metaLanguage)
# EPUB Document
self._build.setValue("epub.nestedToc", self.nestedToc.isChecked())
# HTML Document
self._build.setValue("html.addStyles", self.htmlAddStyles.isChecked())
self._build.setValue("html.preserveTabs", self.htmlPreserveTabs.isChecked())