* add a targetReached(QRectF) signal for completeness
* emit the targetReached signals in all cases that the target is reached, not just when there is an animation * only emit targetReached(QGrahpicsItem*) when there is a target item * provide a getter for the target rect * register setTarget as a property svn path=/trunk/KDE/kdelibs/; revision=1031661
This commit is contained in:
parent
8587a9dd47
commit
e4f20fdba8
@ -101,6 +101,11 @@ ItemBackground::~ItemBackground()
|
||||
delete d;
|
||||
}
|
||||
|
||||
QRectF ItemBackground::target() const
|
||||
{
|
||||
return d->newGeometry;
|
||||
}
|
||||
|
||||
void ItemBackground::setTarget(const QRectF &newGeometry)
|
||||
{
|
||||
d->oldGeometry = geometry();
|
||||
@ -108,6 +113,10 @@ void ItemBackground::setTarget(const QRectF &newGeometry)
|
||||
|
||||
if (!isVisible() && (!d->target || !d->target->isVisible())) {
|
||||
setGeometry(d->newGeometry);
|
||||
targetReached(newGeometry);
|
||||
if (d->target) {
|
||||
emit targetReached(d->target);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -124,6 +133,10 @@ void ItemBackground::setTarget(const QRectF &newGeometry)
|
||||
setGeometry(newGeometry);
|
||||
d->oldGeometry = newGeometry;
|
||||
show();
|
||||
targetReached(newGeometry);
|
||||
if (d->target) {
|
||||
emit targetReached(d->target);
|
||||
}
|
||||
} else {
|
||||
d->fading = false;
|
||||
d->opacity = 1;
|
||||
@ -256,7 +269,10 @@ void ItemBackgroundPrivate::animationUpdate(qreal progress)
|
||||
if (progress == 1) {
|
||||
animId = 0;
|
||||
if ((!fading) || (fadeIn)) {
|
||||
emit q->targetReached(target);
|
||||
emit q->targetReached(newGeometry);
|
||||
if (target) {
|
||||
emit q->targetReached(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,6 +40,8 @@ class ItemBackgroundPrivate;
|
||||
class PLASMA_EXPORT ItemBackground : public QGraphicsWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QRectF target READ target WRITE setTarget)
|
||||
|
||||
public:
|
||||
ItemBackground(QGraphicsWidget *parent = 0);
|
||||
~ItemBackground();
|
||||
@ -51,6 +53,11 @@ public:
|
||||
*/
|
||||
void setTarget(const QRectF &newGeometry);
|
||||
|
||||
/**
|
||||
* @return the current target rect; may be empty if there is no target currently set
|
||||
*/
|
||||
QRectF target() const;
|
||||
|
||||
/**
|
||||
* set the ItemBackground geometry to be the target geometry, plus the ItemBackground margins
|
||||
*/
|
||||
@ -68,18 +75,21 @@ Q_SIGNALS:
|
||||
*/
|
||||
void appearanceChanged();
|
||||
|
||||
|
||||
/**
|
||||
* Emitted at each animation frame. Useful for synchronizing item animations
|
||||
*/
|
||||
|
||||
void animationStep(qreal progress);
|
||||
|
||||
/**
|
||||
* Emitted when the target has been reached. Useful to consider this instead of
|
||||
* the corresponding hoverEnterEvent;
|
||||
*/
|
||||
void targetReached(QRectF);
|
||||
|
||||
/**
|
||||
* Emitted when the target has been reached. Useful to consider this instead of
|
||||
* the corresponding hoverEnterEvent;
|
||||
*/
|
||||
void targetReached(QGraphicsItem *);
|
||||
|
||||
protected:
|
||||
|
Loading…
x
Reference in New Issue
Block a user