API changes needed for configurable contextmenu.
-setContainment, so that we don't have to try and use the parent any more. -hasConfigurationInterface; this should've already been there. -default values for a couple of functions that I think make sense svn path=/trunk/KDE/kdelibs/; revision=1012644
This commit is contained in:
parent
69365ddada
commit
5070e300f5
@ -257,6 +257,7 @@ void Containment::init()
|
||||
if (action) {
|
||||
d->contextActions.insert(trigger, action);
|
||||
action->setParent(this);
|
||||
action->setContainment(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1692,25 +1693,23 @@ void Containment::setContextAction(const QString &trigger, const QString &plugin
|
||||
}
|
||||
if (pluginName.isEmpty()) {
|
||||
cfg.deleteEntry(trigger);
|
||||
} else {
|
||||
if (!action) {
|
||||
action = ContextAction::load(pluginName);
|
||||
if (action) {
|
||||
cfg.writeEntry(trigger, pluginName);
|
||||
d->contextActions.insert(trigger, action);
|
||||
} else {
|
||||
//bad plugin... gets removed. is this a feature or a bug?
|
||||
cfg.deleteEntry(trigger);
|
||||
}
|
||||
} else if (action) {
|
||||
//it already existed, just reload config
|
||||
if (action->isInitialized()) {
|
||||
//FIXME make a truly unique config group
|
||||
KConfigGroup actionConfig = KConfigGroup(&cfg, pluginName);
|
||||
action->restore(actionConfig);
|
||||
}
|
||||
|
||||
} else {
|
||||
action = ContextAction::load(pluginName);
|
||||
if (action) {
|
||||
if (action->isInitialized()) {
|
||||
//FIXME make a truly unique config group
|
||||
KConfigGroup actionConfig = KConfigGroup(&cfg, pluginName);
|
||||
action->restore(actionConfig);
|
||||
}
|
||||
cfg.writeEntry(trigger, pluginName);
|
||||
d->contextActions.insert(trigger, action);
|
||||
action->setParent(this);
|
||||
action->setContainment(this);
|
||||
} else {
|
||||
//bad plugin... gets removed. is this a feature or a bug?
|
||||
cfg.deleteEntry(trigger);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -127,9 +127,14 @@ PackageStructure::Ptr ContextAction::packageStructure()
|
||||
return ContextActionPrivate::s_packageStructure;
|
||||
}
|
||||
|
||||
void ContextAction::setContainment(Containment *c)
|
||||
{
|
||||
d->containment=c;
|
||||
}
|
||||
|
||||
Containment *ContextAction::containment()
|
||||
{
|
||||
return qobject_cast<Plasma::Containment*>(parent());
|
||||
return d->containment;
|
||||
}
|
||||
|
||||
QString ContextAction::name() const
|
||||
@ -213,6 +218,16 @@ void ContextAction::setConfigurationRequired(bool needsConfig)
|
||||
d->needsConfig = needsConfig;
|
||||
}
|
||||
|
||||
bool ContextAction::hasConfigurationInterface() const
|
||||
{
|
||||
return d->hasConfig;
|
||||
}
|
||||
|
||||
void ContextAction::setHasConfigurationInterface(bool hasConfig)
|
||||
{
|
||||
d->hasConfig = hasConfig;
|
||||
}
|
||||
|
||||
QString ContextAction::eventToString(QEvent *event)
|
||||
{
|
||||
QString trigger;
|
||||
|
@ -178,6 +178,18 @@ class PLASMA_EXPORT ContextAction : public QObject
|
||||
*/
|
||||
bool configurationRequired() const;
|
||||
|
||||
/**
|
||||
* @return true if the contextaction has a config UI
|
||||
*/
|
||||
bool hasConfigurationInterface() const;
|
||||
|
||||
/**
|
||||
* set the containment this contextaction is associated with.
|
||||
* some plugins may need information from the containment in order to function or be
|
||||
* configured.
|
||||
*/
|
||||
void setContainment(Containment *c);
|
||||
|
||||
/**
|
||||
* Turns a mouse or wheel event into a string suitable for a ContextAction
|
||||
* @return the string representation of the event
|
||||
@ -211,10 +223,15 @@ class PLASMA_EXPORT ContextAction : public QObject
|
||||
* @param needsConfiguring true if the applet needs to be configured,
|
||||
* or false if it doesn't
|
||||
*/
|
||||
void setConfigurationRequired(bool needsConfiguring);
|
||||
void setConfigurationRequired(bool needsConfiguring = true);
|
||||
|
||||
/**
|
||||
* return the containment the plugin is associated with, if any.
|
||||
* set whether the contextaction has a config UI
|
||||
*/
|
||||
void setHasConfigurationInterface(bool hasConfig = true);
|
||||
|
||||
/**
|
||||
* @return the containment the plugin is associated with, if any.
|
||||
*/
|
||||
Containment *containment();
|
||||
|
||||
|
@ -31,20 +31,24 @@ class ContextActionPrivate : public DataEngineConsumer
|
||||
public:
|
||||
ContextActionPrivate(KService::Ptr service, ContextAction *contextAction) :
|
||||
q(contextAction),
|
||||
containment(0),
|
||||
contextActionDescription(service),
|
||||
initialized(false),
|
||||
needsConfig(false)
|
||||
needsConfig(false),
|
||||
hasConfig(false)
|
||||
{
|
||||
};
|
||||
|
||||
static PackageStructure::Ptr s_packageStructure;
|
||||
|
||||
ContextAction *q;
|
||||
Containment *containment;
|
||||
KPluginInfo contextActionDescription;
|
||||
Package *package;
|
||||
KServiceAction mode;
|
||||
bool initialized : 1;
|
||||
bool needsConfig : 1;
|
||||
bool hasConfig : 1;
|
||||
};
|
||||
|
||||
} // namespace Plasma
|
||||
|
Loading…
Reference in New Issue
Block a user