5import QGroundControl.Controls
10 implicitWidth: _contentLayout.implicitWidth + (_margins * 2)
11 implicitHeight: _contentLayout.implicitHeight + (_margins * 2)
13 default property alias contentItem: _contentLayout.data
15 property alias contentSpacing: _contentLayout.spacing
17 property string defaultBorderColor : QGroundControl.globalPalette.groupBorder
18 property string outerBorderColor : defaultBorderColor
20 property string defaultHeadingPointSize: ScreenTools.defaultFontPointSize + 1
21 property string headingPointSize: defaultHeadingPointSize
23 property string heading
24 property string headingDescription
25 property bool showDividers: true
26 property bool showBorder: true
28 property real _margins: ScreenTools.defaultFontPixelHeight / 2
30 // We work with a y sorted list of children for divider visibility checks
31 property var _ySortedChildren: {
33 for (let c of _contentLayout.children)
35 arr.sort((a, b) => a.y - b.y)
40 Layout.leftMargin: _margins
41 Layout.fillWidth: true
43 visible: heading !== ""
47 font.pointSize: headingPointSize
52 Layout.fillWidth: true
53 text: headingDescription
54 wrapMode: Text.WordWrap
55 font.pointSize: ScreenTools.smallFontPointSize
56 visible: headingDescription !== ""
62 Layout.fillWidth: true
63 implicitWidth: _contentLayout.implicitWidth + (showBorder ? _margins * 2 : 0)
64 implicitHeight: _contentLayout.implicitHeight + (showBorder ? _margins * 2: 0)
66 border.color: outerBorderColor
67 border.width: showBorder ? 1 : 0
68 radius: ScreenTools.defaultFontPixelHeight / 2
71 model: showDividers ? _ySortedChildren.length : 0
74 x: showBorder ? _margins : 0
75 y: _contentItem ? (_contentItem.y + _contentItem.height + _margins + (showBorder ? _margins : 0)) : 0
76 width: parent.width - (showBorder ? _margins * 2 : 0)
78 color: QGroundControl.globalPalette.groupBorder
79 visible: _contentItem ? _isContentItemVisible() : false
81 property var _contentItem: index < _ySortedChildren.length ? _ySortedChildren[index] : undefined
83 function _isRepeater(item) {
84 return item && item.toString().startsWith("QQuickRepeater");
87 function _isContentItemVisible() {
88 if (!_contentItem || !_contentItem.visible || _isRepeater(_contentItem)) {
91 // Any children after this one visually from top to bottom must be visible to show divider
92 for (let i = index + 1; i < _ySortedChildren.length; ++i) {
93 if (!_ySortedChildren[i] || _isRepeater(_ySortedChildren[i])) {
96 if (_ySortedChildren[i].visible) {
107 x: showBorder ? _margins : 0
108 y: showBorder ? _margins : 0
109 width: parent.width - (showBorder ? _margins * 2 : 0)
110 spacing: _margins * (showDividers ? 2 : 1)