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

Method setupContentContainer

app/src/Platform/CSD.cpp:1157–1202  ·  view source on GitHub ↗

* @brief Creates the opaque content-background container holding the reparented QML content. */

Source from the content-addressed store, hash-verified

1155 * @brief Creates the opaque content-background container holding the reparented QML content.
1156 */
1157void Window::setupContentContainer()
1158{
1159 auto* quickWindow = qobject_cast<QQuickWindow*>(m_window.data());
1160 if (!quickWindow)
1161 return;
1162
1163 QQuickItem* root = quickWindow->contentItem();
1164 QQmlEngine* engine = qmlEngine(quickWindow);
1165 if (!engine)
1166 return;
1167
1168 static const char* qmlCode = R"(
1169 import QtQuick
1170
1171 Rectangle {
1172 id: contentContainer
1173 color: "transparent"
1174 }
1175 )";
1176
1177 QQmlComponent component(engine);
1178 component.setData(qmlCode, QUrl());
1179
1180 if (component.isError()) {
1181 for (const auto& error : component.errors())
1182 qWarning() << "CSD QML error:" << error.toString();
1183
1184 return;
1185 }
1186
1187 m_contentContainer = qobject_cast<QQuickItem*>(component.create());
1188 if (!m_contentContainer)
1189 return;
1190
1191 m_contentContainer->setParentItem(root);
1192 m_contentContainer->setZ(0);
1193
1194 connect(quickWindow, &QQuickWindow::widthChanged, this, &Window::updateContentContainerGeometry);
1195 connect(quickWindow, &QQuickWindow::heightChanged, this, &Window::updateContentContainerGeometry);
1196
1197 updateContentContainerGeometry();
1198
1199 const auto children = root->childItems();
1200 for (QQuickItem* child : children)
1201 reparentChildToContainer(child);
1202}
1203
1204/**
1205 * @brief Updates the title bar position and size.

Callers

nothing calls this directly

Calls 4

isErrorMethod · 0.80
QUrlClass · 0.50
dataMethod · 0.45
createMethod · 0.45

Tested by

no test coverage detected