novelWriter 2.4.2__py3-none-any.whl → 2.5b1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. {novelWriter-2.4.2.dist-info → novelWriter-2.5b1.dist-info}/METADATA +4 -5
  2. {novelWriter-2.4.2.dist-info → novelWriter-2.5b1.dist-info}/RECORD +109 -101
  3. novelwriter/__init__.py +33 -39
  4. novelwriter/assets/i18n/project_en_GB.json +1 -0
  5. novelwriter/assets/icons/typicons_dark/icons.conf +2 -0
  6. novelwriter/assets/icons/typicons_dark/nw_font.svg +4 -0
  7. novelwriter/assets/icons/typicons_dark/nw_quote.svg +4 -0
  8. novelwriter/assets/icons/typicons_light/icons.conf +2 -0
  9. novelwriter/assets/icons/typicons_light/nw_font.svg +4 -0
  10. novelwriter/assets/icons/typicons_light/nw_quote.svg +4 -0
  11. novelwriter/assets/manual.pdf +0 -0
  12. novelwriter/assets/sample.zip +0 -0
  13. novelwriter/assets/syntax/cyberpunk_night.conf +5 -3
  14. novelwriter/assets/syntax/default_dark.conf +32 -18
  15. novelwriter/assets/syntax/default_light.conf +24 -10
  16. novelwriter/assets/syntax/dracula.conf +44 -0
  17. novelwriter/assets/syntax/grey_dark.conf +5 -4
  18. novelwriter/assets/syntax/grey_light.conf +5 -4
  19. novelwriter/assets/syntax/light_owl.conf +7 -6
  20. novelwriter/assets/syntax/night_owl.conf +7 -6
  21. novelwriter/assets/syntax/snazzy.conf +42 -0
  22. novelwriter/assets/syntax/solarized_dark.conf +4 -3
  23. novelwriter/assets/syntax/solarized_light.conf +4 -3
  24. novelwriter/assets/syntax/tango.conf +27 -11
  25. novelwriter/assets/syntax/tomorrow.conf +6 -5
  26. novelwriter/assets/syntax/tomorrow_night.conf +7 -6
  27. novelwriter/assets/syntax/tomorrow_night_blue.conf +6 -5
  28. novelwriter/assets/syntax/tomorrow_night_bright.conf +6 -5
  29. novelwriter/assets/syntax/tomorrow_night_eighties.conf +6 -5
  30. novelwriter/assets/text/credits_en.htm +4 -1
  31. novelwriter/assets/themes/cyberpunk_night.conf +2 -0
  32. novelwriter/assets/themes/default_dark.conf +1 -0
  33. novelwriter/assets/themes/default_light.conf +1 -0
  34. novelwriter/assets/themes/dracula.conf +47 -0
  35. novelwriter/assets/themes/solarized_dark.conf +1 -0
  36. novelwriter/assets/themes/solarized_light.conf +1 -0
  37. novelwriter/common.py +31 -9
  38. novelwriter/config.py +118 -84
  39. novelwriter/constants.py +40 -26
  40. novelwriter/core/buildsettings.py +63 -66
  41. novelwriter/core/coretools.py +2 -22
  42. novelwriter/core/docbuild.py +51 -40
  43. novelwriter/core/document.py +3 -5
  44. novelwriter/core/index.py +115 -45
  45. novelwriter/core/item.py +8 -19
  46. novelwriter/core/options.py +2 -4
  47. novelwriter/core/project.py +23 -57
  48. novelwriter/core/projectdata.py +1 -3
  49. novelwriter/core/projectxml.py +12 -15
  50. novelwriter/core/sessions.py +3 -5
  51. novelwriter/core/spellcheck.py +4 -9
  52. novelwriter/core/status.py +211 -164
  53. novelwriter/core/storage.py +0 -8
  54. novelwriter/core/tohtml.py +94 -100
  55. novelwriter/core/tokenizer.py +199 -112
  56. novelwriter/core/{tomd.py → tomarkdown.py} +97 -78
  57. novelwriter/core/toodt.py +212 -148
  58. novelwriter/core/toqdoc.py +403 -0
  59. novelwriter/core/tree.py +5 -7
  60. novelwriter/dialogs/about.py +3 -5
  61. novelwriter/dialogs/docmerge.py +1 -3
  62. novelwriter/dialogs/docsplit.py +1 -3
  63. novelwriter/dialogs/editlabel.py +0 -2
  64. novelwriter/dialogs/preferences.py +111 -88
  65. novelwriter/dialogs/projectsettings.py +216 -180
  66. novelwriter/dialogs/quotes.py +3 -4
  67. novelwriter/dialogs/wordlist.py +3 -9
  68. novelwriter/enum.py +31 -25
  69. novelwriter/error.py +8 -15
  70. novelwriter/extensions/circularprogress.py +5 -6
  71. novelwriter/extensions/configlayout.py +18 -18
  72. novelwriter/extensions/eventfilters.py +1 -5
  73. novelwriter/extensions/modified.py +50 -13
  74. novelwriter/extensions/novelselector.py +1 -3
  75. novelwriter/extensions/pagedsidebar.py +9 -12
  76. novelwriter/extensions/simpleprogress.py +1 -3
  77. novelwriter/extensions/statusled.py +1 -3
  78. novelwriter/extensions/switch.py +4 -6
  79. novelwriter/extensions/switchbox.py +7 -6
  80. novelwriter/extensions/versioninfo.py +3 -9
  81. novelwriter/gui/doceditor.py +132 -133
  82. novelwriter/gui/dochighlight.py +237 -183
  83. novelwriter/gui/docviewer.py +61 -97
  84. novelwriter/gui/docviewerpanel.py +3 -10
  85. novelwriter/gui/editordocument.py +1 -3
  86. novelwriter/gui/itemdetails.py +7 -11
  87. novelwriter/gui/mainmenu.py +11 -7
  88. novelwriter/gui/noveltree.py +11 -24
  89. novelwriter/gui/outline.py +11 -23
  90. novelwriter/gui/projtree.py +26 -43
  91. novelwriter/gui/search.py +1 -3
  92. novelwriter/gui/sidebar.py +2 -6
  93. novelwriter/gui/statusbar.py +6 -10
  94. novelwriter/gui/theme.py +26 -51
  95. novelwriter/guimain.py +50 -71
  96. novelwriter/shared.py +30 -15
  97. novelwriter/tools/dictionaries.py +12 -15
  98. novelwriter/tools/lipsum.py +2 -4
  99. novelwriter/tools/manusbuild.py +1 -3
  100. novelwriter/tools/manuscript.py +71 -144
  101. novelwriter/tools/manussettings.py +67 -73
  102. novelwriter/tools/noveldetails.py +6 -11
  103. novelwriter/tools/welcome.py +2 -16
  104. novelwriter/tools/writingstats.py +6 -9
  105. novelwriter/types.py +45 -3
  106. {novelWriter-2.4.2.dist-info → novelWriter-2.5b1.dist-info}/LICENSE.md +0 -0
  107. {novelWriter-2.4.2.dist-info → novelWriter-2.5b1.dist-info}/WHEEL +0 -0
  108. {novelWriter-2.4.2.dist-info → novelWriter-2.5b1.dist-info}/entry_points.txt +0 -0
  109. {novelWriter-2.4.2.dist-info → novelWriter-2.5b1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,403 @@
1
+ """
2
+ novelWriter – QTextDocument Converter
3
+ =====================================
4
+
5
+ File History:
6
+ Created: 2024-05-21 [2.5b1] ToQTextDocument
7
+
8
+ This file is a part of novelWriter
9
+ Copyright 2018–2024, Veronica Berglyd Olsen
10
+
11
+ This program is free software: you can redistribute it and/or modify
12
+ it under the terms of the GNU General Public License as published by
13
+ the Free Software Foundation, either version 3 of the License, or
14
+ (at your option) any later version.
15
+
16
+ This program is distributed in the hope that it will be useful, but
17
+ WITHOUT ANY WARRANTY; without even the implied warranty of
18
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19
+ General Public License for more details.
20
+
21
+ You should have received a copy of the GNU General Public License
22
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
23
+ """
24
+ from __future__ import annotations
25
+
26
+ import logging
27
+
28
+ from PyQt5.QtGui import (
29
+ QColor, QFont, QFontMetrics, QTextBlockFormat, QTextCharFormat,
30
+ QTextCursor, QTextDocument
31
+ )
32
+
33
+ from novelwriter.constants import nwHeaders, nwHeadFmt, nwKeyWords, nwLabels, nwUnicode
34
+ from novelwriter.core.project import NWProject
35
+ from novelwriter.core.tokenizer import T_Formats, Tokenizer
36
+ from novelwriter.types import (
37
+ QtAlignAbsolute, QtAlignCenter, QtAlignJustify, QtAlignLeft, QtAlignRight,
38
+ QtBlack, QtPageBreakAfter, QtPageBreakBefore, QtTransparent,
39
+ QtVAlignNormal, QtVAlignSub, QtVAlignSuper
40
+ )
41
+
42
+ logger = logging.getLogger(__name__)
43
+
44
+ T_TextStyle = tuple[QTextBlockFormat, QTextCharFormat]
45
+
46
+
47
+ class TextDocumentTheme:
48
+ text: QColor = QtBlack
49
+ highlight: QColor = QtTransparent
50
+ head: QColor = QtBlack
51
+ comment: QColor = QtBlack
52
+ note: QColor = QtBlack
53
+ code: QColor = QtBlack
54
+ modifier: QColor = QtBlack
55
+ keyword: QColor = QtBlack
56
+ tag: QColor = QtBlack
57
+ optional: QColor = QtBlack
58
+
59
+
60
+ def newBlock(cursor: QTextCursor, bFmt: QTextBlockFormat) -> None:
61
+ if cursor.position() > 0:
62
+ cursor.insertBlock(bFmt)
63
+ else:
64
+ cursor.setBlockFormat(bFmt)
65
+
66
+
67
+ class ToQTextDocument(Tokenizer):
68
+ """Core: QTextDocument Writer
69
+
70
+ Extend the Tokenizer class to generate a QTextDocument output. This
71
+ is intended for usage in the document viewer and build tool preview.
72
+ """
73
+
74
+ def __init__(self, project: NWProject) -> None:
75
+ super().__init__(project)
76
+ self._document = QTextDocument()
77
+ self._document.setUndoRedoEnabled(False)
78
+ self._document.setDocumentMargin(0)
79
+
80
+ self._theme = TextDocumentTheme()
81
+ self._styles: dict[int, T_TextStyle] = {}
82
+ self._usedNotes: dict[str, int] = {}
83
+
84
+ self._init = False
85
+ self._bold = QFont.Weight.Bold
86
+ self._normal = QFont.Weight.Normal
87
+
88
+ return
89
+
90
+ def initDocument(self, font: QFont, theme: TextDocumentTheme) -> None:
91
+ """Initialise all computed values of the document."""
92
+ self._textFont = font
93
+ self._theme = theme
94
+
95
+ self._document.setUndoRedoEnabled(False)
96
+ self._document.blockSignals(True)
97
+ self._document.clear()
98
+ self._document.setDefaultFont(self._textFont)
99
+
100
+ qMetric = QFontMetrics(self._textFont)
101
+ mScale = qMetric.height()
102
+ fPt = self._textFont.pointSizeF()
103
+
104
+ # Scaled Sizes
105
+ # ============
106
+
107
+ self._mHead = {
108
+ self.T_TITLE: (mScale * self._marginTitle[0], mScale * self._marginTitle[1]),
109
+ self.T_HEAD1: (mScale * self._marginHead1[0], mScale * self._marginHead1[1]),
110
+ self.T_HEAD2: (mScale * self._marginHead2[0], mScale * self._marginHead2[1]),
111
+ self.T_HEAD3: (mScale * self._marginHead3[0], mScale * self._marginHead3[1]),
112
+ self.T_HEAD4: (mScale * self._marginHead4[0], mScale * self._marginHead4[1]),
113
+ }
114
+
115
+ self._sHead = {
116
+ self.T_TITLE: nwHeaders.H_SIZES.get(0, 1.0) * fPt,
117
+ self.T_HEAD1: nwHeaders.H_SIZES.get(1, 1.0) * fPt,
118
+ self.T_HEAD2: nwHeaders.H_SIZES.get(2, 1.0) * fPt,
119
+ self.T_HEAD3: nwHeaders.H_SIZES.get(3, 1.0) * fPt,
120
+ self.T_HEAD4: nwHeaders.H_SIZES.get(4, 1.0) * fPt,
121
+ }
122
+
123
+ self._mText = (mScale * self._marginText[0], mScale * self._marginText[1])
124
+ self._mMeta = (mScale * self._marginMeta[0], mScale * self._marginMeta[1])
125
+ self._mSep = (mScale * self._marginSep[0], mScale * self._marginSep[1])
126
+
127
+ self._mIndent = mScale * 2.0
128
+
129
+ # Block Format
130
+ # ============
131
+
132
+ self._blockFmt = QTextBlockFormat()
133
+ self._blockFmt.setTopMargin(self._mText[0])
134
+ self._blockFmt.setBottomMargin(self._mText[1])
135
+ self._blockFmt.setAlignment(QtAlignJustify if self._doJustify else QtAlignAbsolute)
136
+
137
+ # Character Formats
138
+ # =================
139
+
140
+ self._cText = QTextCharFormat()
141
+ self._cText.setBackground(QtTransparent)
142
+ self._cText.setForeground(self._theme.text)
143
+
144
+ self._cHead = QTextCharFormat(self._cText)
145
+ self._cHead.setForeground(self._theme.head)
146
+
147
+ self._cComment = QTextCharFormat(self._cText)
148
+ self._cComment.setForeground(self._theme.comment)
149
+
150
+ self._cCommentMod = QTextCharFormat(self._cText)
151
+ self._cCommentMod.setForeground(self._theme.comment)
152
+ self._cCommentMod.setFontWeight(self._bold)
153
+
154
+ self._cNote = QTextCharFormat(self._cText)
155
+ self._cNote.setForeground(self._theme.note)
156
+
157
+ self._cCode = QTextCharFormat(self._cText)
158
+ self._cCode.setForeground(self._theme.code)
159
+
160
+ self._cModifier = QTextCharFormat(self._cText)
161
+ self._cModifier.setForeground(self._theme.modifier)
162
+ self._cModifier.setFontWeight(self._bold)
163
+
164
+ self._cKeyword = QTextCharFormat(self._cText)
165
+ self._cKeyword.setForeground(self._theme.keyword)
166
+
167
+ self._cTag = QTextCharFormat(self._cText)
168
+ self._cTag.setForeground(self._theme.tag)
169
+
170
+ self._cOptional = QTextCharFormat(self._cText)
171
+ self._cOptional.setForeground(self._theme.optional)
172
+
173
+ self._init = True
174
+
175
+ return
176
+
177
+ ##
178
+ # Properties
179
+ ##
180
+
181
+ @property
182
+ def document(self) -> QTextDocument:
183
+ """Return the document."""
184
+ return self._document
185
+
186
+ ##
187
+ # Class Methods
188
+ ##
189
+
190
+ def doConvert(self) -> None:
191
+ """Write text tokens into the document."""
192
+ if not self._init:
193
+ return
194
+
195
+ self._document.blockSignals(True)
196
+ cursor = QTextCursor(self._document)
197
+ cursor.movePosition(QTextCursor.MoveOperation.End)
198
+
199
+ for tType, nHead, tText, tFormat, tStyle in self._tokens:
200
+
201
+ # Styles
202
+ bFmt = QTextBlockFormat(self._blockFmt)
203
+ if tStyle is not None:
204
+ if tStyle & self.A_LEFT:
205
+ bFmt.setAlignment(QtAlignLeft)
206
+ elif tStyle & self.A_RIGHT:
207
+ bFmt.setAlignment(QtAlignRight)
208
+ elif tStyle & self.A_CENTRE:
209
+ bFmt.setAlignment(QtAlignCenter)
210
+ elif tStyle & self.A_JUSTIFY:
211
+ bFmt.setAlignment(QtAlignJustify)
212
+
213
+ if tStyle & self.A_PBB:
214
+ bFmt.setPageBreakPolicy(QtPageBreakBefore)
215
+ if tStyle & self.A_PBA:
216
+ bFmt.setPageBreakPolicy(QtPageBreakAfter)
217
+
218
+ if tStyle & self.A_Z_BTMMRG:
219
+ bFmt.setBottomMargin(0.0)
220
+ if tStyle & self.A_Z_TOPMRG:
221
+ bFmt.setTopMargin(0.0)
222
+
223
+ if tStyle & self.A_IND_L:
224
+ bFmt.setLeftMargin(self._mIndent)
225
+ if tStyle & self.A_IND_R:
226
+ bFmt.setRightMargin(self._mIndent)
227
+
228
+ if tType == self.T_TEXT:
229
+ newBlock(cursor, bFmt)
230
+ self._insertFragments(tText, tFormat, cursor, self._cText)
231
+
232
+ elif tType in self.L_HEADINGS:
233
+ bFmt, cFmt = self._genHeadStyle(tType, nHead, bFmt)
234
+ newBlock(cursor, bFmt)
235
+ cursor.insertText(tText.replace(nwHeadFmt.BR, "\n"), cFmt)
236
+
237
+ elif tType == self.T_SEP:
238
+ sFmt = QTextBlockFormat(bFmt)
239
+ sFmt.setTopMargin(self._mSep[0])
240
+ sFmt.setBottomMargin(self._mSep[1])
241
+ newBlock(cursor, sFmt)
242
+ cursor.insertText(tText, self._cText)
243
+
244
+ elif tType == self.T_SKIP:
245
+ newBlock(cursor, bFmt)
246
+ cursor.insertText(nwUnicode.U_NBSP, self._cText)
247
+
248
+ elif tType in self.L_SUMMARY and self._doSynopsis:
249
+ newBlock(cursor, bFmt)
250
+ modifier = self._localLookup(
251
+ "Short Description" if tType == self.T_SHORT else "Synopsis"
252
+ )
253
+ cursor.insertText(f"{modifier}: ", self._cModifier)
254
+ self._insertFragments(tText, tFormat, cursor, self._cNote)
255
+
256
+ elif tType == self.T_COMMENT and self._doComments:
257
+ newBlock(cursor, bFmt)
258
+ modifier = self._localLookup("Comment")
259
+ cursor.insertText(f"{modifier}: ", self._cCommentMod)
260
+ self._insertFragments(tText, tFormat, cursor, self._cComment)
261
+
262
+ elif tType == self.T_KEYWORD and self._doKeywords:
263
+ newBlock(cursor, bFmt)
264
+ self._insertKeywords(tText, cursor)
265
+
266
+ self._document.blockSignals(False)
267
+
268
+ return
269
+
270
+ def appendFootnotes(self) -> None:
271
+ """Append the footnotes in the buffer."""
272
+ if self._usedNotes:
273
+ self._document.blockSignals(True)
274
+
275
+ cursor = QTextCursor(self._document)
276
+ cursor.movePosition(QTextCursor.MoveOperation.End)
277
+
278
+ bFmt, cFmt = self._genHeadStyle(self.T_HEAD4, -1, self._blockFmt)
279
+ newBlock(cursor, bFmt)
280
+ cursor.insertText(self._localLookup("Footnotes"), cFmt)
281
+
282
+ for key, index in self._usedNotes.items():
283
+ if content := self._footnotes.get(key):
284
+ cFmt = QTextCharFormat(self._cCode)
285
+ cFmt.setAnchor(True)
286
+ cFmt.setAnchorNames([f"footnote_{index}"])
287
+ newBlock(cursor, self._blockFmt)
288
+ cursor.insertText(f"{index}. ", cFmt)
289
+ self._insertFragments(*content, cursor, self._cText)
290
+
291
+ self._document.blockSignals(False)
292
+
293
+ return
294
+
295
+ ##
296
+ # Internal Functions
297
+ ##
298
+
299
+ def _insertFragments(
300
+ self, text: str, tFmt: T_Formats, cursor: QTextCursor, dFmt: QTextCharFormat
301
+ ) -> None:
302
+ """Apply formatting tags to text."""
303
+ cFmt = QTextCharFormat(dFmt)
304
+ start = 0
305
+ temp = text.replace("\n", nwUnicode.U_LSEP)
306
+ for pos, fmt, data in tFmt:
307
+
308
+ # Insert buffer with previous format
309
+ cursor.insertText(temp[start:pos], cFmt)
310
+
311
+ # Construct next format
312
+ if fmt == self.FMT_B_B:
313
+ cFmt.setFontWeight(self._bold)
314
+ elif fmt == self.FMT_B_E:
315
+ cFmt.setFontWeight(self._normal)
316
+ elif fmt == self.FMT_I_B:
317
+ cFmt.setFontItalic(True)
318
+ elif fmt == self.FMT_I_E:
319
+ cFmt.setFontItalic(False)
320
+ elif fmt == self.FMT_D_B:
321
+ cFmt.setFontStrikeOut(True)
322
+ elif fmt == self.FMT_D_E:
323
+ cFmt.setFontStrikeOut(False)
324
+ elif fmt == self.FMT_U_B:
325
+ cFmt.setFontUnderline(True)
326
+ elif fmt == self.FMT_U_E:
327
+ cFmt.setFontUnderline(False)
328
+ elif fmt == self.FMT_M_B:
329
+ cFmt.setBackground(self._theme.highlight)
330
+ elif fmt == self.FMT_M_E:
331
+ cFmt.setBackground(QtTransparent)
332
+ elif fmt == self.FMT_SUP_B:
333
+ cFmt.setVerticalAlignment(QtVAlignSuper)
334
+ elif fmt == self.FMT_SUP_E:
335
+ cFmt.setVerticalAlignment(QtVAlignNormal)
336
+ elif fmt == self.FMT_SUB_B:
337
+ cFmt.setVerticalAlignment(QtVAlignSub)
338
+ elif fmt == self.FMT_SUB_E:
339
+ cFmt.setVerticalAlignment(QtVAlignNormal)
340
+ elif fmt == self.FMT_FNOTE:
341
+ xFmt = QTextCharFormat(self._cCode)
342
+ xFmt.setVerticalAlignment(QtVAlignSuper)
343
+ if data in self._footnotes:
344
+ index = len(self._usedNotes) + 1
345
+ self._usedNotes[data] = index
346
+ xFmt.setAnchor(True)
347
+ xFmt.setAnchorHref(f"#footnote_{index}")
348
+ xFmt.setFontUnderline(True)
349
+ cursor.insertText(f"[{index}]", xFmt)
350
+ else:
351
+ cursor.insertText("[ERR]", cFmt)
352
+
353
+ # Move pos for next pass
354
+ start = pos
355
+
356
+ # Insert whatever is left in the buffer
357
+ cursor.insertText(temp[start:], cFmt)
358
+
359
+ return
360
+
361
+ def _insertKeywords(self, text: str, cursor: QTextCursor) -> None:
362
+ """Apply Markdown formatting to keywords."""
363
+ valid, bits, _ = self._project.index.scanThis("@"+text)
364
+ if valid and bits:
365
+ key = f"{self._localLookup(nwLabels.KEY_NAME[bits[0]])}: "
366
+ cursor.insertText(key, self._cKeyword)
367
+ if (num := len(bits)) > 1:
368
+ if bits[0] == nwKeyWords.TAG_KEY:
369
+ one, two = self._project.index.parseValue(bits[1])
370
+ cFmt = QTextCharFormat(self._cTag)
371
+ cFmt.setAnchor(True)
372
+ cFmt.setAnchorNames([f"tag_{one}".lower()])
373
+ cursor.insertText(one, cFmt)
374
+ if two:
375
+ cursor.insertText(" | ", self._cText)
376
+ cursor.insertText(two, self._cOptional)
377
+ else:
378
+ for n, bit in enumerate(bits[1:], 2):
379
+ cFmt = QTextCharFormat(self._cTag)
380
+ cFmt.setFontUnderline(True)
381
+ cFmt.setAnchor(True)
382
+ cFmt.setAnchorHref(f"#tag_{bit}".lower())
383
+ cursor.insertText(bit, cFmt)
384
+ if n < num:
385
+ cursor.insertText(", ", self._cText)
386
+ return
387
+
388
+ def _genHeadStyle(self, hType: int, nHead: int, rFmt: QTextBlockFormat) -> T_TextStyle:
389
+ """Generate a heading style set."""
390
+ mTop, mBottom = self._mHead.get(hType, (0.0, 0.0))
391
+
392
+ bFmt = QTextBlockFormat(rFmt)
393
+ bFmt.setTopMargin(mTop)
394
+ bFmt.setBottomMargin(mBottom)
395
+
396
+ cFmt = QTextCharFormat(self._cText if hType == self.T_TITLE else self._cHead)
397
+ cFmt.setFontWeight(self._bold)
398
+ cFmt.setFontPointSize(self._sHead.get(hType, 1.0))
399
+ if nHead >= 0:
400
+ cFmt.setAnchorNames([f"{self._handle}:T{nHead:04d}"])
401
+ cFmt.setAnchor(True)
402
+
403
+ return bFmt, cFmt
novelwriter/core/tree.py CHANGED
@@ -23,18 +23,18 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
23
23
  """
24
24
  from __future__ import annotations
25
25
 
26
- import random
27
26
  import logging
27
+ import random
28
28
 
29
- from typing import TYPE_CHECKING, Literal, overload
30
- from pathlib import Path
31
29
  from collections.abc import Iterable, Iterator
30
+ from pathlib import Path
31
+ from typing import TYPE_CHECKING, Literal, overload
32
32
 
33
- from novelwriter.enum import nwItemClass, nwItemLayout, nwItemType
34
- from novelwriter.error import logException
35
33
  from novelwriter.common import isHandle
36
34
  from novelwriter.constants import nwFiles
37
35
  from novelwriter.core.item import NWItem
36
+ from novelwriter.enum import nwItemClass, nwItemLayout, nwItemType
37
+ from novelwriter.error import logException
38
38
 
39
39
  if TYPE_CHECKING: # pragma: no cover
40
40
  from novelwriter.core.project import NWProject
@@ -520,5 +520,3 @@ class NWTree:
520
520
  handle = self._makeHandle()
521
521
 
522
522
  return handle
523
-
524
- # END Class NWTree
@@ -27,20 +27,20 @@ import logging
27
27
 
28
28
  from PyQt5.QtGui import QCloseEvent, QColor
29
29
  from PyQt5.QtWidgets import (
30
- QDialog, QDialogButtonBox, QHBoxLayout, QLabel, QTextBrowser, QVBoxLayout,
31
- QWidget
30
+ QDialogButtonBox, QHBoxLayout, QLabel, QTextBrowser, QVBoxLayout, QWidget
32
31
  )
33
32
 
34
33
  from novelwriter import CONFIG, SHARED
35
34
  from novelwriter.common import cssCol, readTextFile
36
35
  from novelwriter.extensions.configlayout import NColourLabel
36
+ from novelwriter.extensions.modified import NNonBlockingDialog
37
37
  from novelwriter.extensions.versioninfo import VersionInfoWidget
38
38
  from novelwriter.types import QtAlignRightTop, QtDialogClose
39
39
 
40
40
  logger = logging.getLogger(__name__)
41
41
 
42
42
 
43
- class GuiAbout(QDialog):
43
+ class GuiAbout(NNonBlockingDialog):
44
44
 
45
45
  def __init__(self, parent: QWidget) -> None:
46
46
  super().__init__(parent=parent)
@@ -152,5 +152,3 @@ class GuiAbout(QDialog):
152
152
  f"QTextBrowser {{border: none; background: {baseCol};}} "
153
153
  )
154
154
  return
155
-
156
- # END Class GuiAbout
@@ -34,8 +34,8 @@ from PyQt5.QtWidgets import (
34
34
  )
35
35
 
36
36
  from novelwriter import CONFIG, SHARED
37
- from novelwriter.extensions.switch import NSwitch
38
37
  from novelwriter.extensions.configlayout import NColourLabel
38
+ from novelwriter.extensions.switch import NSwitch
39
39
  from novelwriter.types import QtDialogCancel, QtDialogOk, QtDialogReset, QtUserRole
40
40
 
41
41
  logger = logging.getLogger(__name__)
@@ -182,5 +182,3 @@ class GuiDocMerge(QDialog):
182
182
  self.listBox.addItem(newItem)
183
183
 
184
184
  return
185
-
186
- # END Class GuiDocMerge
@@ -34,8 +34,8 @@ from PyQt5.QtWidgets import (
34
34
  )
35
35
 
36
36
  from novelwriter import CONFIG, SHARED
37
- from novelwriter.extensions.switch import NSwitch
38
37
  from novelwriter.extensions.configlayout import NColourLabel
38
+ from novelwriter.extensions.switch import NSwitch
39
39
  from novelwriter.types import QtDialogCancel, QtDialogOk, QtUserRole
40
40
 
41
41
  logger = logging.getLogger(__name__)
@@ -257,5 +257,3 @@ class GuiDocSplit(QDialog):
257
257
  self.listBox.addItem(newItem)
258
258
 
259
259
  return
260
-
261
- # END Class GuiDocSplit
@@ -94,5 +94,3 @@ class GuiEditLabel(QDialog):
94
94
  accepted = cls.result() == QDialog.DialogCode.Accepted
95
95
  cls.deleteLater()
96
96
  return label, accepted
97
-
98
- # END Class GuiEditLabel