53 #include <QGraphicsItem>
54 #include <QFontMetrics>
57 #include <QGraphicsSceneMouseEvent>
78 setAcceptHoverEvents (
true);
85 Text (_text, _parent),
89 setAcceptHoverEvents (
true);
102 void Button::hoverEnterEvent (QGraphicsSceneHoverEvent * )
107 QPen pen = backgroundPen_;
109 pen.setColor (QColor (127, 166, 218));
116 void Button::hoverLeaveEvent (QGraphicsSceneHoverEvent * )
127 void Button::mousePressEvent (QGraphicsSceneMouseEvent *_event)
129 QBrush brush = backgroundBrush_;
131 brush.setColor (brush.color ().lighter (50));
140 void Button::mouseReleaseEvent (QGraphicsSceneMouseEvent *_event)
151 backgroundBrush_ = _brush;
160 backgroundPen_ = _pen;
167 void Button::paint (QPainter *_painter,
const QStyleOptionGraphicsItem *_option, QWidget *_widget)
171 QPainterPath path =
shape ();
172 QPen curr = _painter->pen ();
174 QPen pen = backgroundPen_;
175 pen.setCapStyle(Qt::RoundCap);
176 pen.setJoinStyle(Qt::RoundJoin);
178 pen.setColor (QColor (127, 166, 218, 64));
180 _painter->setPen (pen);
181 _painter->drawPath (path);
182 pen.setColor (QColor (127, 166, 218, 128));
184 _painter->setPen (pen);
185 _painter->drawPath (path);
186 pen.setColor (QColor (127, 166, 218, 192));
188 _painter->setPen (pen);
189 _painter->drawPath (path);
191 _painter->setPen (curr);
203 if (rect.width () && rect.height ())
204 rect.adjust(-3, -3, 3, 3);
QRectF boundingRect() const
Bounding rectangle.
void setBackground(bool _leftOut, bool _rightOut)
Enables background painting.
void setBackgroundPen(QPen _pen)
Sets the background pen.
void setGeometry(const QRectF &_rect)
Sets the geometry.
virtual void setGeometry(const QRectF &_rect)
Sets the geometry.
void paint(QPainter *_painter, const QStyleOptionGraphicsItem *_option, QWidget *_widget=0)
Button glow painting.
virtual QRectF boundingRect() const
Bounding rectangle.
Button(QGraphicsItem *_parent=0)
Constructor.
void pressed()
emmited if the button gets pressed
virtual void setBackgroundBrush(QBrush _brush)
Sets the background brush.
virtual void setBackgroundPen(QPen _pen)
Sets the background pen.
void setBackgroundBrush(QBrush _brush)
Sets the background brush.
virtual void paint(QPainter *_painter, const QStyleOptionGraphicsItem *_option, QWidget *_widget=0)
Background painting.
QPainterPath shape() const
Returns the shape for proper repainting/event handling.