diff --git a/novelwriter/core/item.py b/novelwriter/core/item.py index 2448e314..dc008650 100644 --- a/novelwriter/core/item.py +++ b/novelwriter/core/item.py @@ -27,9 +27,9 @@ import logging from typing import TYPE_CHECKING, Any -from PyQt5.QtGui import QIcon +from PyQt5.QtGui import QFont, QIcon -from novelwriter import SHARED +from novelwriter import CONFIG, SHARED from novelwriter.common import ( checkInt, isHandle, isItemClass, isItemLayout, isItemType, simplified, yesNo @@ -325,6 +325,15 @@ class NWItem: """Get the main item icon.""" return SHARED.theme.getItemIcon(self._type, self._class, self._layout, self._heading) + def getMainFont(self) -> QFont: + """Get the main item icon.""" + if CONFIG.emphLabels and self._layout == nwItemLayout.DOCUMENT: + if self._heading == "H1": + return SHARED.theme.guiFontBU + elif self._heading == "H2": + return SHARED.theme.guiFontB + return SHARED.theme.guiFont + def getImportStatus(self) -> tuple[str, QIcon]: """Return the relevant importance or status label and icon for the current item based on its class. diff --git a/novelwriter/core/itemmodel.py b/novelwriter/core/itemmodel.py index 4f9828c0..0766c905 100644 --- a/novelwriter/core/itemmodel.py +++ b/novelwriter/core/itemmodel.py @@ -29,7 +29,7 @@ import logging from typing import TYPE_CHECKING from PyQt5.QtCore import QAbstractItemModel, QMimeData, QModelIndex, Qt -from PyQt5.QtGui import QIcon +from PyQt5.QtGui import QFont, QIcon from novelwriter.common import decodeMimeHandles, minmax from novelwriter.constants import nwConst @@ -46,6 +46,7 @@ COL_MASK = 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 @@ -58,7 +59,7 @@ NODE_FLAGS = Qt.ItemFlag.ItemIsEnabled NODE_FLAGS |= Qt.ItemFlag.ItemIsSelectable NODE_FLAGS |= Qt.ItemFlag.ItemIsDropEnabled -T_NodeData = str | QIcon | Qt.AlignmentFlag | None +T_NodeData = str | QIcon | QFont | Qt.AlignmentFlag | None class ProjectNode: @@ -75,7 +76,7 @@ class ProjectNode: self._children: list[ProjectNode] = [] self._parent: ProjectNode | None = None self._row = 0 - self._cache: dict[int, str | QIcon | Qt.AlignmentFlag] = {} + self._cache: dict[int, T_NodeData] = {} self._flags = NODE_FLAGS self.refresh() self.updateCount() @@ -117,6 +118,7 @@ class ProjectNode: # Label self._cache[C_LABEL_ICON] = self._item.getMainIcon() self._cache[C_LABEL_TEXT] = self._item.itemName + self._cache[C_LABEL_FONT] = self._item.getMainFont() # Count self._cache[C_COUNT_ALIGN] = QtAlignRight diff --git a/novelwriter/gui/theme.py b/novelwriter/gui/theme.py index 40f65531..1ed7e27b 100644 --- a/novelwriter/gui/theme.py +++ b/novelwriter/gui/theme.py @@ -151,6 +151,9 @@ class GuiTheme: self.guiFont = QApplication.font() self.guiFontB = QApplication.font() self.guiFontB.setBold(True) + self.guiFontBU = QApplication.font() + self.guiFontBU.setBold(True) + self.guiFontBU.setUnderline(True) self.guiFontSmall = QApplication.font() self.guiFontSmall.setPointSizeF(0.9*self.guiFont.pointSizeF()) diff --git a/tests/tools.py b/tests/tools.py index 547c83e3..c48e3216 100644 --- a/tests/tools.py +++ b/tests/tools.py @@ -210,7 +210,7 @@ def buildTestProject(obj: object, projPath: Path) -> None: project._valid = True if nwGUI is not None: - nwGUI.projView.populateTree() + nwGUI.projView.openProjectTasks() return