MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / displayDialog

Method displayDialog

app/src/MQTT/PublisherScriptEditor.cpp:204–228  ·  view source on GitHub ↗

* @brief Opens the dialog pre-populated with existing script code. */

Source from the content-addressed store, hash-verified

202 * @brief Opens the dialog pre-populated with existing script code.
203 */
204void MQTT::PublisherScriptEditor::displayDialog(const QString& currentCode, int language)
205{
206 const int comboIdx = (language == SerialStudio::Lua) ? 1 : 0;
207 m_languageCombo->blockSignals(true);
208 m_languageCombo->setCurrentIndex(comboIdx);
209 m_languageCombo->blockSignals(false);
210
211 const int resolvedLanguage = (comboIdx == 1) ? SerialStudio::Lua : SerialStudio::JavaScript;
212 applyLanguage(resolvedLanguage);
213
214 if (currentCode.isEmpty())
215 m_editor->setPlainText(defaultPlaceholder(resolvedLanguage));
216 else
217 m_editor->setPlainText(currentCode);
218
219 const int tmplIdx = detectTemplate();
220 m_templateCombo->setCurrentIndex(tmplIdx >= 0 ? tmplIdx + 1 : 0);
221
222 m_testOutput->setText(QStringLiteral("--"));
223
224 showNormal();
225 raise();
226 activateWindow();
227 m_editor->setFocus();
228}
229
230/**
231 * @brief Returns the current editor text.

Callers

nothing calls this directly

Calls 3

raiseFunction · 0.85
setCurrentIndexMethod · 0.80
isEmptyMethod · 0.80

Tested by

no test coverage detected