MCPcopy Create free account
hub / github.com/Martchus/syncthingtray / loadComponent

Method loadComponent

syncthingwidgets/quick/quickui.cpp:456–472  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

454}
455
456QObject *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
475template <typename ReturnArg, typename... Args>

Callers

nothing calls this directly

Calls 1

errorStringMethod · 0.80

Tested by

no test coverage detected