API REVIEW: AnimId -> int
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=800804
This commit is contained in:
parent
eba58a193d
commit
175cf065e7
@ -87,7 +87,7 @@ class AppletHandle : public QObject, public QGraphicsItem
|
|||||||
Applet *m_applet;
|
Applet *m_applet;
|
||||||
qreal m_opacity;
|
qreal m_opacity;
|
||||||
FadeType m_anim;
|
FadeType m_anim;
|
||||||
Phase::AnimId m_animId;
|
int m_animId;
|
||||||
qreal m_angle;
|
qreal m_angle;
|
||||||
qreal m_tempAngle;
|
qreal m_tempAngle;
|
||||||
qreal m_scaleWidth;
|
qreal m_scaleWidth;
|
||||||
|
@ -89,7 +89,7 @@ public:
|
|||||||
KIcon icon;
|
KIcon icon;
|
||||||
EmptyGraphicsItem *toolBacker;
|
EmptyGraphicsItem *toolBacker;
|
||||||
QTime stopwatch;
|
QTime stopwatch;
|
||||||
Plasma::Phase::AnimId animId;
|
int animId;
|
||||||
qreal animFrame;
|
qreal animFrame;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ public:
|
|||||||
KIcon icon;
|
KIcon icon;
|
||||||
EmptyGraphicsItem *toolBacker;
|
EmptyGraphicsItem *toolBacker;
|
||||||
QTime stopwatch;
|
QTime stopwatch;
|
||||||
Plasma::Phase::AnimId animId;
|
int animId;
|
||||||
qreal animFrame;
|
qreal animFrame;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
32
phase.cpp
32
phase.cpp
@ -82,7 +82,7 @@ struct CustomAnimationState
|
|||||||
int currentFrame;
|
int currentFrame;
|
||||||
int interval;
|
int interval;
|
||||||
int currentInterval;
|
int currentInterval;
|
||||||
Phase::AnimId id;
|
int id;
|
||||||
QObject* receiver;
|
QObject* receiver;
|
||||||
char* slot;
|
char* slot;
|
||||||
};
|
};
|
||||||
@ -104,7 +104,7 @@ class Phase::Private
|
|||||||
qDeleteAll(animatedElements);
|
qDeleteAll(animatedElements);
|
||||||
qDeleteAll(movingItems);
|
qDeleteAll(movingItems);
|
||||||
|
|
||||||
QMutableMapIterator<AnimId, CustomAnimationState*> it(customAnims);
|
QMutableMapIterator<int, CustomAnimationState*> it(customAnims);
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
delete it.value()->slot;
|
delete it.value()->slot;
|
||||||
delete it.value();
|
delete it.value();
|
||||||
@ -171,8 +171,8 @@ class Phase::Private
|
|||||||
// and really making the code fun ;)
|
// and really making the code fun ;)
|
||||||
QMap<QGraphicsItem*, AnimationState*> animatedItems;
|
QMap<QGraphicsItem*, AnimationState*> animatedItems;
|
||||||
QMap<QGraphicsItem*, MovementState*> movingItems;
|
QMap<QGraphicsItem*, MovementState*> movingItems;
|
||||||
QMap<AnimId, ElementAnimationState*> animatedElements;
|
QMap<int, ElementAnimationState*> animatedElements;
|
||||||
QMap<AnimId, CustomAnimationState*> customAnims;
|
QMap<int, CustomAnimationState*> customAnims;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PhaseSingleton
|
class PhaseSingleton
|
||||||
@ -230,7 +230,7 @@ void Phase::movingItemDestroyed(QObject* o)
|
|||||||
|
|
||||||
void Phase::animatedElementDestroyed(QObject* o)
|
void Phase::animatedElementDestroyed(QObject* o)
|
||||||
{
|
{
|
||||||
QMutableMapIterator<AnimId, ElementAnimationState*> it(d->animatedElements);
|
QMutableMapIterator<int, ElementAnimationState*> it(d->animatedElements);
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
it.next();
|
it.next();
|
||||||
if (it.value()->qobj == o) {
|
if (it.value()->qobj == o) {
|
||||||
@ -242,7 +242,7 @@ void Phase::animatedElementDestroyed(QObject* o)
|
|||||||
|
|
||||||
void Phase::customAnimReceiverDestroyed(QObject* o)
|
void Phase::customAnimReceiverDestroyed(QObject* o)
|
||||||
{
|
{
|
||||||
QMutableMapIterator<AnimId, CustomAnimationState*> it(d->customAnims);
|
QMutableMapIterator<int, CustomAnimationState*> it(d->customAnims);
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
if (it.next().value()->receiver == o) {
|
if (it.next().value()->receiver == o) {
|
||||||
delete it.value()->slot;
|
delete it.value()->slot;
|
||||||
@ -342,7 +342,7 @@ void Phase::moveItem(QGraphicsItem* item, Movement movement, const QPoint &desti
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Phase::AnimId Phase::customAnimation(int frames, int duration, Phase::CurveShape curve,
|
int Phase::customAnimation(int frames, int duration, Phase::CurveShape curve,
|
||||||
QObject* receiver, const char* slot)
|
QObject* receiver, const char* slot)
|
||||||
{
|
{
|
||||||
if (frames < 1 || duration < 1 || !receiver || !slot) {
|
if (frames < 1 || duration < 1 || !receiver || !slot) {
|
||||||
@ -378,9 +378,9 @@ Phase::AnimId Phase::customAnimation(int frames, int duration, Phase::CurveShape
|
|||||||
return state->id;
|
return state->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Phase::stopCustomAnimation(AnimId id)
|
void Phase::stopCustomAnimation(int id)
|
||||||
{
|
{
|
||||||
QMap<AnimId, CustomAnimationState*>::iterator it = d->customAnims.find(id);
|
QMap<int, CustomAnimationState*>::iterator it = d->customAnims.find(id);
|
||||||
if (it != d->customAnims.end()) {
|
if (it != d->customAnims.end()) {
|
||||||
delete [] it.value()->slot;
|
delete [] it.value()->slot;
|
||||||
delete it.value();
|
delete it.value();
|
||||||
@ -389,7 +389,7 @@ void Phase::stopCustomAnimation(AnimId id)
|
|||||||
//kDebug() << "stopCustomAnimation(AnimId " << id << ") done";
|
//kDebug() << "stopCustomAnimation(AnimId " << id << ") done";
|
||||||
}
|
}
|
||||||
|
|
||||||
Phase::AnimId Phase::animateElement(QGraphicsItem *item, ElementAnimation animation)
|
int Phase::animateElement(QGraphicsItem *item, ElementAnimation animation)
|
||||||
{
|
{
|
||||||
//kDebug() << "startElementAnimation(AnimId " << animation << ")";
|
//kDebug() << "startElementAnimation(AnimId " << animation << ")";
|
||||||
ElementAnimationState *state = new ElementAnimationState;
|
ElementAnimationState *state = new ElementAnimationState;
|
||||||
@ -430,9 +430,9 @@ Phase::AnimId Phase::animateElement(QGraphicsItem *item, ElementAnimation animat
|
|||||||
return state->id;
|
return state->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Phase::stopElementAnimation(AnimId id)
|
void Phase::stopElementAnimation(int id)
|
||||||
{
|
{
|
||||||
QMap<AnimId, ElementAnimationState*>::iterator it = d->animatedElements.find(id);
|
QMap<int, ElementAnimationState*>::iterator it = d->animatedElements.find(id);
|
||||||
if (it != d->animatedElements.end()) {
|
if (it != d->animatedElements.end()) {
|
||||||
delete it.value();
|
delete it.value();
|
||||||
d->animatedElements.erase(it);
|
d->animatedElements.erase(it);
|
||||||
@ -440,9 +440,9 @@ void Phase::stopElementAnimation(AnimId id)
|
|||||||
//kDebug() << "stopElementAnimation(AnimId " << id << ") done";
|
//kDebug() << "stopElementAnimation(AnimId " << id << ") done";
|
||||||
}
|
}
|
||||||
|
|
||||||
void Phase::setInitialPixmap(AnimId id, const QPixmap &pixmap)
|
void Phase::setInitialPixmap(int id, const QPixmap &pixmap)
|
||||||
{
|
{
|
||||||
QMap<AnimId, ElementAnimationState*>::iterator it = d->animatedElements.find(id);
|
QMap<int, ElementAnimationState*>::iterator it = d->animatedElements.find(id);
|
||||||
|
|
||||||
if (it == d->animatedElements.end()) {
|
if (it == d->animatedElements.end()) {
|
||||||
kDebug() << "Phase::setInitialPixmap(" << id << ") found no entry for it!";
|
kDebug() << "Phase::setInitialPixmap(" << id << ") found no entry for it!";
|
||||||
@ -452,9 +452,9 @@ void Phase::setInitialPixmap(AnimId id, const QPixmap &pixmap)
|
|||||||
it.value()->pixmap = pixmap;
|
it.value()->pixmap = pixmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap Phase::currentPixmap(AnimId id)
|
QPixmap Phase::currentPixmap(int id)
|
||||||
{
|
{
|
||||||
QMap<AnimId, ElementAnimationState*>::const_iterator it = d->animatedElements.find(id);
|
QMap<int, ElementAnimationState*>::const_iterator it = d->animatedElements.find(id);
|
||||||
|
|
||||||
if (it == d->animatedElements.constEnd()) {
|
if (it == d->animatedElements.constEnd()) {
|
||||||
//kDebug() << "Phase::currentPixmap(" << id << ") found no entry for it!";
|
//kDebug() << "Phase::currentPixmap(" << id << ") found no entry for it!";
|
||||||
|
18
phase.h
18
phase.h
@ -72,8 +72,6 @@ public:
|
|||||||
FastSlideOutMovement
|
FastSlideOutMovement
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef int AnimId;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Singleton accessor
|
* Singleton accessor
|
||||||
**/
|
**/
|
||||||
@ -99,7 +97,7 @@ public:
|
|||||||
*
|
*
|
||||||
* @return an id that can be used to identify this animation.
|
* @return an id that can be used to identify this animation.
|
||||||
*/
|
*/
|
||||||
Q_INVOKABLE AnimId customAnimation(int frames, int duration, Phase::CurveShape curve,
|
Q_INVOKABLE int customAnimation(int frames, int duration, Phase::CurveShape curve,
|
||||||
QObject* receiver, const char* method);
|
QObject* receiver, const char* method);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -109,12 +107,12 @@ public:
|
|||||||
*
|
*
|
||||||
* @arg id the id of the animation as returned by customAnimation
|
* @arg id the id of the animation as returned by customAnimation
|
||||||
*/
|
*/
|
||||||
Q_INVOKABLE void stopCustomAnimation(AnimId id);
|
Q_INVOKABLE void stopCustomAnimation(int id);
|
||||||
|
|
||||||
Q_INVOKABLE AnimId animateElement(QGraphicsItem *obj, ElementAnimation);
|
Q_INVOKABLE int animateElement(QGraphicsItem *obj, ElementAnimation);
|
||||||
Q_INVOKABLE void stopElementAnimation(AnimId id);
|
Q_INVOKABLE void stopElementAnimation(int id);
|
||||||
Q_INVOKABLE void setInitialPixmap(AnimId id, const QPixmap &pixmap);
|
Q_INVOKABLE void setInitialPixmap(int id, const QPixmap &pixmap);
|
||||||
Q_INVOKABLE QPixmap currentPixmap(AnimId id);
|
Q_INVOKABLE QPixmap currentPixmap(int id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Can be used to query if there are other animations happening. This way
|
* Can be used to query if there are other animations happening. This way
|
||||||
@ -127,8 +125,8 @@ public:
|
|||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void animationFinished(QGraphicsItem *item, Plasma::Phase::Animation anim);
|
void animationFinished(QGraphicsItem *item, Plasma::Phase::Animation anim);
|
||||||
void movementFinished(QGraphicsItem *item);
|
void movementFinished(QGraphicsItem *item);
|
||||||
void elementAnimationFinished(Plasma::Phase::AnimId id);
|
void elementAnimationFinished(int id);
|
||||||
void customAnimationFinished(Plasma::Phase::AnimId id);
|
void customAnimationFinished(int id);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void timerEvent(QTimerEvent *event);
|
void timerEvent(QTimerEvent *event);
|
||||||
|
@ -230,7 +230,7 @@ bool IconAction::event(QEvent::Type type, const QPointF &pos)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Phase::AnimId IconAction::animationId() const
|
int IconAction::animationId() const
|
||||||
{
|
{
|
||||||
return m_animationId;
|
return m_animationId;
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ public:
|
|||||||
void hide();
|
void hide();
|
||||||
bool isVisible() const;
|
bool isVisible() const;
|
||||||
|
|
||||||
Phase::AnimId animationId() const;
|
int animationId() const;
|
||||||
QAction* action() const;
|
QAction* action() const;
|
||||||
|
|
||||||
void paint(QPainter *painter) const;
|
void paint(QPainter *painter) const;
|
||||||
@ -79,7 +79,7 @@ private:
|
|||||||
bool m_selected;
|
bool m_selected;
|
||||||
bool m_visible;
|
bool m_visible;
|
||||||
|
|
||||||
Phase::AnimId m_animationId;
|
int m_animationId;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -171,7 +171,7 @@ public:
|
|||||||
QColor textColor;
|
QColor textColor;
|
||||||
QColor shadowColor;
|
QColor shadowColor;
|
||||||
bool m_fadeIn;
|
bool m_fadeIn;
|
||||||
Phase::AnimId m_hoverAnimId;
|
int m_hoverAnimId;
|
||||||
qreal m_hoverAlpha;
|
qreal m_hoverAlpha;
|
||||||
QSizeF iconSize;
|
QSizeF iconSize;
|
||||||
QIcon icon;
|
QIcon icon;
|
||||||
|
Loading…
Reference in New Issue
Block a user