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
) : QGraphicsItem(parent
),d(new Private
)
35 setAcceptsHoverEvents(true);
39 d
->m_theme
= new Plasma::Svg( "menu/raptorslide",this);
40 d
->m_theme
->resize(d
->width
,d
->height
);
42 //Do not hardcode Get from config/xml
43 d
->text
= "RaptorItem";
44 d
->ids
[REGULAR
] = "itemNormal";
45 d
->ids
[OVER
] = QString("itemOver");
46 d
->ids
[PRESSED
] = "itemOver";
48 d
->size
= d
->m_theme
->size();
49 d
->elementSize
= d
->m_theme
->elementSize("itemNormal");
50 d
->iconPixmap
= QPixmap();
52 //FIXME: need methods for these
58 RaptorClaw::~RaptorClaw()
64 void RaptorClaw::paint ( QPainter
* painter
, const QStyleOptionGraphicsItem
* option
, QWidget
* widget
)
68 painter
->setOpacity(d
->opacity
);
69 painter
->setRenderHint(QPainter::SmoothPixmapTransform
);
70 d
->m_theme
->resize(d
->width
,d
->height
);
71 QRectF
source(x(), y(), d
->elementSize
.width() , d
->elementSize
.height());
72 d
->m_theme
->paint(painter
, (int)x(),(int)y(), d
->ids
[d
->state
]);
73 if (!d
->iconPixmap
.isNull()) {
74 painter
->drawPixmap(int(x()+((int)source
.width()-d
->iconPixmap
.width())/2),int(y()+
75 ((int)source
.height()-d
->iconPixmap
.height())/2),d
->iconPixmap
.height(),d
->iconPixmap
.width(),d
->iconPixmap
);
77 kDebug()<<"NUll Icon Pixmap"<<endl
;
80 //painter->drawText(source,Qt::AlignCenter,d->text);
83 void RaptorClaw::setOpacity(float op
)
87 QString
RaptorClaw::loadSvg(MouseState state
)
92 QSize
RaptorClaw::sizeHint() const
94 return QSize(d
->height
,d
->width
);
97 QSize
RaptorClaw::minimumSize() const
99 return QSize(d
->height
,d
->width
);
102 QRect
RaptorClaw::geometry() const
104 return QRect((int)x(),(int)y(),d
->height
,d
->width
);
107 QSize
RaptorClaw::maximumSize() const
109 return QSize(d
->height
,d
->width
);
111 QRectF
RaptorClaw::boundingRect() const
113 return QRectF (x(),y(),d
->elementSize
.width(),d
->elementSize
.height());
117 void RaptorClaw::hoverEnterEvent ( QGraphicsSceneHoverEvent
* event
)
124 void RaptorClaw::hoverMoveEvent ( QGraphicsSceneHoverEvent
* event
)
131 void RaptorClaw::hoverLeaveEvent ( QGraphicsSceneHoverEvent
* event
)
138 QString
RaptorClaw::name()
143 void RaptorClaw::setName(const QString
& name
)
148 void RaptorClaw::setIcon(QPixmap icon
)
150 d
->iconPixmap
= QPixmap(icon
);