remove ContainmentActions::ContainmentActionsSource

all containmentactions are global separed by containment type
This commit is contained in:
Marco Martin 2013-02-25 16:53:58 +01:00
parent 9e8f112be0
commit e00f0b10bb
6 changed files with 10 additions and 111 deletions

View File

@ -175,37 +175,9 @@ void Containment::restore(KConfigGroup &group)
setWallpaper(group.readEntry("wallpaperplugin", ContainmentPrivate::defaultWallpaper));
KConfigGroup cfg;
if (containmentType() == PanelContainment || containmentType() == CustomPanelContainment) {
//don't let global desktop actions conflict with panels
//this also prevents panels from sharing config with each other
//but the panels aren't configurable anyways, and I doubt that'll change.
d->containmentActionsSource = ContainmentActions::Local;
cfg = KConfigGroup(&group, "ActionPlugins");
} else {
const QString source = group.readEntry("ActionPluginsSource", QString());
if (source == "Global") {
cfg = KConfigGroup(corona()->config(), "ActionPlugins");
d->containmentActionsSource = ContainmentActions::Global;
} else if (source == "Activity") {
cfg = KConfigGroup(corona()->config(), "Activities");
cfg = KConfigGroup(&cfg, d->activityId);
cfg = KConfigGroup(&cfg, "ActionPlugins");
d->containmentActionsSource = ContainmentActions::Activity;
} else if (source == "Local") {
cfg = group;
d->containmentActionsSource = ContainmentActions::Local;
} else {
//default to global
//but, if there is no global config, try copying it from local.
cfg = KConfigGroup(corona()->config(), "ActionPlugins");
if (!cfg.exists()) {
cfg = KConfigGroup(&group, "ActionPlugins");
}
d->containmentActionsSource = ContainmentActions::Global;
group.writeEntry("ActionPluginsSource", "Global");
}
}
KConfigGroup cfg = KConfigGroup(corona()->config(), "ActionPlugins");
cfg = KConfigGroup(&cfg, QString::number(containmentType()));
//kDebug() << cfg.keyList();
if (cfg.exists()) {
@ -497,19 +469,10 @@ void Containment::addContainmentActions(const QString &trigger, const QString &p
// it already existed, reset the containment so it wil reload config on next show
plugin->setContainment(0);
} else {
switch (d->containmentActionsSource) {
case ContainmentActions::Activity:
//FIXME
case ContainmentActions::Local:
plugin = PluginLoader::self()->loadContainmentActions(this, pluginName);
break;
default:
plugin = PluginLoader::self()->loadContainmentActions(0, pluginName);
}
plugin = PluginLoader::self()->loadContainmentActions(this, pluginName);
if (plugin) {
cfg.writeEntry(trigger, pluginName);
plugin->setSource(d->containmentActionsSource);
containmentActions().insert(trigger, plugin);
} else {
//bad plugin... gets removed. is this a feature or a bug?

View File

@ -79,16 +79,6 @@ Containment *ContainmentActions::containment()
return qobject_cast<Containment*>(parent());
}
void ContainmentActions::setSource(ContainmentActionsSource source)
{
d->containmentActionsSource = source;
}
ContainmentActions::ContainmentActionsSource ContainmentActions::source() const
{
return d->containmentActionsSource;
}
KConfigGroup ContainmentActions::config() const
{
KConfigGroup cfg;
@ -96,20 +86,8 @@ KConfigGroup ContainmentActions::config() const
return cfg;
}
switch (d->containmentActionsSource) {
case Local:
cfg = d->containment->config();
cfg = KConfigGroup(&cfg, "ActionPlugins");
break;
case Activity:
cfg = KConfigGroup(d->containment->corona()->config(), "Activities");
cfg = KConfigGroup(&cfg, d->containment->activity());
cfg = KConfigGroup(&cfg, "ActionPlugins");
break;
default:
cfg = KConfigGroup(d->containment->corona()->config(), "ActionPlugins");
}
return cfg;
cfg = KConfigGroup(d->containment->corona()->config(), "ActionPlugins");
return KConfigGroup(&cfg, QString::number(d->containment->containmentType()));
}
void ContainmentActions::restore(const KConfigGroup &config)

View File

@ -56,18 +56,6 @@ class PLASMA_EXPORT ContainmentActions : public QObject
Q_OBJECT
public:
/**
* Where the actions come from.
* Containments can use a global set of actions or a personalized set,
* with granularity to Activity or Containment
*/
enum ContainmentActionsSource {
Global = 0,
Activity,
Local
};
Q_ENUMS(ContainmentActionsSource)
/**
* Default constructor for an empty or null containmentactions
*/
@ -88,19 +76,6 @@ class PLASMA_EXPORT ContainmentActions : public QObject
*/
KConfigGroup config() const;
/**
* Sets the source, for this containmentactions Global, Activity or Local
* @param source @see ContainmentActionsSource
* @since 5.0
*/
void setSource(ContainmentActionsSource source);
/**
* @return the source of this containmentactions
* @since 5.0
*/
ContainmentActionsSource source() const;
/**
* This method should be called once the plugin is loaded or settings are changed.
* @param config Config group to load settings

View File

@ -150,21 +150,8 @@ void ContainmentPrivate::setScreen(int newScreen)
KConfigGroup ContainmentPrivate::containmentActionsConfig() const
{
KConfigGroup cfg;
switch (containmentActionsSource) {
case ContainmentActions::Local:
cfg = q->config();
cfg = KConfigGroup(&cfg, "ActionPlugins");
break;
case ContainmentActions::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;
KConfigGroup cfg = KConfigGroup(q->corona()->config(), "ActionPlugins");
return KConfigGroup(&cfg, QString::number(type));
}
void ContainmentPrivate::configChanged()

View File

@ -51,8 +51,7 @@ public:
location(Floating),
screen(-1), // no screen
type(Plasma::NoContainmentType),
drawWallpaper(false),
containmentActionsSource(ContainmentActions::Global)
drawWallpaper(false)
{
}
@ -107,7 +106,6 @@ public:
ContainmentType type;
bool drawWallpaper : 1;
ContainmentActions::ContainmentActionsSource containmentActionsSource;
static const char defaultWallpaper[];
};

View File

@ -31,14 +31,12 @@ public:
q(containmentActions),
containmentActionsDescription(service),
package(0),
containment(0),
containmentActionsSource(ContainmentActions::Global)
containment(0)
{
};
ContainmentActions *q;
ContainmentActions::ContainmentActionsSource containmentActionsSource;
QString currentTrigger;
KPluginInfo containmentActionsDescription;
Package *package;