From 7379b8b521e3c414cd6020c81198ed4a09fa1ca7 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Mon, 14 Oct 2024 00:10:23 +0200 Subject: [PATCH] Remove plain heading style setting again --- novelwriter/core/buildsettings.py | 4 --- novelwriter/core/docbuild.py | 4 +++ novelwriter/core/tokenizer.py | 10 +++++++- novelwriter/tools/manussettings.py | 41 ++++++++---------------------- 4 files changed, 24 insertions(+), 35 deletions(-) diff --git a/novelwriter/core/buildsettings.py b/novelwriter/core/buildsettings.py index 955e7fd5..a9a8e18e 100644 --- a/novelwriter/core/buildsettings.py +++ b/novelwriter/core/buildsettings.py @@ -72,10 +72,6 @@ SETTINGS_TEMPLATE: dict[str, tuple[type, T_Basic]] = { "headings.breakPart": (bool, True), "headings.breakChapter": (bool, True), "headings.breakScene": (bool, False), - "headings.plainTitle": (bool, False), - "headings.plainPart": (bool, False), - "headings.plainChapter": (bool, False), - "headings.plainScene": (bool, False), "text.includeSynopsis": (bool, False), "text.includeComments": (bool, False), "text.includeKeywords": (bool, False), diff --git a/novelwriter/core/docbuild.py b/novelwriter/core/docbuild.py index 1ef2668a..c0d1ca39 100644 --- a/novelwriter/core/docbuild.py +++ b/novelwriter/core/docbuild.py @@ -321,6 +321,10 @@ class NWBuildDocument: self._build.getStr("headings.fmtSection"), self._build.getBool("headings.hideSection") ) + bldObj.setTitleStyle( + self._build.getBool("headings.centerPart"), + self._build.getBool("headings.breakPart") + ) bldObj.setPartitionStyle( self._build.getBool("headings.centerPart"), self._build.getBool("headings.breakPart") diff --git a/novelwriter/core/tokenizer.py b/novelwriter/core/tokenizer.py index 5110c732..1d158a2d 100644 --- a/novelwriter/core/tokenizer.py +++ b/novelwriter/core/tokenizer.py @@ -191,6 +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 @@ -307,6 +308,13 @@ class Tokenizer(ABC): self._hideSection = hide return + def setTitleStyle(self, center: bool, pageBreak: bool) -> None: + """Set the title heading style.""" + self._titleStyle = ( + (self.A_CENTRE if center else self.A_NONE) | (self.A_PBB if pageBreak else self.A_NONE) + ) + return + def setPartitionStyle(self, center: bool, pageBreak: bool) -> None: """Set the partition heading style.""" self._partStyle = ( @@ -663,7 +671,7 @@ class Tokenizer(ABC): nHead += 1 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) + tStyle = self.A_NONE if isPlain else self._titleStyle sHide = self._hidePart if isPlain else False if self._isNovel: if sHide: diff --git a/novelwriter/tools/manussettings.py b/novelwriter/tools/manussettings.py index ad7a9b69..8d552f54 100644 --- a/novelwriter/tools/manussettings.py +++ b/novelwriter/tools/manussettings.py @@ -734,55 +734,46 @@ class _HeadingsTab(NScrollablePage): self.layoutMatrix.setVerticalSpacing(vSp) self.layoutMatrix.setHorizontalSpacing(vSp) - self.layoutMatrix.addWidget(QLabel(self.tr("Plain Text"), self), 0, 1) - self.layoutMatrix.addWidget(QLabel(self.tr("Centre"), self), 0, 2) - self.layoutMatrix.addWidget(QLabel(self.tr("Page Break"), self), 0, 3) + self.layoutMatrix.addWidget(QLabel(self.tr("Centre"), self), 0, 1) + self.layoutMatrix.addWidget(QLabel(self.tr("Page Break"), self), 0, 2) # Title Layout self.lblTitle = QLabel(self._build.getLabel("headings.styleTitle"), self) - self.plainTitle = NSwitch(self, height=iPx) self.centerTitle = NSwitch(self, height=iPx) self.breakTitle = NSwitch(self, height=iPx) self.layoutMatrix.addWidget(self.lblTitle, 1, 0) - self.layoutMatrix.addWidget(self.plainTitle, 1, 1, QtAlignCenter) - self.layoutMatrix.addWidget(self.centerTitle, 1, 2, QtAlignCenter) - self.layoutMatrix.addWidget(self.breakTitle, 1, 3, QtAlignCenter) + self.layoutMatrix.addWidget(self.centerTitle, 1, 1, QtAlignCenter) + self.layoutMatrix.addWidget(self.breakTitle, 1, 2, QtAlignCenter) # Partition Layout self.lblPart = QLabel(self._build.getLabel("headings.stylePart"), self) - self.plainPart = NSwitch(self, height=iPx) self.centerPart = NSwitch(self, height=iPx) self.breakPart = NSwitch(self, height=iPx) self.layoutMatrix.addWidget(self.lblPart, 2, 0) - self.layoutMatrix.addWidget(self.plainPart, 2, 1, QtAlignCenter) - self.layoutMatrix.addWidget(self.centerPart, 2, 2, QtAlignCenter) - self.layoutMatrix.addWidget(self.breakPart, 2, 3, QtAlignCenter) + self.layoutMatrix.addWidget(self.centerPart, 2, 1, QtAlignCenter) + self.layoutMatrix.addWidget(self.breakPart, 2, 2, QtAlignCenter) # Chapter Layout self.lblChapter = QLabel(self._build.getLabel("headings.styleChapter"), self) - self.plainChapter = NSwitch(self, height=iPx) self.centerChapter = NSwitch(self, height=iPx) self.breakChapter = NSwitch(self, height=iPx) self.layoutMatrix.addWidget(self.lblChapter, 3, 0) - self.layoutMatrix.addWidget(self.plainChapter, 3, 1, QtAlignCenter) - self.layoutMatrix.addWidget(self.centerChapter, 3, 2, QtAlignCenter) - self.layoutMatrix.addWidget(self.breakChapter, 3, 3, QtAlignCenter) + self.layoutMatrix.addWidget(self.centerChapter, 3, 1, QtAlignCenter) + self.layoutMatrix.addWidget(self.breakChapter, 3, 2, QtAlignCenter) # Scene Layout self.lblScene = QLabel(self._build.getLabel("headings.styleScene"), self) - self.plainScene = NSwitch(self, height=iPx) self.centerScene = NSwitch(self, height=iPx) self.breakScene = NSwitch(self, height=iPx) self.layoutMatrix.addWidget(self.lblScene, 4, 0) - self.layoutMatrix.addWidget(self.plainScene, 4, 1, QtAlignCenter) - self.layoutMatrix.addWidget(self.centerScene, 4, 2, QtAlignCenter) - self.layoutMatrix.addWidget(self.breakScene, 4, 3, QtAlignCenter) + self.layoutMatrix.addWidget(self.centerScene, 4, 1, QtAlignCenter) + self.layoutMatrix.addWidget(self.breakScene, 4, 2, QtAlignCenter) - self.layoutMatrix.setColumnStretch(4, 1) + self.layoutMatrix.setColumnStretch(3, 1) # Assemble # ======== @@ -815,11 +806,6 @@ class _HeadingsTab(NScrollablePage): self.swtAScene.setChecked(self._build.getBool("headings.hideAltScene")) self.swtSection.setChecked(self._build.getBool("headings.hideSection")) - self.plainTitle.setChecked(self._build.getBool("headings.plainTitle")) - self.plainPart.setChecked(self._build.getBool("headings.plainPart")) - self.plainChapter.setChecked(self._build.getBool("headings.plainChapter")) - self.plainScene.setChecked(self._build.getBool("headings.plainScene")) - self.centerTitle.setChecked(self._build.getBool("headings.centerTitle")) self.centerPart.setChecked(self._build.getBool("headings.centerPart")) self.centerChapter.setChecked(self._build.getBool("headings.centerChapter")) @@ -840,11 +826,6 @@ class _HeadingsTab(NScrollablePage): self._build.setValue("headings.hideAltScene", self.swtAScene.isChecked()) self._build.setValue("headings.hideSection", self.swtSection.isChecked()) - self._build.setValue("headings.plainTitle", self.plainTitle.isChecked()) - self._build.setValue("headings.plainPart", self.plainPart.isChecked()) - self._build.setValue("headings.plainChapter", self.plainChapter.isChecked()) - self._build.setValue("headings.plainScene", self.plainScene.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())