* @brief Invokes a pointer-event JS callback under the watchdog and repaints on success. */
| 461 | * @brief Invokes a pointer-event JS callback under the watchdog and repaints on success. |
| 462 | */ |
| 463 | void Widgets::Painter::dispatchPointer(QJSValue& fn, const QJSValueList& args) |
| 464 | { |
| 465 | if (!m_runtimeOk || !fn.isCallable()) |
| 466 | return; |
| 467 | |
| 468 | if (!m_previewMode) { |
| 469 | const auto* dashboard = &UI::Dashboard::instance(); |
| 470 | if (m_index < 0 || m_index >= dashboard->widgetCount(SerialStudio::DashboardPainter)) { |
| 471 | m_bridge->setGroup(nullptr); |
| 472 | return; |
| 473 | } |
| 474 | |
| 475 | m_bridge->setGroup(&dashboard->getGroupWidget(SerialStudio::DashboardPainter, m_index)); |
| 476 | } |
| 477 | |
| 478 | auto r = m_watchdog.call(fn, args); |
| 479 | if (r.isError()) [[unlikely]] { |
| 480 | setLastError(QStringLiteral("input: ") + r.property(QStringLiteral("message")).toString()); |
| 481 | setRuntimeOk(false); |
| 482 | return; |
| 483 | } |
| 484 | |
| 485 | renderFrame(); |
| 486 | update(); |
| 487 | } |
| 488 | |
| 489 | //-------------------------------------------------------------------------------------------------- |
| 490 | // Pointer input -> JS callbacks |
nothing calls this directly
no test coverage detected