Skip to content

Commit

Permalink
recolor socket on hover
Browse files Browse the repository at this point in the history
  • Loading branch information
zkovari committed Aug 31, 2023
1 parent 9ce796e commit de6de37
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/main/python/plotlyst/view/characters_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def __init__(self, novel: Novel):
(self.ui.btnRelationsView, self.ui.pageRelationsView),
(self.ui.btnComparison, self.ui.pageComparison),
(self.ui.btnProgressView, self.ui.pageProgressView)])
self.ui.btnCardsView.setChecked(True)
self.ui.btnRelationsView.setChecked(True)

self.ui.cards.orderChanged.connect(self._characters_swapped)
self.ui.stackedWidget.setCurrentWidget(self.ui.pageView)
Expand Down
22 changes: 17 additions & 5 deletions src/main/python/plotlyst/view/widget/character/network/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
QGraphicsSceneMouseEvent
from overrides import overrides

from src.main.python.plotlyst.common import PLOTLYST_SECONDARY_COLOR, PLOTLYST_TERTIARY_COLOR
from src.main.python.plotlyst.common import PLOTLYST_SECONDARY_COLOR, PLOTLYST_TERTIARY_COLOR, PLOTLYST_MAIN_COLOR
from src.main.python.plotlyst.core.domain import Character, Novel, RelationsNetwork, CharacterNode
from src.main.python.plotlyst.view.common import pointy
from src.main.python.plotlyst.view.icons import avatars
from src.main.python.plotlyst.view.widget.graphics import NodeItem, draw_helpers, AbstractSocketItem, NetworkItemType, \
from src.main.python.plotlyst.view.widget.graphics import NodeItem, AbstractSocketItem, NetworkItemType, \
NetworkScene


Expand All @@ -44,17 +44,29 @@ class PlaceholderCharacter(Character):


class SocketItem(AbstractSocketItem):
Size: int = 14
Size: int = 20

def __init__(self, parent=None):
self._size = self.Size
super().__init__(Qt.Edge.TopEdge, parent)
pointy(self)
self._hovered: bool = False

@overrides
def hoverEnterEvent(self, event: QGraphicsSceneHoverEvent) -> None:
self._hovered = True
self.update()

@overrides
def hoverLeaveEvent(self, event: 'QGraphicsSceneHoverEvent') -> None:
self._hovered = False
self.update()

@overrides
def paint(self, painter: QPainter, option: QStyleOptionGraphicsItem, widget: Optional[QWidget] = ...) -> None:
painter.setPen(QPen(QColor(PLOTLYST_SECONDARY_COLOR), 1))
painter.setBrush(QColor(PLOTLYST_SECONDARY_COLOR))
color = PLOTLYST_SECONDARY_COLOR if self._hovered else PLOTLYST_TERTIARY_COLOR
painter.setPen(QPen(QColor(color), 1))
painter.setBrush(QColor(color))

radius = self.Size // 2
painter.drawEllipse(QPointF(self.Size / 2, self.Size // 2), radius, radius)
Expand Down

0 comments on commit de6de37

Please sign in to comment.