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

Method runScript

src/TWScriptableWindow.cpp:127–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

125}
126
127void
128TWScriptableWindow::runScript(QObject* scriptObj, Tw::Scripting::Script::ScriptType scriptType)
129{
130 QVariant result;
131
132 TWScriptManager * sm = TWApp::instance()->getScriptManager();
133 if (!sm)
134 return;
135
136 Tw::Scripting::ScriptObject * so = qobject_cast<Tw::Scripting::ScriptObject*>(scriptObj);
137 if (!so) {
138 return;
139 }
140 Tw::Scripting::Script * s = so->getScript();
141 if (!s || s->getType() != scriptType)
142 return;
143
144 bool success = sm->runScript(scriptObj, this, result, scriptType);
145
146 if (success) {
147 if (!result.isNull() && !result.toString().isEmpty()) {
148 if (scriptType == Tw::Scripting::Script::ScriptHook)
149 statusBar()->showMessage(tr("Script \"%1\": %2").arg(s->getTitle(), result.toString()), kStatusMessageDuration);
150 else
151 QMessageBox::information(this, tr("Script result"), result.toString(), QMessageBox::Ok, QMessageBox::Ok);
152 }
153 }
154 else {
155 if (result.isNull())
156 result = tr("unknown error");
157 QMessageBox::information(this, tr("Script error"), tr("Script \"%1\": %2").arg(s->getTitle(), result.toString()), QMessageBox::Ok, QMessageBox::Ok);
158 }
159}
160
161void
162TWScriptableWindow::runHooks(const QString& hookName)

Callers

nothing calls this directly

Calls 5

getScriptManagerMethod · 0.80
getScriptMethod · 0.80
isNullMethod · 0.80
getTitleMethod · 0.80
getTypeMethod · 0.45

Tested by

no test coverage detected