restore ability to register contextual actions
This commit is contained in:
parent
5199d71e54
commit
d2efdc34ee
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user