* provide a Phase singleton

* use it in Corona

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=676831
This commit is contained in:
Aaron J. Seigo 2007-06-17 20:05:43 +00:00
parent 1fa0feaa48
commit fab8953ccb
3 changed files with 24 additions and 7 deletions

View File

@ -52,14 +52,12 @@ public:
: formFactor(Planar),
location(Floating),
layout(0),
engineExplorerAction(0),
phase(new Phase)
engineExplorerAction(0)
{
}
~Private()
{
delete phase;
delete layout;
qDeleteAll(applets);
}
@ -70,7 +68,6 @@ public:
Location location;
Layout* layout;
QAction *engineExplorerAction;
Phase* phase;
};
Corona::Corona(QObject * parent)
@ -195,7 +192,7 @@ void Corona::addPlasmoid(const QString& name)
d->applets << applet;
connect(applet, SIGNAL(destroyed(QObject*)),
this, SLOT(appletDestroyed(QObject*)));
d->phase->animate(applet, Phase::Appear);
Phase::self()->animate(applet, Phase::Appear);
} else {
kDebug() << "Plasmoid " << name << " could not be loaded." << endl;
}
@ -206,7 +203,7 @@ void Corona::addKaramba(const KUrl& path)
QGraphicsItemGroup* karamba = KarambaManager::loadKaramba(path, this);
if (karamba) {
addItem(karamba);
d->phase->animate(karamba, Phase::Appear);
Phase::self()->animate(karamba, Phase::Appear);
} else {
kDebug() << "Karamba " << path << " could not be loaded." << endl;
}
@ -260,7 +257,8 @@ void Corona::dropEvent(QGraphicsSceneDragDropEvent *event)
icon->setUrl(url);
icon->setSize(128,128);
//TODO: associate the url with the icon, use the Button plasmoid here
icon->setPos(event->scenePos()-QPoint(icon->boundingRect().width()/2,icon->boundingRect().height()/2));
icon->setPos(event->scenePos() - QPoint(icon->boundingRect().width()/2,
icon->boundingRect().height()/2));
icon->show();
addItem(icon);
}

View File

@ -62,6 +62,20 @@ class Phase::Private
QMap<QTimeLine*, AnimationState> animations;
};
class PhaseSingleton
{
public:
Phase self;
};
K_GLOBAL_STATIC( PhaseSingleton, privateSelf )
Phase* Phase::self()
{
return &privateSelf->self;
}
Phase::Phase(QObject * parent)
: QObject(parent),
d(new Private)

View File

@ -51,6 +51,11 @@ public:
RenderBackground = 0 /*<< Render the background of an item */
};
/**
* Singleton accessor
**/
static Phase* self();
explicit Phase(QObject * parent = 0);
~Phase();