Fix colour reset bug for status labels (#2461)
This commit is contained in:
@@ -441,9 +441,9 @@ class ProjectXMLReader:
|
|||||||
for xEntry in xItem:
|
for xEntry in xItem:
|
||||||
if xEntry.tag == "entry":
|
if xEntry.tag == "entry":
|
||||||
key = xEntry.attrib.get("key", None)
|
key = xEntry.attrib.get("key", None)
|
||||||
red = checkInt(xEntry.attrib.get("red", 0), 0) # Deprecated in 1.5 R6
|
red = checkInt(xEntry.attrib.get("red", 0), 0) # Removed in 1.5 R6
|
||||||
green = checkInt(xEntry.attrib.get("green", 0), 0) # Deprecated in 1.5 R6
|
green = checkInt(xEntry.attrib.get("green", 0), 0) # Removed in 1.5 R6
|
||||||
blue = checkInt(xEntry.attrib.get("blue", 0), 0) # Deprecated in 1.5 R6
|
blue = checkInt(xEntry.attrib.get("blue", 0), 0) # Removed in 1.5 R6
|
||||||
color = xEntry.attrib.get("color") # Added in 1.5 R6
|
color = xEntry.attrib.get("color") # Added in 1.5 R6
|
||||||
count = checkInt(xEntry.attrib.get("count", 0), 0)
|
count = checkInt(xEntry.attrib.get("count", 0), 0)
|
||||||
shape = xEntry.attrib.get("shape", "")
|
shape = xEntry.attrib.get("shape", "")
|
||||||
|
|||||||
@@ -192,7 +192,8 @@ class NWStatus:
|
|||||||
def refreshIcons(self) -> None:
|
def refreshIcons(self) -> None:
|
||||||
"""Refresh all icons."""
|
"""Refresh all icons."""
|
||||||
for entry in self._store.values():
|
for entry in self._store.values():
|
||||||
entry.color = SHARED.theme.parseColor(entry.theme)
|
if entry.theme != CUSTOM_COL:
|
||||||
|
entry.color = SHARED.theme.parseColor(entry.theme)
|
||||||
entry.icon = NWStatus.createIcon(self._height, entry.color, entry.shape)
|
entry.icon = NWStatus.createIcon(self._height, entry.color, entry.shape)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@@ -324,23 +324,55 @@ def testCoreStatus_Entries(mockGUI, mockRnd):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.core
|
@pytest.mark.core
|
||||||
def testCoreStatus_RefreshIcons(mockGUIwithTheme, mockRnd):
|
def testCoreStatus_RefreshIcons_Theme(mockGUIwithTheme, mockRnd):
|
||||||
"""Test refreshing the icons of the NWStatus class."""
|
"""Test refreshing the icons with theme colours."""
|
||||||
nStatus = NWStatus(NWStatus.STATUS)
|
nStatus = NWStatus(NWStatus.STATUS)
|
||||||
nStatus.add(None, "New", "default", "SQUARE", 0)
|
nStatus.add(None, "New", "default", "SQUARE", 0)
|
||||||
nStatus.add(None, "Note", "red", "CIRCLE", 0)
|
nStatus.add(None, "Note", "red", "CIRCLE", 0)
|
||||||
nStatus.add(None, "Draft", "yellow", "SQUARE", 0)
|
nStatus.add(None, "Draft", "yellow", "SQUARE", 0)
|
||||||
nStatus.add(None, "Finished", "green", "SQUARE", 0)
|
nStatus.add(None, "Finished", "green", "SQUARE", 0)
|
||||||
|
|
||||||
beforeIcons = [nStatus[statusKeys[i]].icon for i in range(4)]
|
iconsA = [nStatus[statusKeys[i]].icon for i in range(4)]
|
||||||
|
themeA = [nStatus[statusKeys[i]].theme for i in range(4)]
|
||||||
|
|
||||||
# Refreshing the icons should generate new ones
|
# Refreshing the icons should generate new ones
|
||||||
nStatus.refreshIcons()
|
nStatus.refreshIcons()
|
||||||
afterIcons = [nStatus[statusKeys[i]].icon for i in range(4)]
|
iconsB = [nStatus[statusKeys[i]].icon for i in range(4)]
|
||||||
|
themeB = [nStatus[statusKeys[i]].theme for i in range(4)]
|
||||||
|
|
||||||
for before, after in zip(beforeIcons, afterIcons, strict=False):
|
for before, after in zip(iconsA, iconsB, strict=False):
|
||||||
assert before is not after
|
assert before is not after
|
||||||
|
|
||||||
|
assert themeA == themeB
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.core
|
||||||
|
def testCoreStatus_RefreshIcons_Custom(mockGUIwithTheme, mockRnd):
|
||||||
|
"""Test refreshing the icons with custom colours."""
|
||||||
|
nStatus = NWStatus(NWStatus.STATUS)
|
||||||
|
nStatus.add(None, "New", "#707070", "SQUARE", 0)
|
||||||
|
nStatus.add(None, "Note", "#ff0000", "CIRCLE", 0)
|
||||||
|
nStatus.add(None, "Draft", "#ffff00", "SQUARE", 0)
|
||||||
|
nStatus.add(None, "Finished", "#00ff00", "SQUARE", 0)
|
||||||
|
|
||||||
|
iconsA = [nStatus[statusKeys[i]].icon for i in range(4)]
|
||||||
|
themeA = [nStatus[statusKeys[i]].theme for i in range(4)]
|
||||||
|
colorA = [nStatus[statusKeys[i]].color.getRgb() for i in range(4)]
|
||||||
|
|
||||||
|
# Refreshing the icons should generate new ones
|
||||||
|
nStatus.refreshIcons()
|
||||||
|
iconsB = [nStatus[statusKeys[i]].icon for i in range(4)]
|
||||||
|
themeB = [nStatus[statusKeys[i]].theme for i in range(4)]
|
||||||
|
colorB = [nStatus[statusKeys[i]].color.getRgb() for i in range(4)]
|
||||||
|
|
||||||
|
for before, after in zip(iconsA, iconsB, strict=False):
|
||||||
|
assert before is not after
|
||||||
|
|
||||||
|
# But they should have the same colour value (#2452)
|
||||||
|
assert themeA == [CUSTOM_COL, CUSTOM_COL, CUSTOM_COL, CUSTOM_COL]
|
||||||
|
assert themeB == [CUSTOM_COL, CUSTOM_COL, CUSTOM_COL, CUSTOM_COL]
|
||||||
|
assert colorA == colorB
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.core
|
@pytest.mark.core
|
||||||
def testCoreStatus_Pack(mockGUIwithTheme, mockRnd):
|
def testCoreStatus_Pack(mockGUIwithTheme, mockRnd):
|
||||||
|
|||||||
Reference in New Issue
Block a user