1 #include "raptorscrollhandler.h"
3 #include "raptorscrollhandler.moc"
5 class RaptorScrollHandler::Private
12 Plasma::Svg
* m_theme
;
19 Qt::Orientations orientation
;
24 RaptorScrollHandler::RaptorScrollHandler(QGraphicsItem
* parent
) : QGraphicsItem(parent
),d(new Private
)
27 setAcceptsHoverEvents(true);
31 d
->m_theme
= new Plasma::Svg( "menu/raptorslide",this);
32 d
->m_theme
->resize(d
->height
,d
->width
);
34 setExpandingDirections(Qt::Vertical
);
36 d
->size
= d
->m_theme
->size();
37 //d->size = QSize(d->size.width()/10,d->size.height()/10);
38 d
->elementSize
= d
->m_theme
->elementSize("arrowUp");
40 d
->orientation
= Qt::Vertical
;
43 void RaptorScrollHandler::setArrowState(RaptorScrollHandler::ArrowState state
)
46 d
->ids
[REGULAR
] = "arrowUp";
47 d
->ids
[OVER
] = "arrowUp";
48 d
->ids
[PRESSED
] = "arrowUp";
49 } else if ( state
== DOWN
) {
50 d
->ids
[REGULAR
] = "arrowDown";
51 d
->ids
[OVER
] = "arrowDown";
52 d
->ids
[PRESSED
] = "arrowDown";
53 } else if ( state
== LEFT
) {
54 d
->ids
[REGULAR
] = "arrowLeft";
55 d
->ids
[OVER
] = "arrowLeft";
56 d
->ids
[PRESSED
] = "arrowLeft";
57 d
->elementSize
= d
->m_theme
->elementSize("arrowLeft");
58 } else if ( state
== RIGHT
) {
59 d
->ids
[REGULAR
] = "arrowRight";
60 d
->ids
[OVER
] = "arrowRight";
61 d
->ids
[PRESSED
] = "arrowRight";
62 d
->elementSize
= d
->m_theme
->elementSize("arrowRight");
68 RaptorScrollHandler::~RaptorScrollHandler()
74 void RaptorScrollHandler::setExpandingDirections(Qt::Orientations ori
)
78 if (d->orientation == Qt::Vertical) {
79 d->ids[REGULAR] = "arrowUp";
80 d->ids[OVER] = "arrowUp";
81 d->ids[PRESSED] = "arrowUp";
84 d->ids[REGULAR] = "arrowBot";
85 d->ids[OVER] = "arrowBot";
86 d->ids[PRESSED] = "arrowDown";
92 void RaptorScrollHandler::paint ( QPainter
* painter
, const QStyleOptionGraphicsItem
* option
, QWidget
* widget
)
94 d
->m_theme
->resize(d
->height
,d
->width
);
95 painter
->setRenderHint(QPainter::SmoothPixmapTransform
);
96 QRectF source
= boundingRect();//(x(), y(), d->width , d->height );
97 d
->m_theme
->paint(painter
, x(),y(), d
->ids
[d
->state
]);
98 //painter->drawRect(boundingRect());
101 QString
RaptorScrollHandler::loadSvg(MouseState state
)
103 return d
->ids
[state
];
106 QSize
RaptorScrollHandler::sizeHint() const
108 return QSize(d
->width
,d
->height
);
111 QRectF
RaptorScrollHandler::boundingRect() const
113 //kDebug() << QRectF (x(),y(),d->elementSize.width(),d->elementSize.height());
114 return QRectF (x(),y(),d
->elementSize
.width(),d
->elementSize
.height());
118 QRect RaptorScrollHandler::geometry () const
120 return QRect (x(),y(),d->width,d->height);
126 void RaptorScrollHandler::hoverEnterEvent ( QGraphicsSceneHoverEvent
* event
)
133 void RaptorScrollHandler::hoverMoveEvent ( QGraphicsSceneHoverEvent
* event
)
136 d
->m_theme
->resize(d
->width
,d
->height
);
141 void RaptorScrollHandler::hoverLeaveEvent ( QGraphicsSceneHoverEvent
* event
)
147 void RaptorScrollHandler::mousePressEvent ( QGraphicsSceneMouseEvent
* event
)