feat: socket hover colors

This commit is contained in:
parker
2025-06-21 02:31:10 +01:00
parent dcc5c25a2d
commit a6a0bec1c0
3 changed files with 21 additions and 4 deletions

View File

@@ -6,7 +6,10 @@
SocketGraphic::SocketGraphic(QGraphicsItem *parent)
: QGraphicsItem(parent)
{
brushActive_ = QBrush("white");
brushInactive_ = QBrush("#9f9f9f");
socketSize_ = 3;
setAcceptHoverEvents(true);
}
QRectF SocketGraphic::boundingRect() const
@@ -18,11 +21,21 @@ QRectF SocketGraphic::boundingRect() const
void SocketGraphic::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
QBrush whiteBrush = QBrush("white");
painter->setPen(Qt::NoPen);
painter->setBrush(whiteBrush);
painter->setBrush(hovered_ ? brushActive_ : brushInactive_);
painter->drawEllipse(QPoint(0,0), socketSize_, socketSize_);
}
void SocketGraphic::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
hovered_ = true;
update();
}
void SocketGraphic::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
hovered_ = false;
update();
}