restore ability to register contextual actions

This commit is contained in:
Marco Martin 2011-06-09 14:31:03 +02:00
parent 5199d71e54
commit d2efdc34ee
2 changed files with 23 additions and 2 deletions

View File

@ -274,6 +274,18 @@ QGraphicsWidget *DeclarativeAppletScript::extractParent(QScriptContext *context,
return parent;
}
void DeclarativeAppletScript::callPlasmoidFunction(const QString &functionName, const QScriptValueList &args, ScriptEnv *env)
{
if (!m_env) {
m_env = ScriptEnv::findScriptEnv(m_engine);
}
if (env) {
QScriptValue func = m_self.property(functionName);
m_env->callFunction(func, args, m_self);
}
}
void DeclarativeAppletScript::constraintsEvent(Plasma::Constraints constraints)
{
if (constraints & Plasma::FormFactorConstraint) {
@ -343,7 +355,9 @@ void DeclarativeAppletScript::executeAction(const QString &name)
}
const QString func("action_" + name);
m_env->callEventListeners(func);
if (!m_env->callEventListeners(func)) {
callPlasmoidFunction(func, QScriptValueList(), m_env);
}
}
bool DeclarativeAppletScript::include(const QString &path)
@ -471,6 +485,11 @@ QScriptValue DeclarativeAppletScript::loadService(QScriptContext *context, QScri
return engine->newQObject(service, QScriptEngine::AutoOwnership);
}
QList<QAction*> DeclarativeAppletScript::contextualActions()
{
return m_interface->contextualActions();
}
QScriptEngine *DeclarativeAppletScript::engine() const
{
return m_engine;

View File

@ -49,7 +49,7 @@ public:
QString filePath(const QString &type, const QString &file) const;
void executeAction(const QString &name);
QList<QAction*> contextualActions();
void constraintsEvent(Plasma::Constraints constraints);
@ -70,6 +70,7 @@ public:
static QScriptValue loadService(QScriptContext *context, QScriptEngine *engine);
public Q_SLOTS:
void executeAction(const QString &name);
void dataUpdated(const QString &name, const Plasma::DataEngine::Data &data);
void signalHandlerException(const QScriptValue &exception);
void popupEvent(bool popped);
@ -92,6 +93,7 @@ Q_SIGNALS:
void contextChanged();
private:
void callPlasmoidFunction(const QString &functionName, const QScriptValueList &args, ScriptEnv *env);
Plasma::DeclarativeWidget *m_declarativeWidget;
AppletInterface *m_interface;
EngineAccess *m_engineAccess;