remove the applet from the applets list in the corona on destruction

svn path=/trunk/KDE/kdebase/workspace/plasma/lib/; revision=670628
This commit is contained in:
Aaron J. Seigo 2007-06-02 07:51:11 +00:00
parent 59641c640e
commit 3471f8e078
2 changed files with 19 additions and 4 deletions

View File

@ -100,7 +100,7 @@ void Corona::init()
// connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(displayContextMenu(QPoint)));
d->engineExplorerAction = new QAction(i18n("Engine Explorer"), this);
connect(d->engineExplorerAction, SIGNAL(triggered(bool)), this, SLOT(launchExplorer(bool)));
connect(d->engineExplorerAction, SIGNAL(triggered(bool)), this, SLOT(launchExplorer()));
// setContextMenuPolicy(Qt::CustomContextMenu);
}
@ -180,7 +180,7 @@ void Corona::addPlasmoid(const QString& name)
addItem(applet);
//applet->constraintsUpdated();
d->applets << applet;
connect(applet, SIGNAL(destroyed(QObject)),
connect(applet, SIGNAL(destroyed(QObject*)),
this, SLOT(appletDestroyed(QObject*)));
} else {
kDebug() << "Plasmoid " << name << " could not be loaded." << endl;
@ -283,11 +283,25 @@ void Corona::contextMenuEvent(QGraphicsSceneContextMenuEvent *contextMenuEvent)
contextMenuEvent->accept();
}
void Corona::launchExplorer(bool /*param*/)
void Corona::launchExplorer()
{
QProcess::execute("plasmaengineexplorer");
}
void Corona::appletDestroyed(QObject* object)
{
// we do a static_cast here since it really isn't an Applet by this
// point anymore since we are in the qobject dtor. we don't actually
// try and do anything with it, we just need the value of the pointer
// so this unsafe looking code is actually just fine.
Applet* applet = static_cast<Plasma::Applet*>(object);
int index = d->applets.indexOf(applet);
if (index > -1) {
d->applets.removeAt(index);
}
}
} // namespace Plasma
#include "corona.moc"

View File

@ -102,7 +102,8 @@ protected:
void contextMenuEvent(QGraphicsSceneContextMenuEvent *contextMenuEvent);
protected Q_SLOTS:
void launchExplorer(bool /*param*/);
void launchExplorer();
void appletDestroyed(QObject*);
private:
void init();