From 6b920bdcdf0ed72bde7e64f1592fef065c37c8f4 Mon Sep 17 00:00:00 2001 From: Zsolt Kovari Date: Mon, 7 Oct 2024 13:59:47 +0200 Subject: [PATCH] set color --- .../python/plotlyst/view/widget/world/map.py | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/main/python/plotlyst/view/widget/world/map.py b/src/main/python/plotlyst/view/widget/world/map.py index cf5455eea..eee21f1af 100644 --- a/src/main/python/plotlyst/view/widget/world/map.py +++ b/src/main/python/plotlyst/view/widget/world/map.py @@ -268,6 +268,15 @@ def activate(self): def highlight(self): self.mapScene().highlightItem(self) + def setColor(self, color: str): + self._marker.color = color + self._marker.color_selected = marker_selected_colors[color] + self.refresh() + + def refresh(self): + self.update() + self.mapScene().markerChangedEvent(self) + def _hoverEnter(self, event: 'QGraphicsSceneHoverEvent') -> None: if not self.isSelected(): effect = QGraphicsOpacityEffect() @@ -353,11 +362,6 @@ def setLocation(self, location: Location): self._marker.ref = location.id self.mapScene().markerChangedEvent(self) - def setColor(self, color: str): - self._marker.color = color - self._marker.color_selected = marker_selected_colors[color] - self.refresh() - def setIcon(self, icon: str): self._marker.icon = icon self.refresh() @@ -380,8 +384,7 @@ def refresh(self): if self._marker.icon: self._iconType = IconRegistry.from_name(self._marker.icon, RELAXED_WHITE_COLOR) - self.update() - self.mapScene().markerChangedEvent(self) + super().refresh() @overrides def boundingRect(self) -> QRectF: @@ -430,6 +433,13 @@ def setMarker(self, marker: WorldBuildingMarker): color.setAlpha(125) self.setBrush(color) + @overrides + def refresh(self): + color = QColor(self._marker.color) + color.setAlpha(125) + self.setBrush(color) + super().refresh() + class AreaSquareItem(QGraphicsRectItem, BaseMapAreaItem): def __init__(self, marker: WorldBuildingMarker, rect: QRectF, parent=None): @@ -678,6 +688,7 @@ def loadMap(self, map: WorldBuildingMap) -> Optional[QGraphicsPixmapItem]: else: continue self.addItem(markerItem) + markerItem.activate() return item else: