diff --git a/corona.cpp b/corona.cpp index cc92e5a57..a7f62a6c6 100644 --- a/corona.cpp +++ b/corona.cpp @@ -92,6 +92,20 @@ QString Corona::appletMimeType() return d->mimetype; } +void Corona::setDefaultContainmentPlugin(const QString &name) +{ + // we could check if it is in: + // Containment::listContainments().contains(name) || + // Containment::listContainments(QString(), KGlobal::mainComponent().componentName()).contains(name) + // but that seems like overkill + d->defaultContainmentPlugin = name; +} + +QString Corona::defaultContainmentPlugin() const +{ + return d->defaultContainmentPlugin; +} + void Corona::saveLayout(const QString &configName) const { KSharedConfigPtr c; @@ -744,6 +758,7 @@ CoronaPrivate::CoronaPrivate(Corona *corona) : q(corona), immutability(Mutable), mimetype("text/x-plasmoidservicename"), + defaultContainmentPlugin("desktop"), config(0), actions(corona) { @@ -874,8 +889,7 @@ void CoronaPrivate::syncConfig() emit q->configSynced(); } -Containment *CoronaPrivate::addContainment(const QString &name, const QVariantList &args, - uint id, bool delayedInit) +Containment *CoronaPrivate::addContainment(const QString &name, const QVariantList &args, uint id, bool delayedInit) { QString pluginName = name; Containment *containment = 0; @@ -885,7 +899,7 @@ Containment *CoronaPrivate::addContainment(const QString &name, const QVariantLi if (pluginName.isEmpty() || pluginName == "default") { // default to the desktop containment - pluginName = "desktop"; + pluginName = defaultContainmentPlugin; } bool loadingNull = pluginName == "null"; diff --git a/corona.h b/corona.h index 50dcfa057..4104ff618 100644 --- a/corona.h +++ b/corona.h @@ -66,6 +66,12 @@ public: */ QString appletMimeType(); + /** + * @return the default containment plugin type + * @since 4.7 + */ + QString defaultContainmentPlugin() const; + /** * @return all containments on this Corona */ @@ -479,6 +485,12 @@ protected: */ void setPreferredToolBoxPlugin(const Containment::Type type, const QString &plugin); + /** + * Sets the default containment plugin to try and load + * @since 4.7 + */ + void setDefaultContainmentPlugin(const QString &name); + //Reimplemented from QGraphicsScene void dragEnterEvent(QGraphicsSceneDragDropEvent *event); void dragLeaveEvent(QGraphicsSceneDragDropEvent *event); diff --git a/private/corona_p.h b/private/corona_p.h index 5240fc2af..5749c28b8 100644 --- a/private/corona_p.h +++ b/private/corona_p.h @@ -54,6 +54,7 @@ public: ImmutabilityType immutability; QString mimetype; QString configName; + QString defaultContainmentPlugin; KSharedConfigPtr config; QTimer configSyncTimer; QList containments;