move/resize the background when the target item does so
svn path=/trunk/KDE/kdelibs/; revision=1017728
This commit is contained in:
parent
88faa0813f
commit
bf26e35f5c
@ -34,12 +34,14 @@ class ItemBackgroundPrivate
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ItemBackgroundPrivate(ItemBackground *parent)
|
ItemBackgroundPrivate(ItemBackground *parent)
|
||||||
: q(parent)
|
: q(parent),
|
||||||
|
target(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void animationUpdate(qreal progress);
|
void animationUpdate(qreal progress);
|
||||||
|
|
||||||
ItemBackground *q;
|
ItemBackground *q;
|
||||||
|
QGraphicsItem *target;
|
||||||
Plasma::FrameSvg *frameSvg;
|
Plasma::FrameSvg *frameSvg;
|
||||||
QRectF oldGeometry;
|
QRectF oldGeometry;
|
||||||
QRectF newGeometry;
|
QRectF newGeometry;
|
||||||
@ -106,15 +108,36 @@ void ItemBackground::setTarget(const QRectF &newGeometry)
|
|||||||
|
|
||||||
void ItemBackground::setTargetItem(QGraphicsItem *target)
|
void ItemBackground::setTargetItem(QGraphicsItem *target)
|
||||||
{
|
{
|
||||||
|
if (d->target && d->target != target) {
|
||||||
|
d->target->removeSceneEventFilter(this);
|
||||||
|
}
|
||||||
|
|
||||||
if (target) {
|
if (target) {
|
||||||
QRectF rect = target->boundingRect();
|
QRectF rect = target->boundingRect();
|
||||||
rect.moveTopLeft(target->pos());
|
rect.moveTopLeft(target->pos());
|
||||||
setTarget(rect);
|
setTarget(rect);
|
||||||
|
|
||||||
|
if (d->target != target) {
|
||||||
|
d->target = target;
|
||||||
|
d->target->installSceneEventFilter(this);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
hide();
|
hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ItemBackground::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
|
||||||
|
{
|
||||||
|
if (watched == d->target) {
|
||||||
|
if (event->type() == QEvent::GraphicsSceneResize ||
|
||||||
|
event->type() == QEvent::GraphicsSceneMove) {
|
||||||
|
setTargetItem(d->target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
QVariant ItemBackground::itemChange(GraphicsItemChange change, const QVariant &value)
|
QVariant ItemBackground::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||||
{
|
{
|
||||||
if (d->immediate) {
|
if (d->immediate) {
|
||||||
|
@ -67,6 +67,11 @@ protected:
|
|||||||
*/
|
*/
|
||||||
QVariant itemChange(GraphicsItemChange change, const QVariant &value);
|
QVariant itemChange(GraphicsItemChange change, const QVariant &value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @reimp from QGraphicsItem
|
||||||
|
*/
|
||||||
|
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ItemBackgroundPrivate * const d;
|
ItemBackgroundPrivate * const d;
|
||||||
Q_PRIVATE_SLOT(d, void animationUpdate(qreal progress))
|
Q_PRIVATE_SLOT(d, void animationUpdate(qreal progress))
|
||||||
|
Loading…
Reference in New Issue
Block a user