diff --git a/novelwriter/constants.py b/novelwriter/constants.py index 2f409d9a..9a871e4d 100644 --- a/novelwriter/constants.py +++ b/novelwriter/constants.py @@ -99,6 +99,7 @@ class nwHeaders: H_VALID = ("H0", "H1", "H2", "H3", "H4") H_LEVEL = {"H0": 0, "H1": 1, "H2": 2, "H3": 3, "H4": 4} + H_SIZES = {0: 1.00, 1: 2.00, 2: 1.75, 3: 1.50, 4: 1.25} class nwFiles: diff --git a/novelwriter/gui/dochighlight.py b/novelwriter/gui/dochighlight.py index 0e731032..c00f7b44 100644 --- a/novelwriter/gui/dochighlight.py +++ b/novelwriter/gui/dochighlight.py @@ -36,7 +36,7 @@ from PyQt5.QtGui import ( from novelwriter import CONFIG, SHARED from novelwriter.common import checkInt -from novelwriter.constants import nwRegEx, nwUnicode +from novelwriter.constants import nwHeaders, nwRegEx, nwUnicode from novelwriter.core.index import processComment from novelwriter.enum import nwComment from novelwriter.types import QRegExUnicode @@ -95,14 +95,14 @@ class GuiDocHighlighter(QSyntaxHighlighter): # Create Character Formats self._addCharFormat("text", SHARED.theme.colText) - self._addCharFormat("header1", SHARED.theme.colHead, "b", 1.8) - self._addCharFormat("header2", SHARED.theme.colHead, "b", 1.6) - self._addCharFormat("header3", SHARED.theme.colHead, "b", 1.4) - self._addCharFormat("header4", SHARED.theme.colHead, "b", 1.2) - self._addCharFormat("head1h", SHARED.theme.colHeadH, "b", 1.8) - self._addCharFormat("head2h", SHARED.theme.colHeadH, "b", 1.6) - self._addCharFormat("head3h", SHARED.theme.colHeadH, "b", 1.4) - self._addCharFormat("head4h", SHARED.theme.colHeadH, "b", 1.2) + self._addCharFormat("header1", SHARED.theme.colHead, "b", nwHeaders.H_SIZES[1]) + self._addCharFormat("header2", SHARED.theme.colHead, "b", nwHeaders.H_SIZES[2]) + self._addCharFormat("header3", SHARED.theme.colHead, "b", nwHeaders.H_SIZES[3]) + self._addCharFormat("header4", SHARED.theme.colHead, "b", nwHeaders.H_SIZES[4]) + self._addCharFormat("head1h", SHARED.theme.colHeadH, "b", nwHeaders.H_SIZES[1]) + self._addCharFormat("head2h", SHARED.theme.colHeadH, "b", nwHeaders.H_SIZES[2]) + self._addCharFormat("head3h", SHARED.theme.colHeadH, "b", nwHeaders.H_SIZES[3]) + self._addCharFormat("head4h", SHARED.theme.colHeadH, "b", nwHeaders.H_SIZES[4]) self._addCharFormat("bold", colEmph, "b") self._addCharFormat("italic", colEmph, "i") self._addCharFormat("strike", SHARED.theme.colHidden, "s") diff --git a/novelwriter/types.py b/novelwriter/types.py index a9fc015d..e4051f8e 100644 --- a/novelwriter/types.py +++ b/novelwriter/types.py @@ -24,7 +24,7 @@ along with this program. If not, see . from __future__ import annotations from PyQt5.QtCore import QRegularExpression, Qt -from PyQt5.QtGui import QColor, QPainter, QTextCursor +from PyQt5.QtGui import QColor, QPainter, QTextCursor, QTextFormat from PyQt5.QtWidgets import QDialogButtonBox, QSizePolicy, QStyle # Qt Alignment Flags @@ -44,6 +44,11 @@ QtAlignRightMiddle = Qt.AlignmentFlag.AlignRight | Qt.AlignmentFlag.AlignVCenter QtAlignRightTop = Qt.AlignmentFlag.AlignRight | Qt.AlignmentFlag.AlignTop QtAlignTop = Qt.AlignmentFlag.AlignTop +# Qt Page Break + +QtPageBreakBefore = QTextFormat.PageBreakFlag.PageBreak_AlwaysBefore +QtPageBreakAfter = QTextFormat.PageBreakFlag.PageBreak_AlwaysAfter + # Qt Painter Types QtTransparent = QColor(0, 0, 0, 0)