* @brief Opens the dialog pre-populated with existing script code. */
| 202 | * @brief Opens the dialog pre-populated with existing script code. |
| 203 | */ |
| 204 | void 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. |
nothing calls this directly
no test coverage detected