1 #include "raptorclaw.h"
4 #include <kicontheme.h>
5 #include "raptorclaw.moc"
7 class RaptorClaw::Private
14 Plasma::Svg
* m_theme
;
32 RaptorClaw::RaptorClaw(QGraphicsItem
*parent
)
33 : QGraphicsItem(parent
)
37 setAcceptsHoverEvents(true);
41 d
->m_theme
= new Plasma::Svg( "menu/raptorslide",this);
42 d
->m_theme
->resize(d
->width
, d
->height
);
44 //Do not hardcode Get from config/xml
45 d
->text
= "RaptorItem";
46 d
->ids
[REGULAR
] = "itemNormal";
47 d
->ids
[OVER
] = "itemOver";
48 d
->ids
[PRESSED
] = "itemOver";
50 d
->size
= d
->m_theme
->size();
51 d
->elementSize
= d
->m_theme
->elementSize("itemNormal");
52 d
->iconPixmap
= QPixmap();
54 //FIXME: need methods for these
59 RaptorClaw::~RaptorClaw()
65 void RaptorClaw::paint(QPainter
*painter
, const QStyleOptionGraphicsItem
*option
, QWidget
*widget
)
69 painter
->setOpacity(d
->opacity
);
70 painter
->setRenderHint(QPainter::SmoothPixmapTransform
);
71 d
->m_theme
->resize(d
->width
,d
->height
);
72 QRectF
source(x(), y(), d
->elementSize
.width() , d
->elementSize
.height());
73 d
->m_theme
->paint(painter
, (int)x(),(int)y(), d
->ids
[d
->state
]);
74 if (!d
->iconPixmap
.isNull()) {
75 painter
->drawPixmap(int(x()+((int)source
.width()-d
->iconPixmap
.width())/2),int(y()+
76 ((int)source
.height()-d
->iconPixmap
.height())/2),d
->iconPixmap
.height(),d
->iconPixmap
.width(),d
->iconPixmap
);
78 kDebug()<<"NUll Icon Pixmap"<<endl
;
81 //painter->drawText(source,Qt::AlignCenter,d->text);
84 void RaptorClaw::setOpacity(float op
)
88 QString
RaptorClaw::loadSvg(MouseState state
)
93 QSize
RaptorClaw::sizeHint() const
95 return QSize(d
->height
,d
->width
);
98 QSize
RaptorClaw::minimumSize() const
100 return QSize(d
->height
,d
->width
);
103 QRect
RaptorClaw::geometry() const
105 return QRect((int)x(),(int)y(),d
->height
,d
->width
);
108 QSize
RaptorClaw::maximumSize() const
110 return QSize(d
->height
,d
->width
);
113 QRectF
RaptorClaw::boundingRect() const
115 return QRectF (x(),y(),d
->elementSize
.width(),d
->elementSize
.height());
119 void RaptorClaw::hoverEnterEvent(QGraphicsSceneHoverEvent
*event
)
126 void RaptorClaw::hoverMoveEvent(QGraphicsSceneHoverEvent
*event
)
133 void RaptorClaw::hoverLeaveEvent(QGraphicsSceneHoverEvent
*event
)
140 QString
RaptorClaw::name()
145 void RaptorClaw::setName(const QString
& name
)
150 void RaptorClaw::setIcon(QPixmap icon
)
152 d
->iconPixmap
= QPixmap(icon
);