Merge branch 'main' into theme_tweaks

This commit is contained in:
Veronica Berglyd Olsen
2025-06-19 22:11:24 +02:00
committed by GitHub
40 changed files with 471 additions and 270 deletions
+35 -35
View File
@@ -10,68 +10,68 @@ licenseurl = https://github.com/primer/brand/blob/main/LICENSE
[Base]
base = #ffffff
default = #1f2328
faded = #59636e
red = #fa4549
faded = #8c959f
red = #cf222e
orange = #e16f24
yellow = #d4a72c
green = #2da44e
cyan = #339D9B
cyan = #339d9b
blue = #0969da
purple = #a475f9
purple = #8557db
[Project]
root = purple
root = #32383f
folder = orange
file = faded
title = green
chapter = red
scene = blue
file = #49bcb7
title = #116329
chapter = #2e934a
scene = #4ac26b
note = yellow
active = green
inactive = red
disabled = faded
active = #24292f
inactive = faded
disabled = #afb8c1
[Palette]
window = #eaeef2
windowtext = default
base = base
alternatebase = #dfe4e9
alternatebase = #dde3e8
text = default
tooltipbase = #fae17d
tooltiptext = #0c1117
button = #f6f8fa
tooltipbase = #fff8c5
tooltiptext = default
button = base
buttontext = default
brighttext = faded
highlight = #dafbe1
highlightedtext = #1a7f37
brighttext = base
highlight = green
highlightedtext = base
link = blue
linkvisited = blue
accent = #dafbe1
accent = green
[GUI]
helptext = faded
fadedtext = faded:128
errortext = #cf222e
helptext = #424a53
fadedtext = #8c959f
errortext = red
[Syntax]
background = base
text = faded
line = default:32
text = #424a53
line = #dde3e8
link = blue
headertext = default
headertag = faded:128
emphasis = green
dialog = default
altdialog = default
note = #d4a72c
hidden = faded:128
headertag = #8c959f
emphasis = #2e934a
dialog = #000000
altdialog = cyan
note = #bf8700
hidden = #8c959f
shortcode = #e85aad
keyword = blue
tag = #218bff
value = #fb8f44
value = orange
optional = #54aeff
spellcheckline = #cf222e
spellcheckline = #fa4549
errorline = cyan
replacetag = purple
modifier = orange
texthighlight = faded:32
modifier = #bc4c00
texthighlight = #a7fbbe
@@ -1,5 +1,5 @@
[Main]
name = Primer Dark
name = Primer Night
mode = dark
author = Myian (adaptation)
credit = GitHub Inc.
@@ -8,63 +8,63 @@ license = MIT License
licenseurl = https://github.com/primer/brand/blob/main/LICENSE
[Base]
base = #0c1117
base = #0d1117
default = #f0f6fc
faded = #a3b0be
faded = #6e7681
red = #ff7b72
orange = #ffa657
yellow = #f8e3a1
green = #7ee787
green = #56d364
cyan = #57CCC5
blue = #79c0ff
purple = #bc8cff
purple = #c398ff
[Project]
root = purple
root = default
folder = orange
file = default
title = green
chapter = red
scene = blue
file = #8adfd7
title = #238636
chapter = #56d364
scene = #aff5b4
note = yellow
active = green
inactive = red
disabled = faded
active = default
inactive = faded
disabled = #484f58
[Palette]
window = #141b23
window = #161b22
windowtext = default
base = base
alternatebase = #1e242a
alternatebase = #30363d
text = default
tooltipbase = yellow
tooltiptext = base
button = #212830
button = #21262d
buttontext = default
brighttext = default
highlight = #104C35
brighttext = base
highlight = #207c59
highlightedtext = default
link = blue
linkvisited = blue
accent = #104C35
accent = #207c59
[GUI]
helptext = faded
fadedtext = faded:128
helptext = #8b949e
fadedtext = #6e7681
errortext = #f85149
[Syntax]
background = base
text = faded
line = default:32
text = #b1bac4
line = #30363d
link = blue
headertext = default
headertag = faded
headertag = #b1bac4
emphasis = #97ee9e
dialog = default
altdialog = default
note = yellow
hidden = faded:128
dialog = #ffffff
altdialog = #8adfd7
note = #f8e3a1
hidden = faded
shortcode = #ff9bce
keyword = #4493f8
tag = blue
@@ -74,4 +74,4 @@ spellcheckline = #f85149
errorline = cyan
replacetag = purple
modifier = orange
texthighlight = faded:32
texthighlight = #104C35
+5 -2
View File
@@ -85,8 +85,8 @@ class Config:
"showMultiSpaces", "showSessionTime", "showTabsNSpaces", "showViewerPanel",
"spellLanguage", "stopWhenIdle", "tabWidth", "textFont", "textMargin", "textWidth",
"themeMode", "useCharCount", "userIdleTime", "verPyQtString", "verPyQtValue",
"verPyString", "verQtString", "verQtValue", "viewComments", "viewPanePos", "viewSynopsis",
"welcomeWinSize",
"verPyString", "verQtString", "verQtValue", "viewComments", "viewNotes", "viewPanePos",
"viewSynopsis", "welcomeWinSize",
)
LANG_NW = 1
@@ -249,6 +249,7 @@ class Config:
self.showSessionTime = True # Show the session time in the status bar
self.viewComments = True # Comments are shown in the viewer
self.viewSynopsis = True # Synopsis is shown in the viewer
self.viewNotes = True # Notes are shown in the viewer
# Search Box States
self.searchCase = False
@@ -713,6 +714,7 @@ class Config:
self.showSessionTime = conf.rdBool(sec, "showsessiontime", self.showSessionTime)
self.viewComments = conf.rdBool(sec, "viewcomments", self.viewComments)
self.viewSynopsis = conf.rdBool(sec, "viewsynopsis", self.viewSynopsis)
self.viewNotes = conf.rdBool(sec, "viewnotes", self.viewNotes)
self.searchCase = conf.rdBool(sec, "searchcase", self.searchCase)
self.searchWord = conf.rdBool(sec, "searchword", self.searchWord)
self.searchRegEx = conf.rdBool(sec, "searchregex", self.searchRegEx)
@@ -840,6 +842,7 @@ class Config:
"showsessiontime": str(self.showSessionTime),
"viewcomments": str(self.viewComments),
"viewsynopsis": str(self.viewSynopsis),
"viewnotes": str(self.viewNotes),
"searchcase": str(self.searchCase),
"searchword": str(self.searchWord),
"searchregex": str(self.searchRegEx),
+2 -2
View File
@@ -38,7 +38,7 @@ from novelwriter import __version__
from novelwriter.common import firstFloat, xmlElement, xmlSubElem
from novelwriter.constants import nwHeadFmt, nwStyles
from novelwriter.formats.shared import BlockFmt, BlockTyp, T_Formats, TextFmt, stripEscape
from novelwriter.formats.tokenizer import Tokenizer
from novelwriter.formats.tokenizer import COMMENT_BLOCKS, Tokenizer
from novelwriter.types import QtHexRgb
if TYPE_CHECKING:
@@ -296,7 +296,7 @@ class ToDocX(Tokenizer):
elif tType == BlockTyp.SKIP:
self._processFragments(par, S_NORM, "")
elif tType == BlockTyp.COMMENT:
elif tType in COMMENT_BLOCKS:
self._processFragments(par, S_META, tText, tFormat)
elif tType == BlockTyp.KEYWORD:
+2 -2
View File
@@ -32,7 +32,7 @@ from typing import TYPE_CHECKING
from novelwriter.common import formatTimeStamp
from novelwriter.constants import nwHtmlUnicode, nwStyles
from novelwriter.formats.shared import BlockFmt, BlockTyp, T_Formats, TextFmt, stripEscape
from novelwriter.formats.tokenizer import Tokenizer
from novelwriter.formats.tokenizer import COMMENT_BLOCKS, Tokenizer
from novelwriter.types import FONT_STYLE, FONT_WEIGHTS, QtHexRgb
if TYPE_CHECKING:
@@ -228,7 +228,7 @@ class ToHtml(Tokenizer):
elif tType == BlockTyp.SKIP:
lines.append(f"<p{hStyle}>&nbsp;</p>\n")
elif tType == BlockTyp.COMMENT:
elif tType in COMMENT_BLOCKS:
lines.append(f"<p class='comment'{hStyle}>{self._formatText(tText, tFmt)}</p>\n")
elif tType == BlockTyp.KEYWORD:
+21 -9
View File
@@ -71,11 +71,23 @@ COMMENT_STYLE = {
nwComment.COMMENT: ComStyle(),
nwComment.STORY: ComStyle("Story Structure", "modifier", "note"),
}
HEADINGS = [
COMMENT_TYPE = {
nwComment.PLAIN: BlockTyp.COMMENT,
nwComment.IGNORE: BlockTyp.COMMENT,
nwComment.SYNOPSIS: BlockTyp.SUMMARY,
nwComment.SHORT: BlockTyp.SUMMARY,
nwComment.NOTE: BlockTyp.NOTE,
nwComment.FOOTNOTE: BlockTyp.COMMENT,
nwComment.COMMENT: BlockTyp.COMMENT,
nwComment.STORY: BlockTyp.NOTE,
}
HEADING_BLOCKS = [
BlockTyp.TITLE, BlockTyp.PART, BlockTyp.HEAD1,
BlockTyp.HEAD2, BlockTyp.HEAD3, BlockTyp.HEAD4,
]
SKIP_INDENT = [*HEADINGS, BlockTyp.SEP, BlockTyp.SKIP]
COMMENT_BLOCKS = (BlockTyp.COMMENT, BlockTyp.SUMMARY, BlockTyp.NOTE)
META_BLOCKS = (BlockTyp.COMMENT, BlockTyp.SUMMARY, BlockTyp.NOTE, BlockTyp.KEYWORD)
SKIP_INDENT = [*HEADING_BLOCKS, BlockTyp.SEP, BlockTyp.SKIP]
B_EMPTY: T_Block = (BlockTyp.EMPTY, "", "", [], BlockFmt.NONE)
@@ -619,7 +631,7 @@ class Tokenizer(ABC):
bStyle = COMMENT_STYLE[cStyle]
tLine, tFmt = self._formatComment(bStyle, cKey, cText)
tBlocks.append((
BlockTyp.COMMENT, "", tLine, tFmt, tStyle
COMMENT_TYPE[cStyle], "", tLine, tFmt, tStyle
))
elif cStyle == nwComment.FOOTNOTE:
@@ -863,12 +875,12 @@ class Tokenizer(ABC):
# We don't need to keep the empty lines after this pass
pass
elif cBlock[0] == BlockTyp.KEYWORD:
# Adjust margins for lines in a list of keyword lines
elif cBlock[0] in (BlockTyp.KEYWORD, BlockTyp.NOTE):
# Adjust margins for lines in repeated meta blocks
aStyle = cBlock[4]
if pBlock[0] == BlockTyp.KEYWORD:
if pBlock[0] == cBlock[0]:
aStyle |= BlockFmt.Z_TOP
if nBlock[0] == BlockTyp.KEYWORD:
if nBlock[0] == cBlock[0]:
aStyle |= BlockFmt.Z_BTM
sBlocks.append((
cBlock[0], cBlock[1], cBlock[2], cBlock[3], aStyle
@@ -990,7 +1002,7 @@ class Tokenizer(ABC):
allWordChars += nPWChars
textWordChars += nPWChars
elif tType in HEADINGS:
elif tType in HEADING_BLOCKS:
titleCount += 1
allWords += nWords
titleWords += nWords
@@ -1004,7 +1016,7 @@ class Tokenizer(ABC):
allChars += nChars
allWordChars += nWChars
elif tType in (BlockTyp.COMMENT, BlockTyp.KEYWORD):
elif tType in META_BLOCKS:
words = tText.split()
allWords += len(words)
allChars += len(tText)
+2 -2
View File
@@ -29,7 +29,7 @@ from typing import TYPE_CHECKING
from novelwriter.constants import nwUnicode
from novelwriter.formats.shared import BlockFmt, BlockTyp, T_Formats, TextFmt
from novelwriter.formats.tokenizer import Tokenizer
from novelwriter.formats.tokenizer import COMMENT_BLOCKS, Tokenizer
if TYPE_CHECKING:
from pathlib import Path
@@ -144,7 +144,7 @@ class ToMarkdown(Tokenizer):
elif tType == BlockTyp.SKIP:
lines.append(f"{cSkip}\n\n")
elif tType == BlockTyp.COMMENT:
elif tType in COMMENT_BLOCKS:
lines.append(f"{self._formatText(tText, tFormat, mTags)}\n\n")
elif tType == BlockTyp.KEYWORD:
+2 -2
View File
@@ -40,7 +40,7 @@ from novelwriter import __version__
from novelwriter.common import xmlElement, xmlIndent, xmlSubElem
from novelwriter.constants import nwHeadFmt, nwStyles
from novelwriter.formats.shared import BlockFmt, BlockTyp, TextFmt, stripEscape
from novelwriter.formats.tokenizer import Tokenizer
from novelwriter.formats.tokenizer import COMMENT_BLOCKS, Tokenizer
from novelwriter.types import FONT_STYLE, QtHexRgb
if TYPE_CHECKING:
@@ -389,7 +389,7 @@ class ToOdt(Tokenizer):
elif tType == BlockTyp.SKIP:
self._addTextPar(xText, S_TEXT, oStyle, "")
elif tType == BlockTyp.COMMENT:
elif tType in COMMENT_BLOCKS:
self._addTextPar(xText, S_META, oStyle, tText, tFmt=tFormat)
elif tType == BlockTyp.KEYWORD:
+8 -4
View File
@@ -37,7 +37,7 @@ from PyQt6.QtPrintSupport import QPrinter
from novelwriter import __version__
from novelwriter.constants import nwStyles, nwUnicode
from novelwriter.formats.shared import BlockFmt, BlockTyp, T_Formats, TextFmt, stripEscape
from novelwriter.formats.tokenizer import HEADINGS, Tokenizer
from novelwriter.formats.tokenizer import HEADING_BLOCKS, META_BLOCKS, Tokenizer
from novelwriter.types import (
QtAlignAbsolute, QtAlignCenter, QtAlignJustify, QtAlignLeft, QtAlignRight,
QtKeepAnchor, QtMoveAnchor, QtPageBreakAfter, QtPageBreakAuto,
@@ -214,7 +214,7 @@ class ToQTextDocument(Tokenizer):
for tType, tMeta, tText, tFormat, tStyle in self._blocks:
bFmt = QTextBlockFormat(self._blockFmt)
if tType in (BlockTyp.COMMENT, BlockTyp.KEYWORD):
if tType in META_BLOCKS:
bFmt.setTopMargin(self._mMeta[0])
bFmt.setBottomMargin(self._mMeta[1])
elif tType == BlockTyp.SEP:
@@ -248,17 +248,21 @@ class ToQTextDocument(Tokenizer):
if tStyle & BlockFmt.IND_T:
bFmt.setTextIndent(self._tIndent)
if tType in (BlockTyp.TEXT, BlockTyp.COMMENT, BlockTyp.KEYWORD):
if tType == BlockTyp.TEXT:
newBlock(cursor, bFmt)
self._insertFragments(tText, tFormat, cursor, self._charFmt)
elif tType in HEADINGS:
elif tType in HEADING_BLOCKS:
bFmt, cFmt = self._genHeadStyle(tType, tMeta, bFmt)
for tPart in tText.split("\n"):
newBlock(cursor, bFmt)
cursor.insertText(tPart, cFmt)
bFmt.setPageBreakPolicy(QtPageBreakAuto)
elif tType in META_BLOCKS:
newBlock(cursor, bFmt)
self._insertFragments(tText, tFormat, cursor, self._charFmt)
elif tType == BlockTyp.SEP:
newBlock(cursor, bFmt)
cursor.insertText(tText, self._charFmt)
+23
View File
@@ -231,6 +231,8 @@ class GuiDocViewer(QTextBrowser):
qDoc.setCommentType(nwComment.PLAIN, CONFIG.viewComments)
qDoc.setCommentType(nwComment.SYNOPSIS, CONFIG.viewSynopsis)
qDoc.setCommentType(nwComment.SHORT, CONFIG.viewSynopsis)
qDoc.setCommentType(nwComment.STORY, CONFIG.viewNotes)
qDoc.setCommentType(nwComment.NOTE, CONFIG.viewNotes)
# Be extra careful here to prevent crashes when first opening a
# project as a crash here leaves no way of recovering.
@@ -911,12 +913,23 @@ class GuiDocViewFooter(QWidget):
self.showSynopsis.toggled.connect(self._doToggleSynopsis)
self.showSynopsis.setToolTip(self.tr("Show Synopsis Comments"))
# Show Notes
self.showNotes = QToolButton(self)
self.showNotes.setText(self.tr("Notes"))
self.showNotes.setCheckable(True)
self.showNotes.setChecked(CONFIG.viewNotes)
self.showNotes.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon)
self.showNotes.setIconSize(iSz)
self.showNotes.toggled.connect(self._doToggleNotes)
self.showNotes.setToolTip(self.tr("Show Notes"))
# Assemble Layout
self.outerBox = QHBoxLayout()
self.outerBox.addWidget(self.showHide, 0)
self.outerBox.addStretch(1)
self.outerBox.addWidget(self.showComments, 0)
self.outerBox.addWidget(self.showSynopsis, 0)
self.outerBox.addWidget(self.showNotes, 0)
self.outerBox.setSpacing(4)
self.setLayout(self.outerBox)
@@ -942,6 +955,7 @@ class GuiDocViewFooter(QWidget):
self.setFont(SHARED.theme.guiFont)
self.showComments.setFont(SHARED.theme.guiFontSmall)
self.showSynopsis.setFont(SHARED.theme.guiFontSmall)
self.showNotes.setFont(SHARED.theme.guiFontSmall)
return
def updateTheme(self) -> None:
@@ -953,11 +967,13 @@ class GuiDocViewFooter(QWidget):
self.showHide.setThemeIcon("panel")
self.showComments.setIcon(bulletIcon)
self.showSynopsis.setIcon(bulletIcon)
self.showNotes.setIcon(bulletIcon)
buttonStyle = SHARED.theme.getStyleSheet(STYLES_MIN_TOOLBUTTON)
self.showHide.setStyleSheet(buttonStyle)
self.showComments.setStyleSheet(buttonStyle)
self.showSynopsis.setStyleSheet(buttonStyle)
self.showNotes.setStyleSheet(buttonStyle)
self.matchColors()
@@ -992,3 +1008,10 @@ class GuiDocViewFooter(QWidget):
CONFIG.viewSynopsis = state
self.docViewer.reloadText()
return
@pyqtSlot(bool)
def _doToggleNotes(self, state: bool) -> None:
"""Toggle the view notes button and reload the document."""
CONFIG.viewNotes = state
self.docViewer.reloadText()
return