diff --git a/novelwriter/core/itemmodel.py b/novelwriter/core/itemmodel.py
index 6fb2580a..ac7cb738 100644
--- a/novelwriter/core/itemmodel.py
+++ b/novelwriter/core/itemmodel.py
@@ -45,16 +45,18 @@ logger = logging.getLogger(__name__)
INV_ROOT = "invisibleRoot"
C_FACTOR = 0x0100
-C_LABEL_TEXT = 0x0000 | Qt.ItemDataRole.DisplayRole
-C_LABEL_ICON = 0x0000 | Qt.ItemDataRole.DecorationRole
-C_LABEL_FONT = 0x0000 | Qt.ItemDataRole.FontRole
-C_COUNT_TEXT = 0x0100 | Qt.ItemDataRole.DisplayRole
-C_COUNT_ICON = 0x0100 | Qt.ItemDataRole.DecorationRole
-C_COUNT_ALIGN = 0x0100 | Qt.ItemDataRole.TextAlignmentRole
-C_ACTIVE_ICON = 0x0200 | Qt.ItemDataRole.DecorationRole
-C_ACTIVE_TIP = 0x0200 | Qt.ItemDataRole.ToolTipRole
-C_STATUS_ICON = 0x0300 | Qt.ItemDataRole.DecorationRole
-C_STATUS_TIP = 0x0300 | Qt.ItemDataRole.ToolTipRole
+C_LABEL_TEXT = 0x0000 | Qt.ItemDataRole.DisplayRole
+C_LABEL_ICON = 0x0000 | Qt.ItemDataRole.DecorationRole
+C_LABEL_FONT = 0x0000 | Qt.ItemDataRole.FontRole
+C_COUNT_TEXT = 0x0100 | Qt.ItemDataRole.DisplayRole
+C_COUNT_ICON = 0x0100 | Qt.ItemDataRole.DecorationRole
+C_COUNT_ALIGN = 0x0100 | Qt.ItemDataRole.TextAlignmentRole
+C_ACTIVE_ICON = 0x0200 | Qt.ItemDataRole.DecorationRole
+C_ACTIVE_TIP = 0x0200 | Qt.ItemDataRole.ToolTipRole
+C_ACTIVE_ACCESS = 0x0200 | Qt.ItemDataRole.AccessibleTextRole
+C_STATUS_ICON = 0x0300 | Qt.ItemDataRole.DecorationRole
+C_STATUS_TIP = 0x0300 | Qt.ItemDataRole.ToolTipRole
+C_STATUS_ACCESS = 0x0300 | Qt.ItemDataRole.AccessibleTextRole
NODE_FLAGS = Qt.ItemFlag.ItemIsEnabled
NODE_FLAGS |= Qt.ItemFlag.ItemIsSelectable
@@ -150,13 +152,15 @@ class ProjectNode:
# Active
aText, aIcon = self._item.getActiveStatus()
- self._cache[C_ACTIVE_TIP] = aText
self._cache[C_ACTIVE_ICON] = aIcon
+ self._cache[C_ACTIVE_TIP] = aText
+ self._cache[C_ACTIVE_ACCESS] = aText
# Status
sText, sIcon = self._item.getImportStatus()
- self._cache[C_STATUS_TIP] = sText
self._cache[C_STATUS_ICON] = sIcon
+ self._cache[C_STATUS_TIP] = sText
+ self._cache[C_STATUS_ACCESS] = sText
return
diff --git a/novelwriter/core/novelmodel.py b/novelwriter/core/novelmodel.py
index e5b49b15..0447f526 100644
--- a/novelwriter/core/novelmodel.py
+++ b/novelwriter/core/novelmodel.py
@@ -46,6 +46,7 @@ R_TEXT = Qt.ItemDataRole.DisplayRole
R_ICON = Qt.ItemDataRole.DecorationRole
R_ALIGN = Qt.ItemDataRole.TextAlignmentRole
R_TIP = Qt.ItemDataRole.ToolTipRole
+R_ACCESS = Qt.ItemDataRole.AccessibleTextRole
R_HANDLE = 0xff01
R_KEY = 0xff02
@@ -217,6 +218,7 @@ class NovelModel(QAbstractTableModel):
text = ", ".join(refs)
data[C_FACTOR*2 | R_TEXT] = text
data[C_FACTOR*2 | R_TIP] = f"{self._extraLabel}: {text}"
+ data[C_FACTOR*2 | R_ACCESS] = f"{self._extraLabel}: {text}"
data[C_FACTOR*3 | R_ICON] = self._more
data[R_HANDLE] = handle
data[R_KEY] = key
diff --git a/novelwriter/dialogs/docmerge.py b/novelwriter/dialogs/docmerge.py
index 97717dc6..9345efd6 100644
--- a/novelwriter/dialogs/docmerge.py
+++ b/novelwriter/dialogs/docmerge.py
@@ -73,8 +73,9 @@ class GuiDocMerge(NDialog):
self.listBox.setDragDropMode(QAbstractItemView.DragDropMode.InternalMove)
# Merge Options
- self.trashLabel = QLabel(self.tr("Move merged items to Trash"), self)
self.trashSwitch = NSwitch(self, height=iPx)
+ self.trashLabel = QLabel(self.tr("Move merged items to Trash"), self)
+ self.trashLabel.setBuddy(self.trashSwitch)
self.optBox = QGridLayout()
self.optBox.addWidget(self.trashLabel, 0, 0)
diff --git a/novelwriter/dialogs/docsplit.py b/novelwriter/dialogs/docsplit.py
index 3f1f34ad..a67aafa7 100644
--- a/novelwriter/dialogs/docsplit.py
+++ b/novelwriter/dialogs/docsplit.py
@@ -90,16 +90,19 @@ class GuiDocSplit(NDialog):
self.splitLevel.currentIndexChanged.connect(self._reloadList)
# Split Options
- self.folderLabel = QLabel(self.tr("Split into a new folder"), self)
self.folderSwitch = NSwitch(self, height=iPx)
self.folderSwitch.setChecked(intoFolder)
+ self.folderLabel = QLabel(self.tr("Split into a new folder"), self)
+ self.folderLabel.setBuddy(self.folderSwitch)
- self.hierarchyLabel = QLabel(self.tr("Create document hierarchy"), self)
self.hierarchySwitch = NSwitch(self, height=iPx)
self.hierarchySwitch.setChecked(docHierarchy)
+ self.hierarchyLabel = QLabel(self.tr("Create document hierarchy"), self)
+ self.hierarchyLabel.setBuddy(self.hierarchySwitch)
- self.trashLabel = QLabel(self.tr("Move split document to Trash"), self)
self.trashSwitch = NSwitch(self, height=iPx)
+ self.trashLabel = QLabel(self.tr("Move split document to Trash"), self)
+ self.trashLabel.setBuddy(self.trashSwitch)
self.optBox = QGridLayout()
self.optBox.addWidget(self.folderLabel, 0, 0)
diff --git a/novelwriter/dialogs/editlabel.py b/novelwriter/dialogs/editlabel.py
index 5386acb4..97bb269c 100644
--- a/novelwriter/dialogs/editlabel.py
+++ b/novelwriter/dialogs/editlabel.py
@@ -43,11 +43,14 @@ class GuiEditLabel(NDialog):
self.setWindowTitle(self.tr("Item Label"))
# Item Label
- self.labelValue = QLineEdit(self)
- self.labelValue.setMinimumWidth(220)
- self.labelValue.setMaxLength(200)
- self.labelValue.setText(text)
- self.labelValue.selectAll()
+ self.edtValue = QLineEdit(self)
+ self.edtValue.setMinimumWidth(220)
+ self.edtValue.setMaxLength(200)
+ self.edtValue.setText(text)
+ self.edtValue.selectAll()
+
+ self.lblValue = QLabel(self.tr("Label"), self)
+ self.lblValue.setBuddy(self.lblValue)
# Buttons
self.buttonBox = QDialogButtonBox(QtDialogOk | QtDialogCancel, self)
@@ -56,8 +59,8 @@ class GuiEditLabel(NDialog):
# Assemble
self.innerBox = QHBoxLayout()
- self.innerBox.addWidget(QLabel(self.tr("Label"), self), 0)
- self.innerBox.addWidget(self.labelValue, 1)
+ self.innerBox.addWidget(self.lblValue, 0)
+ self.innerBox.addWidget(self.edtValue, 1)
self.innerBox.setSpacing(12)
self.outerBox = QVBoxLayout()
@@ -77,7 +80,7 @@ class GuiEditLabel(NDialog):
@property
def itemLabel(self) -> str:
- return self.labelValue.text()
+ return self.edtValue.text()
@classmethod
def getLabel(cls, parent: QWidget, text: str) -> tuple[str, bool]:
diff --git a/novelwriter/dialogs/preferences.py b/novelwriter/dialogs/preferences.py
index f98374af..bf330101 100644
--- a/novelwriter/dialogs/preferences.py
+++ b/novelwriter/dialogs/preferences.py
@@ -80,6 +80,7 @@ class GuiPreferences(NDialog):
# SideBar
self.sidebar = NPagedSideBar(self)
self.sidebar.setLabelColor(SHARED.theme.helpText)
+ self.sidebar.setAccessibleName(self.titleLabel.text())
self.sidebar.buttonClicked.connect(self._sidebarClicked)
# Form
diff --git a/novelwriter/dialogs/projectsettings.py b/novelwriter/dialogs/projectsettings.py
index 9c8190be..623be345 100644
--- a/novelwriter/dialogs/projectsettings.py
+++ b/novelwriter/dialogs/projectsettings.py
@@ -86,6 +86,7 @@ class GuiProjectSettings(NDialog):
# SideBar
self.sidebar = NPagedSideBar(self)
self.sidebar.setLabelColor(SHARED.theme.helpText)
+ self.sidebar.setAccessibleName(self.titleLabel.text())
self.sidebar.addButton(self.tr("Settings"), self.PAGE_SETTINGS)
self.sidebar.addButton(self.tr("Status"), self.PAGE_STATUS)
self.sidebar.addButton(self.tr("Importance"), self.PAGE_IMPORT)
@@ -349,6 +350,7 @@ class _StatusPage(NFixedPage):
self.listBox.setHeaderLabels([self.tr("Label"), self.tr("Usage")])
self.listBox.setColumnWidth(self.C_LABEL, wCol0)
self.listBox.setIndentation(0)
+ self.listBox.setAccessibleName(pageLabel)
self.listBox.setSelectionBehavior(QAbstractItemView.SelectionBehavior.SelectRows)
self.listBox.setSelectionMode(QAbstractItemView.SelectionMode.SingleSelection)
self.listBox.itemSelectionChanged.connect(self._onSelectionChanged)
@@ -686,6 +688,7 @@ class _ReplacePage(NFixedPage):
self.listBox.setHeaderLabels([self.tr("Keyword"), self.tr("Replace With")])
self.listBox.setColumnWidth(self.C_KEY, wCol0)
self.listBox.setIndentation(0)
+ self.listBox.setAccessibleName(self.pageTitle.text())
self.listBox.setSelectionBehavior(QAbstractItemView.SelectionBehavior.SelectRows)
self.listBox.setSelectionMode(QAbstractItemView.SelectionMode.SingleSelection)
self.listBox.itemSelectionChanged.connect(self._onSelectionChanged)
diff --git a/novelwriter/extensions/configlayout.py b/novelwriter/extensions/configlayout.py
index 8183f9a9..b82a0997 100644
--- a/novelwriter/extensions/configlayout.py
+++ b/novelwriter/extensions/configlayout.py
@@ -211,7 +211,8 @@ class NScrollableForm(QScrollArea):
else:
qWidget = widget
- qLabel = QLabel(label or "", self)
+ text = label or ""
+ qLabel = QLabel(text, self)
qLabel.setIndent(self._indent)
qLabel.setBuddy(qWidget)
@@ -227,6 +228,7 @@ class NScrollableForm(QScrollArea):
row.addLayout(labelBox, stretch[0])
if editable:
self._editable[editable] = qHelp
+ text = f"{text}: {helpText}"
else:
row.addWidget(qLabel, stretch[0])
@@ -235,6 +237,7 @@ class NScrollableForm(QScrollArea):
box.addWidget(qWidget, 1)
box.addWidget(QLabel(unit, self), 0)
row.addLayout(box, stretch[1])
+ text = f"{text} Unit: {unit}"
elif isinstance(button, QAbstractButton):
box = QHBoxLayout()
box.addWidget(qWidget, 1)
@@ -243,10 +246,11 @@ class NScrollableForm(QScrollArea):
else:
row.addWidget(qWidget, stretch[1])
+ self._first = False
self._layout.addLayout(row)
if label:
self._index[label.strip()] = qWidget
- self._first = False
+ qLabel.setAccessibleName(text)
return
diff --git a/novelwriter/extensions/switch.py b/novelwriter/extensions/switch.py
index 421fb712..4699d50a 100644
--- a/novelwriter/extensions/switch.py
+++ b/novelwriter/extensions/switch.py
@@ -23,12 +23,12 @@ along with this program. If not, see .
"""
from __future__ import annotations
-from PyQt6.QtCore import QPropertyAnimation, Qt, pyqtProperty # pyright: ignore
-from PyQt6.QtGui import QEnterEvent, QMouseEvent, QPainter, QPaintEvent, QResizeEvent
+from PyQt6.QtCore import QPropertyAnimation, Qt, pyqtProperty, pyqtSlot # pyright: ignore
+from PyQt6.QtGui import QEnterEvent, QPainter, QPaintEvent, QResizeEvent
from PyQt6.QtWidgets import QAbstractButton, QWidget
from novelwriter import SHARED
-from novelwriter.types import QtMouseLeft, QtNoPen, QtPaintAntiAlias, QtSizeFixed
+from novelwriter.types import QtNoPen, QtPaintAntiAlias, QtSizeFixed
class NSwitch(QAbstractButton):
@@ -50,6 +50,8 @@ class NSwitch(QAbstractButton):
self.setFixedHeight(self._xH)
self._offset = self._xR
+ self.clicked.connect(self._onClick)
+
return
##
@@ -94,7 +96,7 @@ class NSwitch(QAbstractButton):
painter.setRenderHint(QtPaintAntiAlias, True)
painter.setOpacity(1.0 if self.isEnabled() else 0.5)
- painter.setPen(palette.mid().color())
+ painter.setPen(palette.highlight().color() if self.hasFocus() else palette.mid().color())
painter.setBrush(palette.highlight() if self.isChecked() else palette.alternateBase())
painter.drawRoundedRect(0, 0, self._xW, self._xH, self._xR, self._xR)
@@ -106,19 +108,18 @@ class NSwitch(QAbstractButton):
return
- def mouseReleaseEvent(self, event: QMouseEvent) -> None:
- """Animate the switch on mouse release."""
- super().mouseReleaseEvent(event)
- if event.button() == QtMouseLeft:
- anim = QPropertyAnimation(self, b"offset", self)
- anim.setDuration(120)
- anim.setStartValue(self._offset)
- anim.setEndValue((self._xW - self._xR) if self.isChecked() else self._xR)
- anim.start()
- return
-
def enterEvent(self, event: QEnterEvent) -> None:
"""Change the cursor when hovering the button."""
self.setCursor(Qt.CursorShape.PointingHandCursor)
super().enterEvent(event)
return
+
+ @pyqtSlot(bool)
+ def _onClick(self, checked: bool) -> None:
+ """Animate the toggle action."""
+ anim = QPropertyAnimation(self, b"offset", self)
+ anim.setDuration(120)
+ anim.setStartValue(self._offset)
+ anim.setEndValue((self._xW - self._xR) if checked else self._xR)
+ anim.start()
+ return
diff --git a/novelwriter/extensions/switchbox.py b/novelwriter/extensions/switchbox.py
index c43def8a..e4732f97 100644
--- a/novelwriter/extensions/switchbox.py
+++ b/novelwriter/extensions/switchbox.py
@@ -100,6 +100,7 @@ class NSwitchBox(QScrollArea):
switch.toggled.connect(lambda state: self._emitSwitchSignal(identifier, state))
self._content.addWidget(switch, self._index, 2, QtAlignRight)
+ label.setBuddy(switch)
self._widgets.append(switch)
self._bumpIndex()
diff --git a/novelwriter/gui/noveltree.py b/novelwriter/gui/noveltree.py
index ac98cd83..ad071e3e 100644
--- a/novelwriter/gui/noveltree.py
+++ b/novelwriter/gui/noveltree.py
@@ -298,6 +298,7 @@ class GuiNovelToolBar(QWidget):
self.novelValue.setHandle(rootHandle)
SHARED.project.data.setLastHandle(rootHandle, "novel")
self.novelView.setCurrentNovel(rootHandle)
+ self.novelView.novelTree.setAccessibleName(self.novelValue.currentText())
return
def setLastColType(self, colType: nwNovelExtra, doRefresh: bool = True) -> None:
diff --git a/novelwriter/gui/projtree.py b/novelwriter/gui/projtree.py
index 11c8b909..4565e315 100644
--- a/novelwriter/gui/projtree.py
+++ b/novelwriter/gui/projtree.py
@@ -254,6 +254,7 @@ class GuiProjectToolBar(QWidget):
self.viewLabel.setFont(SHARED.theme.guiFontB)
self.viewLabel.setContentsMargins(0, 0, 0, 0)
self.viewLabel.setSizePolicy(QtSizeExpanding, QtSizeExpanding)
+ self.projTree.setAccessibleName(self.viewLabel.text())
# Quick Links
self.mQuick = QMenu(self)
diff --git a/novelwriter/gui/search.py b/novelwriter/gui/search.py
index 323b2200..51bf1a15 100644
--- a/novelwriter/gui/search.py
+++ b/novelwriter/gui/search.py
@@ -125,6 +125,7 @@ class GuiProjectSearch(QWidget):
self.searchResult.setAllColumnsShowFocus(True)
self.searchResult.itemDoubleClicked.connect(self._searchResultDoubleClicked)
self.searchResult.itemSelectionChanged.connect(self._searchResultSelected)
+ self.searchResult.setAccessibleName(self.viewLabel.text())
if header := self.searchResult.header():
header.setStretchLastSection(False)
diff --git a/novelwriter/tools/lipsum.py b/novelwriter/tools/lipsum.py
index b2028dca..4e54d79e 100644
--- a/novelwriter/tools/lipsum.py
+++ b/novelwriter/tools/lipsum.py
@@ -75,8 +75,9 @@ class GuiLipsum(NDialog):
self.paraCount.setMaximum(100)
self.paraCount.setValue(5)
- self.randLabel = QLabel(self.tr("Randomise order"), self)
self.randSwitch = NSwitch(self)
+ self.randLabel = QLabel(self.tr("Randomise order"), self)
+ self.randLabel.setBuddy(self.randSwitch)
self.formBox = QGridLayout()
self.formBox.addWidget(self.headLabel, 0, 0, 1, 2, QtAlignLeft)
diff --git a/novelwriter/tools/manussettings.py b/novelwriter/tools/manussettings.py
index ee802487..855f64ea 100644
--- a/novelwriter/tools/manussettings.py
+++ b/novelwriter/tools/manussettings.py
@@ -104,6 +104,7 @@ class GuiBuildSettings(NToolDialog):
# SideBar
self.sidebar = NPagedSideBar(self)
self.sidebar.setLabelColor(SHARED.theme.helpText)
+ self.sidebar.setAccessibleName(self.titleLabel.text())
self.sidebar.addLabel(self.tr("General"))
self.sidebar.addButton(self.tr("Selection"), self.OPT_FILTERS)
@@ -564,9 +565,10 @@ class _HeadingsTab(NScrollablePage):
self.fmtPart.setReadOnly(True)
self.btnPart = NIconToolButton(self, iSz, "edit", "green")
self.btnPart.clicked.connect(qtLambda(self._editHeading, self.EDIT_TITLE))
+ self.swtPart = NSwitch(self, height=iPx)
self.hdePart = QLabel(trHide, self)
self.hdePart.setIndent(6)
- self.swtPart = NSwitch(self, height=iPx)
+ self.hdePart.setBuddy(self.swtPart)
self.formatBox.addWidget(self.lblPart, 0, 0)
self.formatBox.addWidget(self.fmtPart, 0, 1)
@@ -580,9 +582,10 @@ class _HeadingsTab(NScrollablePage):
self.fmtChapter.setReadOnly(True)
self.btnChapter = NIconToolButton(self, iSz, "edit", "green")
self.btnChapter.clicked.connect(qtLambda(self._editHeading, self.EDIT_CHAPTER))
+ self.swtChapter = NSwitch(self, height=iPx)
self.hdeChapter = QLabel(trHide, self)
self.hdeChapter.setIndent(6)
- self.swtChapter = NSwitch(self, height=iPx)
+ self.hdeChapter.setBuddy(self.swtChapter)
self.formatBox.addWidget(self.lblChapter, 1, 0)
self.formatBox.addWidget(self.fmtChapter, 1, 1)
@@ -596,9 +599,10 @@ class _HeadingsTab(NScrollablePage):
self.fmtUnnumbered.setReadOnly(True)
self.btnUnnumbered = NIconToolButton(self, iSz, "edit", "green")
self.btnUnnumbered.clicked.connect(qtLambda(self._editHeading, self.EDIT_UNNUM))
+ self.swtUnnumbered = NSwitch(self, height=iPx)
self.hdeUnnumbered = QLabel(trHide, self)
self.hdeUnnumbered.setIndent(6)
- self.swtUnnumbered = NSwitch(self, height=iPx)
+ self.hdeUnnumbered.setBuddy(self.swtUnnumbered)
self.formatBox.addWidget(self.lblUnnumbered, 2, 0)
self.formatBox.addWidget(self.fmtUnnumbered, 2, 1)
@@ -612,9 +616,10 @@ class _HeadingsTab(NScrollablePage):
self.fmtScene.setReadOnly(True)
self.btnScene = NIconToolButton(self, iSz, "edit", "green")
self.btnScene.clicked.connect(qtLambda(self._editHeading, self.EDIT_SCENE))
+ self.swtScene = NSwitch(self, height=iPx)
self.hdeScene = QLabel(trHide, self)
self.hdeScene.setIndent(6)
- self.swtScene = NSwitch(self, height=iPx)
+ self.hdeScene.setBuddy(self.swtScene)
self.formatBox.addWidget(self.lblScene, 3, 0)
self.formatBox.addWidget(self.fmtScene, 3, 1)
@@ -628,9 +633,10 @@ class _HeadingsTab(NScrollablePage):
self.fmtAScene.setReadOnly(True)
self.btnAScene = NIconToolButton(self, iSz, "edit", "green")
self.btnAScene.clicked.connect(qtLambda(self._editHeading, self.EDIT_HSCENE))
+ self.swtAScene = NSwitch(self, height=iPx)
self.hdeAScene = QLabel(trHide, self)
self.hdeAScene.setIndent(6)
- self.swtAScene = NSwitch(self, height=iPx)
+ self.hdeAScene.setBuddy(self.swtAScene)
self.formatBox.addWidget(self.lblAScene, 4, 0)
self.formatBox.addWidget(self.fmtAScene, 4, 1)
@@ -644,9 +650,10 @@ class _HeadingsTab(NScrollablePage):
self.fmtSection.setReadOnly(True)
self.btnSection = NIconToolButton(self, iSz, "edit", "green")
self.btnSection.clicked.connect(qtLambda(self._editHeading, self.EDIT_SECTION))
+ self.swtSection = NSwitch(self, height=iPx)
self.hdeSection = QLabel(trHide, self)
self.hdeSection.setIndent(6)
- self.swtSection = NSwitch(self, height=iPx)
+ self.hdeSection.setBuddy(self.swtSection)
self.formatBox.addWidget(self.lblSection, 5, 0)
self.formatBox.addWidget(self.fmtSection, 5, 1)
@@ -704,44 +711,59 @@ class _HeadingsTab(NScrollablePage):
# Layout Matrix
# =============
+ trCentre = self.tr("Centre")
+ trBreak = self.tr("Page Break")
+
self.layoutMatrix = QGridLayout()
self.layoutMatrix.setVerticalSpacing(12)
self.layoutMatrix.setHorizontalSpacing(12)
- self.layoutMatrix.addWidget(QLabel(self.tr("Centre"), self), 0, 1)
- self.layoutMatrix.addWidget(QLabel(self.tr("Page Break"), self), 0, 2)
+ self.layoutMatrix.addWidget(QLabel(trCentre, self), 0, 1)
+ self.layoutMatrix.addWidget(QLabel(trBreak, self), 0, 2)
# Title Layout
- self.lblTitle = QLabel(self._build.getLabel("headings.styleTitle"), self)
+ trLabel = self._build.getLabel("headings.styleTitle")
+ self.lblTitle = QLabel(trLabel, self)
self.centerTitle = NSwitch(self, height=iPx)
+ self.centerTitle.setAccessibleName(f"{trLabel}: {trCentre}")
self.breakTitle = NSwitch(self, height=iPx)
+ self.breakTitle.setAccessibleName(f"{trLabel}: {trBreak}")
self.layoutMatrix.addWidget(self.lblTitle, 1, 0)
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)
+ trLabel = self._build.getLabel("headings.stylePart")
+ self.lblPart = QLabel(trLabel, self)
self.centerPart = NSwitch(self, height=iPx)
+ self.centerPart.setAccessibleName(f"{trLabel}: {trCentre}")
self.breakPart = NSwitch(self, height=iPx)
+ self.breakPart.setAccessibleName(f"{trLabel}: {trBreak}")
self.layoutMatrix.addWidget(self.lblPart, 2, 0)
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)
+ trLabel = self._build.getLabel("headings.styleChapter")
+ self.lblChapter = QLabel(trLabel, self)
self.centerChapter = NSwitch(self, height=iPx)
+ self.centerChapter.setAccessibleName(f"{trLabel}: {trCentre}")
self.breakChapter = NSwitch(self, height=iPx)
+ self.breakChapter.setAccessibleName(f"{trLabel}: {trBreak}")
self.layoutMatrix.addWidget(self.lblChapter, 3, 0)
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)
+ trLabel = self._build.getLabel("headings.styleScene")
+ self.lblScene = QLabel(trLabel, self)
self.centerScene = NSwitch(self, height=iPx)
+ self.centerScene.setAccessibleName(f"{trLabel}: {trCentre}")
self.breakScene = NSwitch(self, height=iPx)
+ self.breakScene.setAccessibleName(f"{trLabel}: {trBreak}")
self.layoutMatrix.addWidget(self.lblScene, 4, 0)
self.layoutMatrix.addWidget(self.centerScene, 4, 1, QtAlignCenter)
@@ -979,7 +1001,6 @@ class _FormattingTab(NScrollableForm):
# Note Headings
self.addNoteHead = NSwitch(self, height=iPx)
-
self.addRow(self._build.getLabel("text.addNoteHeadings"), self.addNoteHead)
# Text Format
diff --git a/novelwriter/tools/noveldetails.py b/novelwriter/tools/noveldetails.py
index ec42ccf1..75580233 100644
--- a/novelwriter/tools/noveldetails.py
+++ b/novelwriter/tools/noveldetails.py
@@ -86,6 +86,7 @@ class GuiNovelDetails(NNonBlockingDialog):
# SideBar
self.sidebar = NPagedSideBar(self)
self.sidebar.setLabelColor(SHARED.theme.helpText)
+ self.sidebar.setAccessibleName(self.titleLabel.text())
self.sidebar.addButton(self.tr("Overview"), self.PAGE_OVERVIEW)
self.sidebar.addButton(self.tr("Contents"), self.PAGE_CONTENTS)
self.sidebar.setSelected(self.PAGE_OVERVIEW)
@@ -356,16 +357,14 @@ class _ContentsPage(NFixedPage):
countFrom = options.getInt("GuiNovelDetails", "countFrom", 1)
clearDouble = options.getBool("GuiNovelDetails", "clearDouble", True)
- self.wpLabel = QLabel(self.tr("Words per page"), self)
-
self.wpValue = QSpinBox(self)
self.wpValue.setMinimum(10)
self.wpValue.setMaximum(1000)
self.wpValue.setSingleStep(10)
self.wpValue.setValue(wordsPerPage)
self.wpValue.valueChanged.connect(self._populateTree)
-
- self.poLabel = QLabel(self.tr("First page offset"), self)
+ self.wpLabel = QLabel(self.tr("Words per page"), self)
+ self.wpLabel.setBuddy(self.wpValue)
self.poValue = QSpinBox(self)
self.poValue.setMinimum(1)
@@ -373,12 +372,14 @@ class _ContentsPage(NFixedPage):
self.poValue.setSingleStep(1)
self.poValue.setValue(countFrom)
self.poValue.valueChanged.connect(self._populateTree)
-
- self.dblLabel = QLabel(self.tr("Chapters on odd pages"), self)
+ self.poLabel = QLabel(self.tr("First page offset"), self)
+ self.poLabel.setBuddy(self.poValue)
self.dblValue = NSwitch(self, height=iPx)
self.dblValue.setChecked(clearDouble)
self.dblValue.clicked.connect(self._populateTree)
+ self.dblLabel = QLabel(self.tr("Chapters on odd pages"), self)
+ self.dblLabel.setBuddy(self.dblValue)
self.optionsBox = QGridLayout()
self.optionsBox.addWidget(self.wpLabel, 0, 0)
diff --git a/novelwriter/tools/writingstats.py b/novelwriter/tools/writingstats.py
index f2c14be2..0cbb9124 100644
--- a/novelwriter/tools/writingstats.py
+++ b/novelwriter/tools/writingstats.py
@@ -183,59 +183,82 @@ class GuiWritingStats(NToolDialog):
# Filter Options
iPx = SHARED.theme.baseIconHeight
- self.filterBox = QGroupBox(self.tr("Filters"), self)
self.filterForm = QGridLayout(self)
+ self.filterForm.setRowStretch(6, 1)
+ self.filterBox = QGroupBox(self.tr("Filters"), self)
self.filterBox.setLayout(self.filterForm)
- self.incNovel = NSwitch(self, height=iPx)
- self.incNovel.setChecked(
+ # Include Novel Files
+ self.swtIncNovel = NSwitch(self, height=iPx)
+ self.swtIncNovel.setChecked(
pOptions.getBool("GuiWritingStats", "incNovel", True)
)
- self.incNovel.clicked.connect(self._updateListBox)
+ self.swtIncNovel.clicked.connect(self._updateListBox)
+ self.lblIncNovel = QLabel(self.tr("Count novel files"), self)
+ self.lblIncNovel.setBuddy(self.swtIncNovel)
- self.incNotes = NSwitch(self, height=iPx)
- self.incNotes.setChecked(
+ self.filterForm.addWidget(self.lblIncNovel, 0, 0)
+ self.filterForm.addWidget(self.swtIncNovel, 0, 1)
+
+ # Include Note Files
+ self.swtIncNotes = NSwitch(self, height=iPx)
+ self.swtIncNotes.setChecked(
pOptions.getBool("GuiWritingStats", "incNotes", True)
)
- self.incNotes.clicked.connect(self._updateListBox)
+ self.swtIncNotes.clicked.connect(self._updateListBox)
+ self.lblIncNotes = QLabel(self.tr("Count note files"), self)
+ self.lblIncNotes.setBuddy(self.swtIncNotes)
- self.hideZeros = NSwitch(self, height=iPx)
- self.hideZeros.setChecked(
+ self.filterForm.addWidget(self.lblIncNotes, 1, 0)
+ self.filterForm.addWidget(self.swtIncNotes, 1, 1)
+
+ # Hide Zero Counts
+ self.swtHideZeros = NSwitch(self, height=iPx)
+ self.swtHideZeros.setChecked(
pOptions.getBool("GuiWritingStats", "hideZeros", True)
)
- self.hideZeros.clicked.connect(self._updateListBox)
+ self.swtHideZeros.clicked.connect(self._updateListBox)
+ self.lblHideZeros = QLabel(self.tr("Hide zero word count"), self)
+ self.lblHideZeros.setBuddy(self.swtHideZeros)
- self.hideNegative = NSwitch(self, height=iPx)
- self.hideNegative.setChecked(
+ self.filterForm.addWidget(self.lblHideZeros, 2, 0)
+ self.filterForm.addWidget(self.swtHideZeros, 2, 1)
+
+ # Hide Negative Counts
+ self.swtHideNegative = NSwitch(self, height=iPx)
+ self.swtHideNegative.setChecked(
pOptions.getBool("GuiWritingStats", "hideNegative", False)
)
- self.hideNegative.clicked.connect(self._updateListBox)
+ self.swtHideNegative.clicked.connect(self._updateListBox)
+ self.lblHideNegative = QLabel(self.tr("Hide negative word count"), self)
+ self.lblHideNegative.setBuddy(self.swtHideNegative)
- self.groupByDay = NSwitch(self, height=iPx)
- self.groupByDay.setChecked(
+ self.filterForm.addWidget(self.lblHideNegative, 3, 0)
+ self.filterForm.addWidget(self.swtHideNegative, 3, 1)
+
+ # Group Entries
+ self.swtGroupByDay = NSwitch(self, height=iPx)
+ self.swtGroupByDay.setChecked(
pOptions.getBool("GuiWritingStats", "groupByDay", False)
)
- self.groupByDay.clicked.connect(self._updateListBox)
+ self.swtGroupByDay.clicked.connect(self._updateListBox)
+ self.lblGroupByDay = QLabel(self.tr("Group entries by day"), self)
+ self.lblGroupByDay.setBuddy(self.swtGroupByDay)
- self.showIdleTime = NSwitch(self, height=iPx)
- self.showIdleTime.setChecked(
+ self.filterForm.addWidget(self.lblGroupByDay, 4, 0)
+ self.filterForm.addWidget(self.swtGroupByDay, 4, 1)
+
+ # Show Idle
+ self.swtShowIdleTime = NSwitch(self, height=iPx)
+ self.swtShowIdleTime.setChecked(
pOptions.getBool("GuiWritingStats", "showIdleTime", False)
)
- self.showIdleTime.clicked.connect(self._updateListBox)
+ self.swtShowIdleTime.clicked.connect(self._updateListBox)
+ self.lblShowIdleTime = QLabel(self.tr("Show idle time"), self)
+ self.lblShowIdleTime.setBuddy(self.swtShowIdleTime)
- self.filterForm.addWidget(QLabel(self.tr("Count novel files"), self), 0, 0)
- self.filterForm.addWidget(QLabel(self.tr("Count note files"), self), 1, 0)
- self.filterForm.addWidget(QLabel(self.tr("Hide zero word count"), self), 2, 0)
- self.filterForm.addWidget(QLabel(self.tr("Hide negative word count"), self), 3, 0)
- self.filterForm.addWidget(QLabel(self.tr("Group entries by day"), self), 4, 0)
- self.filterForm.addWidget(QLabel(self.tr("Show idle time"), self), 5, 0)
- self.filterForm.addWidget(self.incNovel, 0, 1)
- self.filterForm.addWidget(self.incNotes, 1, 1)
- self.filterForm.addWidget(self.hideZeros, 2, 1)
- self.filterForm.addWidget(self.hideNegative, 3, 1)
- self.filterForm.addWidget(self.groupByDay, 4, 1)
- self.filterForm.addWidget(self.showIdleTime, 5, 1)
- self.filterForm.setRowStretch(6, 1)
+ self.filterForm.addWidget(self.lblShowIdleTime, 5, 0)
+ self.filterForm.addWidget(self.swtShowIdleTime, 5, 1)
# Settings
self.histMax = QSpinBox(self)
@@ -325,12 +348,12 @@ class GuiWritingStats(NToolDialog):
sortCol = self.listBox.sortColumn()
sortOrder = header.sortIndicatorOrder() if header else 0
- incNovel = self.incNovel.isChecked()
- incNotes = self.incNotes.isChecked()
- hideZeros = self.hideZeros.isChecked()
- hideNegative = self.hideNegative.isChecked()
- groupByDay = self.groupByDay.isChecked()
- showIdleTime = self.showIdleTime.isChecked()
+ incNovel = self.swtIncNovel.isChecked()
+ incNotes = self.swtIncNotes.isChecked()
+ hideZeros = self.swtHideZeros.isChecked()
+ hideNegative = self.swtHideNegative.isChecked()
+ groupByDay = self.swtGroupByDay.isChecked()
+ showIdleTime = self.swtShowIdleTime.isChecked()
histMax = self.histMax.value()
logger.debug("Saving State: GuiWritingStats")
@@ -487,11 +510,11 @@ class GuiWritingStats(NToolDialog):
self.listBox.clear()
self.timeFilter = 0.0
- incNovel = self.incNovel.isChecked()
- incNotes = self.incNotes.isChecked()
- hideZeros = self.hideZeros.isChecked()
- hideNegative = self.hideNegative.isChecked()
- groupByDay = self.groupByDay.isChecked()
+ incNovel = self.swtIncNovel.isChecked()
+ incNotes = self.swtIncNotes.isChecked()
+ hideZeros = self.swtHideZeros.isChecked()
+ hideNegative = self.swtHideNegative.isChecked()
+ groupByDay = self.swtGroupByDay.isChecked()
histMax = self.histMax.value()
# Group the data
@@ -563,7 +586,7 @@ class GuiWritingStats(NToolDialog):
# Populate the list
mTrans = Qt.TransformationMode.FastTransformation
mAspect = Qt.AspectRatioMode.IgnoreAspectRatio
- showIdleTime = self.showIdleTime.isChecked()
+ showIdleTime = self.swtShowIdleTime.isChecked()
for _, sStart, sDiff, nWords, _, _, sIdle in self.filterData:
if showIdleTime:
diff --git a/tests/test_tools/test_tools_writingstats.py b/tests/test_tools/test_tools_writingstats.py
index 298b8540..0e2bc4ee 100644
--- a/tests/test_tools/test_tools_writingstats.py
+++ b/tests/test_tools/test_tools_writingstats.py
@@ -261,7 +261,7 @@ def testToolWritingStats_Filters(qtbot, monkeypatch, nwGUI, projPath, tstPaths):
assert item.text(sessLog.C_COUNT) == f"{200:n}"
# No Novel Files
- qtbot.mouseClick(sessLog.incNovel, QtMouseLeft)
+ qtbot.mouseClick(sessLog.swtIncNovel, QtMouseLeft)
assert sessLog._saveData(sessLog.FMT_JSON)
jsonStats = tstPaths.tmpDir / "sessionStats.json"
@@ -329,8 +329,8 @@ def testToolWritingStats_Filters(qtbot, monkeypatch, nwGUI, projPath, tstPaths):
]
# No Note Files
- qtbot.mouseClick(sessLog.incNovel, QtMouseLeft)
- qtbot.mouseClick(sessLog.incNotes, QtMouseLeft)
+ qtbot.mouseClick(sessLog.swtIncNovel, QtMouseLeft)
+ qtbot.mouseClick(sessLog.swtIncNotes, QtMouseLeft)
assert sessLog._saveData(sessLog.FMT_JSON)
jsonStats = tstPaths.tmpDir / "sessionStats.json"
@@ -398,8 +398,8 @@ def testToolWritingStats_Filters(qtbot, monkeypatch, nwGUI, projPath, tstPaths):
]
# No Negative Entries
- qtbot.mouseClick(sessLog.incNotes, QtMouseLeft)
- qtbot.mouseClick(sessLog.hideNegative, QtMouseLeft)
+ qtbot.mouseClick(sessLog.swtIncNotes, QtMouseLeft)
+ qtbot.mouseClick(sessLog.swtHideNegative, QtMouseLeft)
assert sessLog._saveData(sessLog.FMT_JSON)
jsonStats = tstPaths.tmpDir / "sessionStats.json"
@@ -439,8 +439,8 @@ def testToolWritingStats_Filters(qtbot, monkeypatch, nwGUI, projPath, tstPaths):
]
# Un-hide Zero Entries
- qtbot.mouseClick(sessLog.hideNegative, QtMouseLeft)
- qtbot.mouseClick(sessLog.hideZeros, QtMouseLeft)
+ qtbot.mouseClick(sessLog.swtHideNegative, QtMouseLeft)
+ qtbot.mouseClick(sessLog.swtHideZeros, QtMouseLeft)
assert sessLog._saveData(sessLog.FMT_JSON)
jsonStats = tstPaths.tmpDir / "sessionStats.json"
@@ -526,14 +526,14 @@ def testToolWritingStats_Filters(qtbot, monkeypatch, nwGUI, projPath, tstPaths):
assert item is not None
assert item.text(sessLog.C_IDLE) == "4 %"
- qtbot.mouseClick(sessLog.showIdleTime, QtMouseLeft)
+ qtbot.mouseClick(sessLog.swtShowIdleTime, QtMouseLeft)
item = sessLog.listBox.topLevelItem(7)
assert item is not None
assert item.text(sessLog.C_IDLE) == "00:01:10"
# Group by Day
- qtbot.mouseClick(sessLog.groupByDay, QtMouseLeft)
+ qtbot.mouseClick(sessLog.swtGroupByDay, QtMouseLeft)
assert sessLog._saveData(sessLog.FMT_JSON)
jsonStats = tstPaths.tmpDir / "sessionStats.json"