Fix active status icon and tooltip
This commit is contained in:
@@ -29,6 +29,7 @@ from typing import TYPE_CHECKING, Any
|
||||
|
||||
from PyQt5.QtGui import QIcon
|
||||
|
||||
from novelwriter import SHARED
|
||||
from novelwriter.common import (
|
||||
checkInt, isHandle, isItemClass, isItemLayout, isItemType, simplified,
|
||||
yesNo
|
||||
@@ -330,6 +331,13 @@ class NWItem:
|
||||
entry = self._project.data.itemImport[self._import]
|
||||
return entry.name, entry.icon
|
||||
|
||||
def getActiveStatus(self) -> tuple[str, QIcon]:
|
||||
"""Return the relevant active status label and icon for
|
||||
the current item based on its type.
|
||||
"""
|
||||
key = ("checked" if self._active else "unchecked") if self.isFileType() else "noncheckable"
|
||||
return trConst(nwLabels.ACTIVE_NAME[key]), SHARED.theme.getIcon(key)
|
||||
|
||||
##
|
||||
# Checker Methods
|
||||
##
|
||||
|
||||
@@ -113,18 +113,14 @@ class ProjectNode:
|
||||
self._cache[C_COUNT_ALIGN] = QtAlignRight
|
||||
|
||||
# Active
|
||||
if self._item.isFileType():
|
||||
if self._item.isActive:
|
||||
self._cache[C_ACTIVE_ICON] = SHARED.theme.getIcon("checked")
|
||||
else:
|
||||
self._cache[C_ACTIVE_ICON] = SHARED.theme.getIcon("unchecked")
|
||||
else:
|
||||
self._cache[C_ACTIVE_ICON] = SHARED.theme.getIcon("noncheckable")
|
||||
aText, aIcon = self._item.getActiveStatus()
|
||||
self._cache[C_ACTIVE_TIP] = aText
|
||||
self._cache[C_ACTIVE_ICON] = aIcon
|
||||
|
||||
# Status
|
||||
sText, sIcon = self._item.getImportStatus()
|
||||
self._cache[C_STATUS_ICON] = sIcon
|
||||
self._cache[C_STATUS_TIP] = sText
|
||||
self._cache[C_STATUS_ICON] = sIcon
|
||||
|
||||
self.updateCount()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user