From 206c5cfb5ebd03006a2a94cf3c2ee6ff256fa4cf Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Mon, 18 Feb 2013 20:12:31 +0100 Subject: [PATCH] make containmentActionsConfig private it will eventually have to be removed but for now the config needs to exist before the containmentactions instance, therefore still has to be out of ContainmentActions --- src/plasma/containment.cpp | 45 ++++++++-------------------- src/plasma/containment.h | 20 +++---------- src/plasma/private/containment_p.cpp | 21 ++++++++++++- src/plasma/private/containment_p.h | 6 ++++ 4 files changed, 43 insertions(+), 49 deletions(-) diff --git a/src/plasma/containment.cpp b/src/plasma/containment.cpp index c745681dd..533ff60f7 100644 --- a/src/plasma/containment.cpp +++ b/src/plasma/containment.cpp @@ -250,7 +250,7 @@ void Containment::restore(KConfigGroup &group) if (cfg.exists()) { foreach (const QString &key, cfg.keyList()) { //kDebug() << "loading" << key; - setContainmentActions(key, cfg.readEntry(key, QString())); + addContainmentActions(key, cfg.readEntry(key, QString())); } } else { //shell defaults ContainmentActionsPluginsConfig conf = corona()->containmentActionsDefaults(d->type); @@ -258,7 +258,7 @@ void Containment::restore(KConfigGroup &group) QHash defaults = conf.d->plugins; for (QHash::const_iterator it = defaults.constBegin(), end = defaults.constEnd(); it != end; ++it) { - setContainmentActions(it.key(), it.value()); + addContainmentActions(it.key(), it.value()); } } @@ -622,9 +622,9 @@ QString Containment::wallpaper() const return d->wallpaper; } -void Containment::setContainmentActions(const QString &trigger, const QString &pluginName) +void Containment::addContainmentActions(const QString &trigger, const QString &pluginName) { - KConfigGroup cfg = containmentActionsConfig(); + KConfigGroup cfg = d->containmentActionsConfig(); ContainmentActions *plugin = 0; if (d->actionPlugins()->contains(trigger)) { @@ -664,15 +664,16 @@ void Containment::setContainmentActions(const QString &trigger, const QString &p emit configNeedsSaving(); } -QStringList Containment::containmentActionsTriggers() +QHash Containment::containmentActions() { - return d->actionPlugins()->keys(); -} - -QString Containment::containmentActions(const QString &trigger) -{ - ContainmentActions *c = d->actionPlugins()->value(trigger); - return c ? c->pluginName() : QString(); + switch (d->containmentActionsSource) { + case ContainmentPrivate::Activity: + //FIXME + case ContainmentPrivate::Local: + return d->localActionPlugins; + default: + return d->globalActionPlugins; + } } void Containment::setActivity(const QString &activityId) @@ -699,26 +700,6 @@ void Containment::showConfigurationInterface() Applet::showConfigurationInterface(); } -KConfigGroup Containment::containmentActionsConfig() -{ - KConfigGroup cfg; - switch (d->containmentActionsSource) { - case ContainmentPrivate::Local: - cfg = config(); - cfg = KConfigGroup(&cfg, "ActionPlugins"); - break; - case ContainmentPrivate::Activity: - cfg = KConfigGroup(corona()->config(), "Activities"); - cfg = KConfigGroup(&cfg, d->activityId); - cfg = KConfigGroup(&cfg, "ActionPlugins"); - break; - default: - cfg = KConfigGroup(corona()->config(), "ActionPlugins"); - } - return cfg; -} - - } // Plasma namespace diff --git a/src/plasma/containment.h b/src/plasma/containment.h index e62d91d91..0e2c2ca13 100644 --- a/src/plasma/containment.h +++ b/src/plasma/containment.h @@ -295,25 +295,13 @@ class PLASMA_EXPORT Containment : public Applet * @param pluginName the name of the plugin to attempt to load. blank = set no plugin. * @since 4.4 */ - void setContainmentActions(const QString &trigger, const QString &pluginName); + void addContainmentActions(const QString &trigger, const QString &pluginName); /** - * @return a list of all triggers that have a containmentactions plugin associated - * @since 4.4 + * @return All the loaded containment action plugins, indexed by trigger name + * @since 5.0 */ - QStringList containmentActionsTriggers(); - - /** - * @return the plugin name for the given trigger - * @since 4.4 - */ - QString containmentActions(const QString &trigger); - - /** - * @return the config group that containmentactions plugins go in - * @since 4.6 - */ - KConfigGroup containmentActionsConfig(); + QHash containmentActions(); Q_SIGNALS: diff --git a/src/plasma/private/containment_p.cpp b/src/plasma/private/containment_p.cpp index e27989060..efb310d8d 100644 --- a/src/plasma/private/containment_p.cpp +++ b/src/plasma/private/containment_p.cpp @@ -390,6 +390,25 @@ bool ContainmentPrivate::isPanelContainment() const return type == Containment::PanelContainment || type == Containment::CustomPanelContainment; } +KConfigGroup ContainmentPrivate::containmentActionsConfig() const +{ + KConfigGroup cfg; + switch (containmentActionsSource) { + case ContainmentPrivate::Local: + cfg = q->config(); + cfg = KConfigGroup(&cfg, "ActionPlugins"); + break; + case ContainmentPrivate::Activity: + cfg = KConfigGroup(q->corona()->config(), "Activities"); + cfg = KConfigGroup(&cfg, activityId); + cfg = KConfigGroup(&cfg, "ActionPlugins"); + break; + default: + cfg = KConfigGroup(q->corona()->config(), "ActionPlugins"); + } + return cfg; +} + bool ContainmentPrivate::prepareContainmentActions(const QString &trigger, const QPoint &screenPos, KMenu *menu) { ContainmentActions *plugin = actionPlugins()->value(trigger); @@ -401,7 +420,7 @@ bool ContainmentPrivate::prepareContainmentActions(const QString &trigger, const plugin->setContainment(q); // now configure it - KConfigGroup cfg = q->containmentActionsConfig(); + KConfigGroup cfg = containmentActionsConfig(); KConfigGroup pluginConfig = KConfigGroup(&cfg, trigger); plugin->restore(pluginConfig); } diff --git a/src/plasma/private/containment_p.h b/src/plasma/private/containment_p.h index 1c9cf48cf..442ab9159 100644 --- a/src/plasma/private/containment_p.h +++ b/src/plasma/private/containment_p.h @@ -98,6 +98,12 @@ public: */ static void addDefaultActions(KActionCollection *actions, Containment *c = 0); + /** + * @return the config group that containmentactions plugins go in + * @since 4.6 + */ + KConfigGroup containmentActionsConfig() const; + /** * inits the containmentactions if necessary * if it needs configuring, this warns the user and returns false