MCPcopy Create free account
hub / github.com/TeXworks/texworks / runScript

Method runScript

src/TWScriptManager.cpp:386–409  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

384}
385
386bool
387TWScriptManager::runScript(QObject* script, QObject * context, QVariant & result, Tw::Scripting::Script::ScriptType scriptType)
388{
389 Tw::Settings settings;
390
391 Tw::Scripting::ScriptObject * so = qobject_cast<Tw::Scripting::ScriptObject*>(script);
392 if (!so || so->getType() != scriptType)
393 return false;
394
395 const bool needsPlugin = (
396#if WITH_QTSCRIPT
397 qobject_cast<const Tw::Scripting::JSScriptInterface*>(so->getScriptLanguagePlugin()) == nullptr &&
398#endif
399 qobject_cast<const Tw::Scripting::ECMAScriptInterface*>(so->getScriptLanguagePlugin()) == nullptr
400 );
401 if (needsPlugin && !settings.value(QString::fromLatin1("enableScriptingPlugins"), false).toBool())
402 return false;
403
404 if (!so->isEnabled())
405 return false;
406
407 Tw::Scripting::ScriptAPI api(so, qApp, context, result);
408 return so->run(api);
409}
410
411void
412TWScriptManager::runHooks(const QString& hookName, QObject * context /* = nullptr */)

Callers

nothing calls this directly

Calls 5

getTypeMethod · 0.45
valueMethod · 0.45
isEnabledMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected