From ffc6ae289ec73ac0415649a395109b6205853a47 Mon Sep 17 00:00:00 2001 From: Chani Armitage Date: Tue, 11 May 2010 19:02:24 +0000 Subject: [PATCH] API change: instead of Containment having activityId functions, it just exposes the whole Context*. The activity functions have to be left in for BC, and they still work as they did before. svn path=/trunk/KDE/kdelibs/; revision=1125570 --- containment.cpp | 61 ++++++++++++++++++----------------------- containment.h | 18 ++---------- private/containment_p.h | 5 ++++ 3 files changed, 35 insertions(+), 49 deletions(-) diff --git a/containment.cpp b/containment.cpp index 6e44484b9..8e67feec4 100644 --- a/containment.cpp +++ b/containment.cpp @@ -359,7 +359,7 @@ void Containment::restore(KConfigGroup &group) setScreen(group.readEntry("screen", d->screen), group.readEntry("desktop", d->desktop)); QString activityId = group.readEntry("activityId", QString()); if (!activityId.isEmpty()) { - setActivityId(activityId); + d->context()->setCurrentActivityId(activityId); } setActivity(group.readEntry("activity", QString())); @@ -1971,39 +1971,34 @@ void Containment::setActivity(const QString &activity) Context *context = d->context(); if (context->currentActivity() != activity) { context->setCurrentActivity(activity); - - foreach (Applet *a, d->applets) { - a->updateConstraints(ContextConstraint); - } - - KConfigGroup c = config(); - c.writeEntry("activity", activity); - - if (d->toolBox) { - d->toolBox.data()->update(); - } - emit configNeedsSaving(); } } -void Containment::setActivityId(const QString &activity) +void ContainmentPrivate::onContextChanged(Plasma::Context *con) { - Context *context = d->context(); - if (context->currentActivityId() != activity) { - context->setCurrentActivityId(activity); - - foreach (Applet *a, d->applets) { - a->updateConstraints(ContextConstraint); - } - - KConfigGroup c = config(); - c.writeEntry("activityId", activity); - - if (d->toolBox) { - d->toolBox.data()->update(); - } - emit configNeedsSaving(); + foreach (Applet *a, applets) { + a->updateConstraints(ContextConstraint); } + + KConfigGroup c = q->config(); + QString act = con->currentActivityId(); + + //save anything that's been set (boy I hope this avoids overwriting things) + //FIXME of course if the user sets the name to an empty string we have a bug + //but once we get context retrieving the name as soon as the id is set, this issue should go away + if (!act.isEmpty()) { + c.writeEntry("activityId", act); + } + act = con->currentActivity(); + if (!act.isEmpty()) { + c.writeEntry("activity", act); + } + + if (toolBox) { + toolBox.data()->update(); + } + emit q->configNeedsSaving(); + emit q->contextChanged(con); } QString Containment::activity() const @@ -2011,9 +2006,9 @@ QString Containment::activity() const return d->context()->currentActivity(); } -QString Containment::activityId() const +Context *Containment::context() const { - return d->context()->currentActivityId(); + return d->context(); } Context *ContainmentPrivate::context() @@ -2021,9 +2016,7 @@ Context *ContainmentPrivate::context() if (!con) { con = new Context(q); q->connect(con, SIGNAL(changed(Plasma::Context*)), - q, SIGNAL(contextChanged(Plasma::Context*))); - q->connect(con, SIGNAL(activityChanged(Plasma::Context*)), - q, SIGNAL(activityNameChanged(Plasma::Context*))); + q, SLOT(onContextChanged(Plasma::Context*))); } return con; diff --git a/containment.h b/containment.h index 1b82d96b7..0b120d678 100644 --- a/containment.h +++ b/containment.h @@ -352,18 +352,10 @@ class PLASMA_EXPORT Containment : public Applet QString activity() const; /** - * Sets the current activity by id - * - * @param activity the id of the activity + * @return the context for this containment * @since 4.5 */ - void setActivityId(const QString &activity); - - /** - * @return the current activity id associated with this containment - * @since 4.5 - */ - QString activityId() const; + Context* context() const; /** * Shows the context menu for the containment directly, bypassing Applets @@ -464,11 +456,6 @@ class PLASMA_EXPORT Containment : public Applet * The context associated to this containment has changed */ void contextChanged(Plasma::Context *context); - /** - * The activity name for the context associated to this containment has changed - * @since 4.5 - */ - void activityNameChanged(Plasma::Context *context); public Q_SLOTS: /** @@ -632,6 +619,7 @@ class PLASMA_EXPORT Containment : public Applet Q_PRIVATE_SLOT(d, void showDropZoneDelayed()) Q_PRIVATE_SLOT(d, void checkStatus(Plasma::ItemStatus)) Q_PRIVATE_SLOT(d, void remoteAppletReady(Plasma::AccessAppletJob *)) + Q_PRIVATE_SLOT(d, void onContextChanged(Plasma::Context *con)) /** * This slot is called when the 'stat' after a job event has finished. */ diff --git a/private/containment_p.h b/private/containment_p.h index 5dffe848c..32913ad9e 100644 --- a/private/containment_p.h +++ b/private/containment_p.h @@ -120,6 +120,11 @@ public: */ Context *context(); + /** + * propogates context changes + */ + void onContextChanged(Plasma::Context *con); + /** * Handles dropped/pasted mimetype data * @param scenePos scene-relative position