* 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;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QRectF ItemBackground::target() const
|
||||||
|
{
|
||||||
|
return d->newGeometry;
|
||||||
|
}
|
||||||
|
|
||||||
void ItemBackground::setTarget(const QRectF &newGeometry)
|
void ItemBackground::setTarget(const QRectF &newGeometry)
|
||||||
{
|
{
|
||||||
d->oldGeometry = geometry();
|
d->oldGeometry = geometry();
|
||||||
@ -108,6 +113,10 @@ void ItemBackground::setTarget(const QRectF &newGeometry)
|
|||||||
|
|
||||||
if (!isVisible() && (!d->target || !d->target->isVisible())) {
|
if (!isVisible() && (!d->target || !d->target->isVisible())) {
|
||||||
setGeometry(d->newGeometry);
|
setGeometry(d->newGeometry);
|
||||||
|
targetReached(newGeometry);
|
||||||
|
if (d->target) {
|
||||||
|
emit targetReached(d->target);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,6 +133,10 @@ void ItemBackground::setTarget(const QRectF &newGeometry)
|
|||||||
setGeometry(newGeometry);
|
setGeometry(newGeometry);
|
||||||
d->oldGeometry = newGeometry;
|
d->oldGeometry = newGeometry;
|
||||||
show();
|
show();
|
||||||
|
targetReached(newGeometry);
|
||||||
|
if (d->target) {
|
||||||
|
emit targetReached(d->target);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
d->fading = false;
|
d->fading = false;
|
||||||
d->opacity = 1;
|
d->opacity = 1;
|
||||||
@ -256,9 +269,12 @@ void ItemBackgroundPrivate::animationUpdate(qreal progress)
|
|||||||
if (progress == 1) {
|
if (progress == 1) {
|
||||||
animId = 0;
|
animId = 0;
|
||||||
if ((!fading) || (fadeIn)) {
|
if ((!fading) || (fadeIn)) {
|
||||||
|
emit q->targetReached(newGeometry);
|
||||||
|
if (target) {
|
||||||
emit q->targetReached(target);
|
emit q->targetReached(target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (fading) {
|
if (fading) {
|
||||||
opacity = fadeIn?progress:1-progress;
|
opacity = fadeIn?progress:1-progress;
|
||||||
|
@ -40,6 +40,8 @@ class ItemBackgroundPrivate;
|
|||||||
class PLASMA_EXPORT ItemBackground : public QGraphicsWidget
|
class PLASMA_EXPORT ItemBackground : public QGraphicsWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QRectF target READ target WRITE setTarget)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ItemBackground(QGraphicsWidget *parent = 0);
|
ItemBackground(QGraphicsWidget *parent = 0);
|
||||||
~ItemBackground();
|
~ItemBackground();
|
||||||
@ -51,6 +53,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
void setTarget(const QRectF &newGeometry);
|
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
|
* set the ItemBackground geometry to be the target geometry, plus the ItemBackground margins
|
||||||
*/
|
*/
|
||||||
@ -68,18 +75,21 @@ Q_SIGNALS:
|
|||||||
*/
|
*/
|
||||||
void appearanceChanged();
|
void appearanceChanged();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Emitted at each animation frame. Useful for synchronizing item animations
|
* Emitted at each animation frame. Useful for synchronizing item animations
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void animationStep(qreal progress);
|
void animationStep(qreal progress);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Emitted when the target has been reached. Useful to consider this instead of
|
* Emitted when the target has been reached. Useful to consider this instead of
|
||||||
* the corresponding hoverEnterEvent;
|
* 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 *);
|
void targetReached(QGraphicsItem *);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user