get rid of ContainmentActions::isInitialized()

This commit is contained in:
Aaron Seigo 2012-11-09 18:55:03 +01:00
parent 95cca61920
commit 6662b81c58
5 changed files with 17 additions and 31 deletions

View File

@ -896,19 +896,15 @@ void Containment::setContainmentActions(const QString &trigger, const QString &p
if (plugin->pluginName() != pluginName) {
d->actionPlugins()->remove(trigger);
delete plugin;
plugin=0;
plugin = 0;
}
}
if (pluginName.isEmpty()) {
cfg.deleteEntry(trigger);
} else if (plugin) {
//it already existed, just reload config
if (plugin->isInitialized()) {
plugin->setContainment(this); //to be safe
//FIXME make a truly unique config group
KConfigGroup pluginConfig = KConfigGroup(&cfg, trigger);
plugin->restore(pluginConfig);
}
// it already existed, reset the containment so it wil reload config on next show
plugin->setContainment(0);
} else {
switch (d->containmentActionsSource) {
case ContainmentPrivate::Activity:
@ -919,6 +915,7 @@ void Containment::setContainmentActions(const QString &trigger, const QString &p
default:
plugin = PluginLoader::self()->loadContainmentActions(0, pluginName);
}
if (plugin) {
cfg.writeEntry(trigger, pluginName);
d->actionPlugins()->insert(trigger, plugin);

View File

@ -102,15 +102,9 @@ QString ContainmentActions::pluginName() const
return d->containmentActionsDescription.pluginName();
}
bool ContainmentActions::isInitialized() const
{
return d->initialized;
}
void ContainmentActions::restore(const KConfigGroup &config)
{
init(config);
d->initialized = true;
}
void ContainmentActions::init(const KConfigGroup &config)

View File

@ -85,11 +85,6 @@ class PLASMA_EXPORT ContainmentActions : public QObject
**/
QString icon() const;
/**
* @return true if initialized (usually by calling restore), false otherwise
*/
bool isInitialized() const;
/**
* This method should be called once the plugin is loaded or settings are changed.
* @param config Config group to load settings
@ -167,6 +162,11 @@ class PLASMA_EXPORT ContainmentActions : public QObject
*/
void setContainment(Containment *newContainment);
/**
* @return the containment the plugin is associated with.
*/
Containment *containment();
Q_SIGNALS:
/**
* Emitted when @see configurationRequired() changes
@ -200,11 +200,6 @@ class PLASMA_EXPORT ContainmentActions : public QObject
*/
void setConfigurationRequired(bool needsConfiguring = true);
/**
* @return the containment the plugin is associated with.
*/
Containment *containment();
private:
friend class ContainmentActionsPackage;
friend class ContainmentActionsPrivate;

View File

@ -859,9 +859,11 @@ bool ContainmentPrivate::prepareContainmentActions(const QString &trigger, const
if (!plugin) {
return false;
}
plugin->setContainment(q);
if (!plugin->isInitialized()) {
if (plugin->containment() != q) {
plugin->setContainment(q);
// now configure it
KConfigGroup cfg = q->containmentActionsConfig();
KConfigGroup pluginConfig = KConfigGroup(&cfg, trigger);
plugin->restore(pluginConfig);

View File

@ -32,9 +32,8 @@ public:
q(containmentActions),
containmentActionsDescription(service),
package(0),
initialized(false),
needsConfig(false),
containment(0)
containment(0),
needsConfig(false)
{
};
@ -42,9 +41,8 @@ public:
KPluginInfo containmentActionsDescription;
Package *package;
KServiceAction mode;
bool initialized : 1;
bool needsConfig : 1;
Containment *containment;
bool needsConfig;
};
} // namespace Plasma