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

Method setupBorder

app/src/Platform/CSD.cpp:999–1042  ·  view source on GitHub ↗

* @brief Creates the 1px window border as four scene-graph edges (no painter, no FBO). */

Source from the content-addressed store, hash-verified

997 * @brief Creates the 1px window border as four scene-graph edges (no painter, no FBO).
998 */
999void Window::setupBorder()
1000{
1001 auto* quickWindow = qobject_cast<QQuickWindow*>(m_window.data());
1002 if (!quickWindow)
1003 return;
1004
1005 QQmlEngine* engine = qmlEngine(quickWindow);
1006 if (!engine)
1007 return;
1008
1009 static const char* qmlCode = R"(
1010 import QtQuick
1011
1012 Item {
1013 id: border
1014 readonly property color stroke: "#73666666"
1015 Rectangle { color: border.stroke; height: 1; anchors { left: parent.left; right: parent.right; top: parent.top } }
1016 Rectangle { color: border.stroke; height: 1; anchors { left: parent.left; right: parent.right; bottom: parent.bottom } }
1017 Rectangle { color: border.stroke; width: 1; anchors { top: parent.top; bottom: parent.bottom; left: parent.left } }
1018 Rectangle { color: border.stroke; width: 1; anchors { top: parent.top; bottom: parent.bottom; right: parent.right } }
1019 }
1020 )";
1021
1022 QQmlComponent component(engine);
1023 component.setData(qmlCode, QUrl());
1024 if (component.isError()) {
1025 for (const auto& error : component.errors())
1026 qWarning() << "CSD border QML error:" << error.toString();
1027
1028 return;
1029 }
1030
1031 m_border = qobject_cast<QQuickItem*>(component.create());
1032 if (!m_border)
1033 return;
1034
1035 m_border->setParentItem(quickWindow->contentItem());
1036 m_border->setZ(1000000);
1037
1038 connect(quickWindow, &QQuickWindow::widthChanged, this, &Window::updateBorderGeometry);
1039 connect(quickWindow, &QQuickWindow::heightChanged, this, &Window::updateBorderGeometry);
1040
1041 updateBorderGeometry();
1042}
1043
1044/**
1045 * @brief Creates and configures the title bar.

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