| 454 | } |
| 455 | |
| 456 | QObject *QuickUI::loadComponent(QAnyStringView uri, QAnyStringView typeName, const QVariantMap &initialProperties) |
| 457 | { |
| 458 | auto component = QQmlComponent(m_engine, uri, typeName, m_engine); |
| 459 | auto *const object = component.createWithInitialProperties(initialProperties); |
| 460 | if (object) { |
| 461 | // ensure the JavaScript engine deletes the object if we don't assign a parent in C++ |
| 462 | m_engine->setObjectOwnership(object, QJSEngine::JavaScriptOwnership); |
| 463 | } else { |
| 464 | const auto message = QStringLiteral("Unable to load component \"%1\" of Qt Quick UI: %2").arg(typeName, component.errorString()); |
| 465 | #ifdef SYNCTHINGWIDGETS_GUI_QTQUICK_MODE_DESKTOP |
| 466 | QMessageBox::critical(nullptr, QCoreApplication::applicationName(), message); |
| 467 | #else |
| 468 | qWarning() << message; |
| 469 | #endif |
| 470 | } |
| 471 | return object; |
| 472 | } |
| 473 | |
| 474 | #ifdef SYNCTHINGWIDGETS_GUI_QTQUICK_MODE_DESKTOP |
| 475 | template <typename ReturnArg, typename... Args> |
nothing calls this directly
no test coverage detected