Restore project item emphasis

This commit is contained in:
Veronica Berglyd Olsen
2024-11-21 01:33:09 +01:00
parent d55f53be0a
commit 7ed619cf2e
4 changed files with 20 additions and 6 deletions
+11 -2
View File
@@ -27,9 +27,9 @@ import logging
from typing import TYPE_CHECKING, Any 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 ( from novelwriter.common import (
checkInt, isHandle, isItemClass, isItemLayout, isItemType, simplified, checkInt, isHandle, isItemClass, isItemLayout, isItemType, simplified,
yesNo yesNo
@@ -325,6 +325,15 @@ class NWItem:
"""Get the main item icon.""" """Get the main item icon."""
return SHARED.theme.getItemIcon(self._type, self._class, self._layout, self._heading) 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]: def getImportStatus(self) -> tuple[str, QIcon]:
"""Return the relevant importance or status label and icon for """Return the relevant importance or status label and icon for
the current item based on its class. the current item based on its class.
+5 -3
View File
@@ -29,7 +29,7 @@ import logging
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from PyQt5.QtCore import QAbstractItemModel, QMimeData, QModelIndex, Qt 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.common import decodeMimeHandles, minmax
from novelwriter.constants import nwConst from novelwriter.constants import nwConst
@@ -46,6 +46,7 @@ COL_MASK = 0x0100
C_LABEL_TEXT = 0x0000 | Qt.ItemDataRole.DisplayRole C_LABEL_TEXT = 0x0000 | Qt.ItemDataRole.DisplayRole
C_LABEL_ICON = 0x0000 | Qt.ItemDataRole.DecorationRole C_LABEL_ICON = 0x0000 | Qt.ItemDataRole.DecorationRole
C_LABEL_FONT = 0x0000 | Qt.ItemDataRole.FontRole
C_COUNT_TEXT = 0x0100 | Qt.ItemDataRole.DisplayRole C_COUNT_TEXT = 0x0100 | Qt.ItemDataRole.DisplayRole
C_COUNT_ICON = 0x0100 | Qt.ItemDataRole.DecorationRole C_COUNT_ICON = 0x0100 | Qt.ItemDataRole.DecorationRole
C_COUNT_ALIGN = 0x0100 | Qt.ItemDataRole.TextAlignmentRole 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.ItemIsSelectable
NODE_FLAGS |= Qt.ItemFlag.ItemIsDropEnabled NODE_FLAGS |= Qt.ItemFlag.ItemIsDropEnabled
T_NodeData = str | QIcon | Qt.AlignmentFlag | None T_NodeData = str | QIcon | QFont | Qt.AlignmentFlag | None
class ProjectNode: class ProjectNode:
@@ -75,7 +76,7 @@ class ProjectNode:
self._children: list[ProjectNode] = [] self._children: list[ProjectNode] = []
self._parent: ProjectNode | None = None self._parent: ProjectNode | None = None
self._row = 0 self._row = 0
self._cache: dict[int, str | QIcon | Qt.AlignmentFlag] = {} self._cache: dict[int, T_NodeData] = {}
self._flags = NODE_FLAGS self._flags = NODE_FLAGS
self.refresh() self.refresh()
self.updateCount() self.updateCount()
@@ -117,6 +118,7 @@ class ProjectNode:
# Label # Label
self._cache[C_LABEL_ICON] = self._item.getMainIcon() self._cache[C_LABEL_ICON] = self._item.getMainIcon()
self._cache[C_LABEL_TEXT] = self._item.itemName self._cache[C_LABEL_TEXT] = self._item.itemName
self._cache[C_LABEL_FONT] = self._item.getMainFont()
# Count # Count
self._cache[C_COUNT_ALIGN] = QtAlignRight self._cache[C_COUNT_ALIGN] = QtAlignRight
+3
View File
@@ -151,6 +151,9 @@ class GuiTheme:
self.guiFont = QApplication.font() self.guiFont = QApplication.font()
self.guiFontB = QApplication.font() self.guiFontB = QApplication.font()
self.guiFontB.setBold(True) self.guiFontB.setBold(True)
self.guiFontBU = QApplication.font()
self.guiFontBU.setBold(True)
self.guiFontBU.setUnderline(True)
self.guiFontSmall = QApplication.font() self.guiFontSmall = QApplication.font()
self.guiFontSmall.setPointSizeF(0.9*self.guiFont.pointSizeF()) self.guiFontSmall.setPointSizeF(0.9*self.guiFont.pointSizeF())
+1 -1
View File
@@ -210,7 +210,7 @@ def buildTestProject(obj: object, projPath: Path) -> None:
project._valid = True project._valid = True
if nwGUI is not None: if nwGUI is not None:
nwGUI.projView.populateTree() nwGUI.projView.openProjectTasks()
return return