1 #include "contactbutton.h"
4 #include <QGraphicsSceneMouseEvent>
7 ContactButton::ContactButton( const QString
&pixmapPath
, QGraphicsItem
*parent
)
8 : QGraphicsWidget( parent
)
10 if ( mPixmap
.load( pixmapPath
) )
11 qDebug()<<"error loading path:"<<pixmapPath
;
12 resize(mPixmap
.width(), mPixmap
.height());
13 setAcceptedMouseButtons( Qt::LeftButton
);
17 ContactButton::ContactButton( ContactButton
&button
)
19 setAcceptedMouseButtons( Qt::LeftButton
);
20 setGeometry( button
.geometry() );
22 mPixmap
= button
.mPixmap
;
23 setFlag(ItemIgnoresParentOpacity
);
26 void ContactButton::paint( QPainter
* painter
, const QStyleOptionGraphicsItem
* option
, QWidget
* widget
)
29 painter
->drawPixmap(QPoint( 0, 0 ), mPixmap
);
32 void ContactButton::mousePressEvent(QGraphicsSceneMouseEvent
*event
)
34 qDebug()<< "ContactButton::mousePressEvent = " << event
->pos() <<" "<< geometry();
36 return QGraphicsItem::mousePressEvent(event
);
39 QSizeF
ContactButton::sizeHint( Qt::SizeHint which
, const QSizeF
& constraint
) const
41 //Adjust it to work with pulser
44 case Qt::PreferredSize:
45 return mPixmap.size();
47 return mPixmap.size();
52 return QGraphicsWidget::sizeHint(which
, constraint
);