Add separate toggle for notes in viewer

This commit is contained in:
Veronica Berglyd Olsen
2025-06-19 20:30:54 +02:00
parent 03dcb63cf6
commit c598fdd009
2 changed files with 28 additions and 2 deletions
+5 -2
View File
@@ -85,8 +85,8 @@ class Config:
"showMultiSpaces", "showSessionTime", "showTabsNSpaces", "showViewerPanel", "showMultiSpaces", "showSessionTime", "showTabsNSpaces", "showViewerPanel",
"spellLanguage", "stopWhenIdle", "tabWidth", "textFont", "textMargin", "textWidth", "spellLanguage", "stopWhenIdle", "tabWidth", "textFont", "textMargin", "textWidth",
"themeMode", "useCharCount", "userIdleTime", "verPyQtString", "verPyQtValue", "themeMode", "useCharCount", "userIdleTime", "verPyQtString", "verPyQtValue",
"verPyString", "verQtString", "verQtValue", "viewComments", "viewPanePos", "viewSynopsis", "verPyString", "verQtString", "verQtValue", "viewComments", "viewNotes", "viewPanePos",
"welcomeWinSize", "viewSynopsis", "welcomeWinSize",
) )
LANG_NW = 1 LANG_NW = 1
@@ -249,6 +249,7 @@ class Config:
self.showSessionTime = True # Show the session time in the status bar self.showSessionTime = True # Show the session time in the status bar
self.viewComments = True # Comments are shown in the viewer self.viewComments = True # Comments are shown in the viewer
self.viewSynopsis = True # Synopsis is 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 # Search Box States
self.searchCase = False self.searchCase = False
@@ -713,6 +714,7 @@ class Config:
self.showSessionTime = conf.rdBool(sec, "showsessiontime", self.showSessionTime) self.showSessionTime = conf.rdBool(sec, "showsessiontime", self.showSessionTime)
self.viewComments = conf.rdBool(sec, "viewcomments", self.viewComments) self.viewComments = conf.rdBool(sec, "viewcomments", self.viewComments)
self.viewSynopsis = conf.rdBool(sec, "viewsynopsis", self.viewSynopsis) 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.searchCase = conf.rdBool(sec, "searchcase", self.searchCase)
self.searchWord = conf.rdBool(sec, "searchword", self.searchWord) self.searchWord = conf.rdBool(sec, "searchword", self.searchWord)
self.searchRegEx = conf.rdBool(sec, "searchregex", self.searchRegEx) self.searchRegEx = conf.rdBool(sec, "searchregex", self.searchRegEx)
@@ -840,6 +842,7 @@ class Config:
"showsessiontime": str(self.showSessionTime), "showsessiontime": str(self.showSessionTime),
"viewcomments": str(self.viewComments), "viewcomments": str(self.viewComments),
"viewsynopsis": str(self.viewSynopsis), "viewsynopsis": str(self.viewSynopsis),
"viewnotes": str(self.viewNotes),
"searchcase": str(self.searchCase), "searchcase": str(self.searchCase),
"searchword": str(self.searchWord), "searchword": str(self.searchWord),
"searchregex": str(self.searchRegEx), "searchregex": str(self.searchRegEx),
+23
View File
@@ -231,6 +231,8 @@ class GuiDocViewer(QTextBrowser):
qDoc.setCommentType(nwComment.PLAIN, CONFIG.viewComments) qDoc.setCommentType(nwComment.PLAIN, CONFIG.viewComments)
qDoc.setCommentType(nwComment.SYNOPSIS, CONFIG.viewSynopsis) qDoc.setCommentType(nwComment.SYNOPSIS, CONFIG.viewSynopsis)
qDoc.setCommentType(nwComment.SHORT, 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 # Be extra careful here to prevent crashes when first opening a
# project as a crash here leaves no way of recovering. # 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.toggled.connect(self._doToggleSynopsis)
self.showSynopsis.setToolTip(self.tr("Show Synopsis Comments")) 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 # Assemble Layout
self.outerBox = QHBoxLayout() self.outerBox = QHBoxLayout()
self.outerBox.addWidget(self.showHide, 0) self.outerBox.addWidget(self.showHide, 0)
self.outerBox.addStretch(1) self.outerBox.addStretch(1)
self.outerBox.addWidget(self.showComments, 0) self.outerBox.addWidget(self.showComments, 0)
self.outerBox.addWidget(self.showSynopsis, 0) self.outerBox.addWidget(self.showSynopsis, 0)
self.outerBox.addWidget(self.showNotes, 0)
self.outerBox.setSpacing(4) self.outerBox.setSpacing(4)
self.setLayout(self.outerBox) self.setLayout(self.outerBox)
@@ -942,6 +955,7 @@ class GuiDocViewFooter(QWidget):
self.setFont(SHARED.theme.guiFont) self.setFont(SHARED.theme.guiFont)
self.showComments.setFont(SHARED.theme.guiFontSmall) self.showComments.setFont(SHARED.theme.guiFontSmall)
self.showSynopsis.setFont(SHARED.theme.guiFontSmall) self.showSynopsis.setFont(SHARED.theme.guiFontSmall)
self.showNotes.setFont(SHARED.theme.guiFontSmall)
return return
def updateTheme(self) -> None: def updateTheme(self) -> None:
@@ -953,11 +967,13 @@ class GuiDocViewFooter(QWidget):
self.showHide.setThemeIcon("panel") self.showHide.setThemeIcon("panel")
self.showComments.setIcon(bulletIcon) self.showComments.setIcon(bulletIcon)
self.showSynopsis.setIcon(bulletIcon) self.showSynopsis.setIcon(bulletIcon)
self.showNotes.setIcon(bulletIcon)
buttonStyle = SHARED.theme.getStyleSheet(STYLES_MIN_TOOLBUTTON) buttonStyle = SHARED.theme.getStyleSheet(STYLES_MIN_TOOLBUTTON)
self.showHide.setStyleSheet(buttonStyle) self.showHide.setStyleSheet(buttonStyle)
self.showComments.setStyleSheet(buttonStyle) self.showComments.setStyleSheet(buttonStyle)
self.showSynopsis.setStyleSheet(buttonStyle) self.showSynopsis.setStyleSheet(buttonStyle)
self.showNotes.setStyleSheet(buttonStyle)
self.matchColors() self.matchColors()
@@ -992,3 +1008,10 @@ class GuiDocViewFooter(QWidget):
CONFIG.viewSynopsis = state CONFIG.viewSynopsis = state
self.docViewer.reloadText() self.docViewer.reloadText()
return 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