Skip to content

Commit

Permalink
set color
Browse files Browse the repository at this point in the history
  • Loading branch information
zkovari committed Oct 7, 2024
1 parent 19103fb commit 6b920bd
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/main/python/plotlyst/view/widget/world/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand All @@ -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:
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -678,6 +688,7 @@ def loadMap(self, map: WorldBuildingMap) -> Optional[QGraphicsPixmapItem]:
else:
continue
self.addItem(markerItem)
markerItem.activate()

return item
else:
Expand Down

0 comments on commit 6b920bd

Please sign in to comment.