From fab8953ccba00d95a8313cc0b55447415e0f5b3b Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Sun, 17 Jun 2007 20:05:43 +0000 Subject: [PATCH] * provide a Phase singleton * use it in Corona svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=676831 --- corona.cpp | 12 +++++------- phase.cpp | 14 ++++++++++++++ phase.h | 5 +++++ 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/corona.cpp b/corona.cpp index 59f9b80ef..b30e9b04a 100644 --- a/corona.cpp +++ b/corona.cpp @@ -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); } diff --git a/phase.cpp b/phase.cpp index c4f98b4ba..34ad8b223 100644 --- a/phase.cpp +++ b/phase.cpp @@ -62,6 +62,20 @@ class Phase::Private QMap 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) diff --git a/phase.h b/phase.h index f72cfc99a..4dc4c5404 100644 --- a/phase.h +++ b/phase.h @@ -51,6 +51,11 @@ public: RenderBackground = 0 /*<< Render the background of an item */ }; + /** + * Singleton accessor + **/ + static Phase* self(); + explicit Phase(QObject * parent = 0); ~Phase();