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:
|
||||
ItemBackgroundPrivate(ItemBackground *parent)
|
||||
: q(parent)
|
||||
: q(parent),
|
||||
target(0)
|
||||
{}
|
||||
|
||||
void animationUpdate(qreal progress);
|
||||
|
||||
ItemBackground *q;
|
||||
QGraphicsItem *target;
|
||||
Plasma::FrameSvg *frameSvg;
|
||||
QRectF oldGeometry;
|
||||
QRectF newGeometry;
|
||||
@ -106,15 +108,36 @@ void ItemBackground::setTarget(const QRectF &newGeometry)
|
||||
|
||||
void ItemBackground::setTargetItem(QGraphicsItem *target)
|
||||
{
|
||||
if (d->target && d->target != target) {
|
||||
d->target->removeSceneEventFilter(this);
|
||||
}
|
||||
|
||||
if (target) {
|
||||
QRectF rect = target->boundingRect();
|
||||
rect.moveTopLeft(target->pos());
|
||||
setTarget(rect);
|
||||
|
||||
if (d->target != target) {
|
||||
d->target = target;
|
||||
d->target->installSceneEventFilter(this);
|
||||
}
|
||||
} else {
|
||||
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)
|
||||
{
|
||||
if (d->immediate) {
|
||||
|
@ -67,6 +67,11 @@ protected:
|
||||
*/
|
||||
QVariant itemChange(GraphicsItemChange change, const QVariant &value);
|
||||
|
||||
/**
|
||||
* @reimp from QGraphicsItem
|
||||
*/
|
||||
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event);
|
||||
|
||||
private:
|
||||
ItemBackgroundPrivate * const d;
|
||||
Q_PRIVATE_SLOT(d, void animationUpdate(qreal progress))
|
||||
|
Loading…
Reference in New Issue
Block a user