28 #include <QApplication>
29 #include <QGraphicsSceneMouseEvent>
30 #include <QPaintEvent>
33 #include "WQtNetworkColors.h"
34 #include "WQtNetworkEditorGlobals.h"
35 #include "WQtNetworkInputPort.h"
36 #include "WQtNetworkItemActivator.h"
37 #include "WQtNetworkOutputPort.h"
40 : m_module( module ), m_activeColor( WQtNetworkColors::ActivatorActive ),
41 m_inactiveColor( WQtNetworkColors::ActivatorInactive )
46 poly << QPointF( dist, dist ) << QPointF( dist + WNETWORKPORT_SIZEX, dist ) << QPointF( dist, dist + WNETWORKPORT_SIZEY );
49 setPen( QPen( Qt::white, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin ) );
50 setAcceptHoverEvents(
true );
58 if(
m_module->getProperties()->getProperty(
"active" )->toPropBool()->get() )
60 setToolTip(
"<b>Active</b><br> Click to deactivate" );
64 setToolTip(
"<b>Not</b> active.<br> Click to activate." );
92 QGraphicsPolygonItem::paint( painter, option, widget );
100 mouseEvent->accept();
105 if( !startItem.isEmpty() )
107 WPropBool active =
m_module->getProperties()->getProperty(
"active" )->toPropBool();
108 active->set( !active->get() );
112 mouseEvent->accept();
116 mouseEvent->ignore();
128 if(
m_module->getProperties()->getProperty(
"active" )->toPropBool()->get() )
131 setToolTip(
"<b>Active</b><br> Click to deactivate." );
136 setToolTip(
"<b>Not</b> active<br> Click to activate." );
void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
Start drawing an arrow temporary.
WQtNetworkItemActivator(std::shared_ptr< WModule > module)
Constructor for indicator showing if module is active.
std::shared_ptr< WModule > m_module
the module
bool m_needStateUpdate
If true, the module state changed.
~WQtNetworkItemActivator()
Destructor.
void activeChangeNotifier()
Callback getting called by the module's active property to know about state changes.
boost::signals2::connection m_notifierConnection
The connection used for notification.
void handleActiveState()
Setups tooltip and brush acccording to state.
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
Actually paints the port.
QColor m_inactiveColor
color used for inactive indicator
virtual int type() const
Reimplementation from QGraphicsItem.
QColor m_activeColor
color used for active indicator