Add methods to refresh status icons on theme change
This commit is contained in:
@@ -483,14 +483,14 @@ class NWProject:
|
|||||||
|
|
||||||
def setDefaultStatusImport(self) -> None:
|
def setDefaultStatusImport(self) -> None:
|
||||||
"""Set the default status and importance values."""
|
"""Set the default status and importance values."""
|
||||||
self._data.itemStatus.add(None, self.tr("New"), (120, 120, 120), "STAR", 0)
|
self._data.itemStatus.add(None, self.tr("New"), "faded", "STAR", 0)
|
||||||
self._data.itemStatus.add(None, self.tr("Note"), (205, 171, 143), "TRIANGLE", 0)
|
self._data.itemStatus.add(None, self.tr("Note"), "red", "TRIANGLE", 0)
|
||||||
self._data.itemStatus.add(None, self.tr("Draft"), (143, 240, 164), "CIRCLE_T", 0)
|
self._data.itemStatus.add(None, self.tr("Draft"), "yellow", "CIRCLE_T", 0)
|
||||||
self._data.itemStatus.add(None, self.tr("Finished"), (249, 240, 107), "STAR", 0)
|
self._data.itemStatus.add(None, self.tr("Finished"), "green", "STAR", 0)
|
||||||
self._data.itemImport.add(None, self.tr("New"), (120, 120, 120), "SQUARE", 0)
|
self._data.itemImport.add(None, self.tr("New"), "purple", "SQUARE", 0)
|
||||||
self._data.itemImport.add(None, self.tr("Minor"), (220, 138, 221), "BLOCK_2", 0)
|
self._data.itemImport.add(None, self.tr("Minor"), "purple", "BLOCK_2", 0)
|
||||||
self._data.itemImport.add(None, self.tr("Major"), (220, 138, 221), "BLOCK_3", 0)
|
self._data.itemImport.add(None, self.tr("Major"), "purple", "BLOCK_3", 0)
|
||||||
self._data.itemImport.add(None, self.tr("Main"), (220, 138, 221), "BLOCK_4", 0)
|
self._data.itemImport.add(None, self.tr("Main"), "purple", "BLOCK_4", 0)
|
||||||
return
|
return
|
||||||
|
|
||||||
def setProjectLang(self, language: str | None) -> None:
|
def setProjectLang(self, language: str | None) -> None:
|
||||||
@@ -547,6 +547,12 @@ class NWProject:
|
|||||||
self._tree.refreshAllItems()
|
self._tree.refreshAllItems()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def updateTheme(self) -> None:
|
||||||
|
"""Update theme elements."""
|
||||||
|
self._data.itemStatus.refreshIcons()
|
||||||
|
self._data.itemImport.refreshIcons()
|
||||||
|
return
|
||||||
|
|
||||||
def localLookup(self, word: str | int) -> str:
|
def localLookup(self, word: str | int) -> str:
|
||||||
"""Look up a word or number in the translation map for the
|
"""Look up a word or number in the translation map for the
|
||||||
project and return it. The variable is cast to a string before
|
project and return it. The variable is cast to a string before
|
||||||
|
|||||||
@@ -189,6 +189,16 @@ class NWStatus:
|
|||||||
logger.error("Could not parse entry %s", str(data))
|
logger.error("Could not parse entry %s", str(data))
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def refreshIcons(self) -> None:
|
||||||
|
"""Refresh all icons."""
|
||||||
|
for entry in self._store.values():
|
||||||
|
if entry.theme != CUSTOM_COL:
|
||||||
|
print("<", entry.color.name(QColor.NameFormat.HexRgb))
|
||||||
|
entry.color = SHARED.theme.parseColor(entry.theme)
|
||||||
|
print(">", entry.color.name(QColor.NameFormat.HexRgb))
|
||||||
|
entry.icon = NWStatus.createIcon(self._height, entry.color, entry.shape)
|
||||||
|
return
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def createIcon(height: int, color: QColor, shape: nwStatusShape) -> QIcon:
|
def createIcon(height: int, color: QColor, shape: nwStatusShape) -> QIcon:
|
||||||
"""Generate an icon for a status label."""
|
"""Generate an icon for a status label."""
|
||||||
|
|||||||
@@ -913,6 +913,7 @@ class GuiMain(QMainWindow):
|
|||||||
def refreshThemeColors(self, syntax: bool = False, force: bool = False) -> None:
|
def refreshThemeColors(self, syntax: bool = False, force: bool = False) -> None:
|
||||||
"""Refresh the GUI theme."""
|
"""Refresh the GUI theme."""
|
||||||
SHARED.theme.loadTheme(force=force)
|
SHARED.theme.loadTheme(force=force)
|
||||||
|
SHARED.project.updateTheme()
|
||||||
self.setPalette(QApplication.palette())
|
self.setPalette(QApplication.palette())
|
||||||
self.docEditor.updateTheme()
|
self.docEditor.updateTheme()
|
||||||
self.docViewer.updateTheme()
|
self.docViewer.updateTheme()
|
||||||
|
|||||||
Reference in New Issue
Block a user