* provide a Phase singleton
* use it in Corona svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=676831
This commit is contained in:
parent
1fa0feaa48
commit
fab8953ccb
12
corona.cpp
12
corona.cpp
@ -52,14 +52,12 @@ public:
|
|||||||
: formFactor(Planar),
|
: formFactor(Planar),
|
||||||
location(Floating),
|
location(Floating),
|
||||||
layout(0),
|
layout(0),
|
||||||
engineExplorerAction(0),
|
engineExplorerAction(0)
|
||||||
phase(new Phase)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
~Private()
|
~Private()
|
||||||
{
|
{
|
||||||
delete phase;
|
|
||||||
delete layout;
|
delete layout;
|
||||||
qDeleteAll(applets);
|
qDeleteAll(applets);
|
||||||
}
|
}
|
||||||
@ -70,7 +68,6 @@ public:
|
|||||||
Location location;
|
Location location;
|
||||||
Layout* layout;
|
Layout* layout;
|
||||||
QAction *engineExplorerAction;
|
QAction *engineExplorerAction;
|
||||||
Phase* phase;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Corona::Corona(QObject * parent)
|
Corona::Corona(QObject * parent)
|
||||||
@ -195,7 +192,7 @@ void Corona::addPlasmoid(const QString& name)
|
|||||||
d->applets << applet;
|
d->applets << applet;
|
||||||
connect(applet, SIGNAL(destroyed(QObject*)),
|
connect(applet, SIGNAL(destroyed(QObject*)),
|
||||||
this, SLOT(appletDestroyed(QObject*)));
|
this, SLOT(appletDestroyed(QObject*)));
|
||||||
d->phase->animate(applet, Phase::Appear);
|
Phase::self()->animate(applet, Phase::Appear);
|
||||||
} else {
|
} else {
|
||||||
kDebug() << "Plasmoid " << name << " could not be loaded." << endl;
|
kDebug() << "Plasmoid " << name << " could not be loaded." << endl;
|
||||||
}
|
}
|
||||||
@ -206,7 +203,7 @@ void Corona::addKaramba(const KUrl& path)
|
|||||||
QGraphicsItemGroup* karamba = KarambaManager::loadKaramba(path, this);
|
QGraphicsItemGroup* karamba = KarambaManager::loadKaramba(path, this);
|
||||||
if (karamba) {
|
if (karamba) {
|
||||||
addItem(karamba);
|
addItem(karamba);
|
||||||
d->phase->animate(karamba, Phase::Appear);
|
Phase::self()->animate(karamba, Phase::Appear);
|
||||||
} else {
|
} else {
|
||||||
kDebug() << "Karamba " << path << " could not be loaded." << endl;
|
kDebug() << "Karamba " << path << " could not be loaded." << endl;
|
||||||
}
|
}
|
||||||
@ -260,7 +257,8 @@ void Corona::dropEvent(QGraphicsSceneDragDropEvent *event)
|
|||||||
icon->setUrl(url);
|
icon->setUrl(url);
|
||||||
icon->setSize(128,128);
|
icon->setSize(128,128);
|
||||||
//TODO: associate the url with the icon, use the Button plasmoid here
|
//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();
|
icon->show();
|
||||||
addItem(icon);
|
addItem(icon);
|
||||||
}
|
}
|
||||||
|
14
phase.cpp
14
phase.cpp
@ -62,6 +62,20 @@ class Phase::Private
|
|||||||
QMap<QTimeLine*, AnimationState> animations;
|
QMap<QTimeLine*, AnimationState> animations;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class PhaseSingleton
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Phase self;
|
||||||
|
};
|
||||||
|
|
||||||
|
K_GLOBAL_STATIC( PhaseSingleton, privateSelf )
|
||||||
|
|
||||||
|
Phase* Phase::self()
|
||||||
|
{
|
||||||
|
return &privateSelf->self;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Phase::Phase(QObject * parent)
|
Phase::Phase(QObject * parent)
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
d(new Private)
|
d(new Private)
|
||||||
|
5
phase.h
5
phase.h
@ -51,6 +51,11 @@ public:
|
|||||||
RenderBackground = 0 /*<< Render the background of an item */
|
RenderBackground = 0 /*<< Render the background of an item */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Singleton accessor
|
||||||
|
**/
|
||||||
|
static Phase* self();
|
||||||
|
|
||||||
explicit Phase(QObject * parent = 0);
|
explicit Phase(QObject * parent = 0);
|
||||||
~Phase();
|
~Phase();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user