API review:

assContainment() is not a slot, and now there is a public version
without containment id and delayed init params (always assumed as 0 and
false in the public version) and a private version in Private with these
two params used only when restoring the configuration

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=801100
This commit is contained in:
Marco Martin 2008-04-25 17:15:14 +00:00
parent de3ab77f26
commit 282a18571b
2 changed files with 69 additions and 68 deletions

View File

@ -125,6 +125,57 @@ public:
{
q->config()->sync();
}
Containment* addContainment(const QString& name, const QVariantList& args, uint id, bool delayedInit)
{
QString pluginName = name;
Containment* containment = 0;
Applet* applet = 0;
//kDebug() << "Loading" << name << args << id;
if (pluginName.isEmpty()) {
// default to the desktop containment
pluginName = "desktop";
} else if (pluginName != "null") {
applet = Applet::load(pluginName, id, args);
containment = dynamic_cast<Containment*>(applet);
}
if (!containment) {
kDebug() << "loading of containment" << name << "failed.";
// in case we got a non-Containment from Applet::loadApplet or a null containment was requested
delete applet;
containment = new Containment(0, 0, id);
// we want to provide something and don't care about the failure to launch
containment->setFailedToLaunch(false);
containment->setFormFactor(Plasma::Planar);
}
containment->setIsContainment(true);
if (!delayedInit) {
q->addItem(containment);
containment->init();
containment->updateConstraints(Plasma::StartupCompletedConstraint);
}
containments.append(containment);
connect(containment, SIGNAL(destroyed(QObject*)),
q, SLOT(containmentDestroyed(QObject*)));
connect(containment, SIGNAL(configNeedsSaving()),
q, SLOT(scheduleConfigSync()));
connect(containment, SIGNAL(screenChanged(int,int,Plasma::Containment*)),
q, SIGNAL(screenOwnerChanged(int,int,Plasma::Containment*)));
if (!delayedInit) {
emit q->containmentAdded(containment);
}
return containment;
}
Corona *q;
ImmutabilityType immutability;
@ -210,8 +261,8 @@ void Corona::loadLayout(const QString& configName)
int cid = group.toUInt();
//kDebug() << "got a containment in the config, trying to make a" << containmentConfig.readEntry("plugin", QString()) << "from" << group;
Containment *c = addContainment(containmentConfig.readEntry("plugin", QString()), QVariantList(),
cid, true);
Containment *c = d->addContainment(containmentConfig.readEntry("plugin", QString()), QVariantList(),
cid, true);
if (!c) {
continue;
}
@ -280,55 +331,9 @@ KSharedConfigPtr Corona::config() const
return d->config;
}
Containment* Corona::addContainment(const QString& name, const QVariantList& args, uint id, bool delayedInit)
Containment* Corona::addContainment(const QString& name, const QVariantList& args)
{
QString pluginName = name;
Containment* containment = 0;
Applet* applet = 0;
//kDebug() << "Loading" << name << args << id;
if (pluginName.isEmpty()) {
// default to the desktop containment
pluginName = "desktop";
} else if (pluginName != "null") {
applet = Applet::load(pluginName, id, args);
containment = dynamic_cast<Containment*>(applet);
}
if (!containment) {
kDebug() << "loading of containment" << name << "failed.";
// in case we got a non-Containment from Applet::loadApplet or a null containment was requested
delete applet;
containment = new Containment(0, 0, id);
// we want to provide something and don't care about the failure to launch
containment->setFailedToLaunch(false);
containment->setFormFactor(Plasma::Planar);
}
containment->setIsContainment(true);
if (!delayedInit) {
addItem(containment);
containment->init();
containment->updateConstraints(Plasma::StartupCompletedConstraint);
}
d->containments.append(containment);
connect(containment, SIGNAL(destroyed(QObject*)),
this, SLOT(containmentDestroyed(QObject*)));
connect(containment, SIGNAL(configNeedsSaving()),
SLOT(scheduleConfigSync()));
connect(containment, SIGNAL(screenChanged(int,int,Plasma::Containment*)),
this, SIGNAL(screenOwnerChanged(int,int,Plasma::Containment*)));
if (!delayedInit) {
emit containmentAdded(containment);
}
return containment;
return d->addContainment(name, args, 0, false);
}
void Corona::destroyContainment(Containment *c)

View File

@ -71,6 +71,20 @@ public:
*/
KSharedConfig::Ptr config() const;
/**
* Adds a Containment to the Corona
*
* @param name the plugin name for the containment, as given by
* KPluginInfo::pluginName(). If an empty string is passed in, the defalt
* containment plugin will be used (usually DesktopContainment). If the
* string literal "null" is passed in, then no plugin will be loaded and
* a simple Containment object will be created instead.
* @param args argument list to pass to the containment
*
* @return a pointer to the containment on success, or 0 on failure
*/
Containment* addContainment(const QString& name, const QVariantList& args = QVariantList());
public Q_SLOTS:
/**
* Load applet layout from a config file
@ -92,24 +106,6 @@ public Q_SLOTS:
*/
void scheduleConfigSync() const;
/**
* Adds a Containment to the Corona
*
* @param name the plugin name for the containment, as given by
* KPluginInfo::pluginName(). If an empty string is passed in, the defalt
* containment plugin will be used (usually DesktopContainment). If the
* string literal "null" is passed in, then no plugin will be loaded and
* a simple Containment object will be created instead.
* @param args argument list to pass to the containment
* @param id to assign to this containment, or 0 to auto-assign it a new id
* @param geometry where to place the containment, or to auto-place it if an invalid
* is provided
*
* @return a pointer to the containment on success, or 0 on failure
*/
Containment* addContainment(const QString& name, const QVariantList& args = QVariantList(),
uint id = 0, bool delayInit = false);
/**
* Removes a given containment from the corona
*/