wiRedPanda
Logic Circuit Simulator
Loading...
Searching...
No Matches
PortHoverLabel Class Reference

A small floating label drawn next to a port while a connected port is hovered. More...

#include <PortHoverLabel.h>

Inheritance diagram for PortHoverLabel:
[legend]

Public Types

enum  { Type = QGraphicsItem::UserType + 4 }
enum class  Side { Left , Right , Top , Bottom }
 Which side of the port the chip is biased towards, away from the element body. More...

Public Member Functions

QRectF boundingRect () const override
void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
 PortHoverLabel (const QString &text, Side side, QGraphicsItem *parent=nullptr)
 Constructs a label chip showing text, anchored at the item's origin (the port).
QPainterPath shape () const override
QString text () const
 Returns the label text (the connected port's name).
int type () const override

Detailed Description

A small floating label drawn next to a port while a connected port is hovered.

When the user hovers a port, ConnectionManager spawns one of these next to every port on the other end of that port's wires, so the labels of all connected endpoints are visible at once (e.g. to check that an IC pin and a 7-segment input carry matching names) without tracing each wire by hand. The chip mirrors the application tooltip styling and is removed when the hover ends.

It derives from QGraphicsObject (rather than QGraphicsItem) so ConnectionManager can track the live instances with QPointer and stay safe if the scene is cleared while a hover is active. The chip is styled to match the native QToolTip and ignores the view transform, so it reads identically to the hovered port's own tooltip at any zoom.

Definition at line 29 of file PortHoverLabel.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
Type 

Definition at line 35 of file PortHoverLabel.h.

◆ Side

enum class PortHoverLabel::Side
strong

Which side of the port the chip is biased towards, away from the element body.

Enumerator
Left 
Right 
Top 
Bottom 

Definition at line 33 of file PortHoverLabel.h.

Constructor & Destructor Documentation

◆ PortHoverLabel()

PortHoverLabel::PortHoverLabel ( const QString & text,
Side side,
QGraphicsItem * parent = nullptr )
explicit

Constructs a label chip showing text, anchored at the item's origin (the port).

Parameters
textThe connected port's label.
sideSide of the origin to draw the chip on, biased away from the element body.
parentOptional parent item.

Definition at line 21 of file PortHoverLabel.cpp.

References Bottom, Left, Right, text(), and Top.

Member Function Documentation

◆ boundingRect()

QRectF PortHoverLabel::boundingRect ( ) const
override
Reimplemented from base class.

Definition at line 56 of file PortHoverLabel.cpp.

◆ paint()

void PortHoverLabel::paint ( QPainter * painter,
const QStyleOptionGraphicsItem * option,
QWidget * widget )
override
Reimplemented from base class.

Definition at line 69 of file PortHoverLabel.cpp.

References ThemeManager::attributes().

◆ shape()

QPainterPath PortHoverLabel::shape ( ) const
override
Reimplemented from base class.

Definition at line 62 of file PortHoverLabel.cpp.

◆ text()

QString PortHoverLabel::text ( ) const
inline

Returns the label text (the connected port's name).

Definition at line 47 of file PortHoverLabel.h.

Referenced by PortHoverLabel().

◆ type()

int PortHoverLabel::type ( ) const
inlineoverride

Definition at line 36 of file PortHoverLabel.h.

References Type.


The documentation for this class was generated from the following files: