Add a little style.

--HG--
branch : dfighter-tools
This commit is contained in:
dfighter1985 2014-09-13 18:03:02 +02:00
parent af550acd62
commit aef69eef64
2 changed files with 31 additions and 6 deletions

View file

@ -58,7 +58,7 @@ void ExpressionLink::nodeMoved()
void ExpressionLink::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget ) void ExpressionLink::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget )
{ {
setPen( QPen( Qt::darkRed ) ); setPen( QPen( Qt::black ) );
QGraphicsLineItem::paint( painter, option, widget ); QGraphicsLineItem::paint( painter, option, widget );
} }

View file

@ -39,15 +39,40 @@ QRectF ExpressionNode::boundingRect() const
void ExpressionNode::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget ) void ExpressionNode::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget )
{ {
QBrush br;
QPen p;
QColor c;
QRectF rect = boundingRect();
QRectF header = rect;
header.setHeight( header.height() * 0.2 );
// Draw filled rectangle, header
c.setRed( 44 );
c.setGreen( 169 );
c.setBlue( 232 );
br.setColor( c );
br.setStyle( Qt::SolidPattern );
p.setColor( c );
painter->setPen( p );
painter->fillRect( header, br );
// Draw header text
p.setColor( Qt::black );
painter->setPen( p );
painter->drawText( header, Qt::AlignCenter, "Something" );
if( option->state & QStyle::State_Selected ) if( option->state & QStyle::State_Selected )
{ {
QPen outline; p.setStyle( Qt::DotLine );
outline.setStyle( Qt::DotLine ); p.setColor( Qt::red );
painter->setPen( outline );
} }
painter->drawRect( boundingRect() ); // Draw outline of the entire thing + header
painter->setPen( p );
painter->drawRect( rect );
painter->drawRect( header );
} }