4import QGroundControl.Controls
6import "PlanPanelLogic.js" as Logic
8/// Shows a list and an inspector for the selected list entry. When the height allows, the list sits above the inspector. On
9/// short screens the list and the inspector take turns filling the whole area.
11/// The list component exposes contentHeight and may emit itemActivated(). The inspector component may emit backRequested().
15 property Component listComponent
16 property Component inspectorComponent
17 property bool hasSelection: false
18 property string layoutModeOverride: "" ///< "split" or "drillIn" to bypass the height check
19 property real userListHeight: -1 ///< Set by dragging the divider, negative uses the height of the list content
21 readonly property string layoutMode: layoutModeOverride !== "" ? layoutModeOverride : Logic.layoutMode(height, ScreenTools.defaultFontPixelHeight)
22 readonly property bool inspectorVisible: hasSelection && (layoutMode === "split" || _inspectorOpen)
23 readonly property bool listVisible: layoutMode === "split" || !inspectorVisible
25 property bool _inspectorOpen: false
27 readonly property real _dividerHeight: Math.max(ScreenTools.defaultFontPixelHeight * 0.8, ScreenTools.isMobile ? ScreenTools.minTouchPixels * 0.5 : 0)
28 readonly property real _minListHeight: ScreenTools.defaultFontPixelHeight * 4
29 readonly property real _minInspectorHeight: ScreenTools.defaultFontPixelHeight * 8
30 readonly property real _splitListHeight: {
31 if (userListHeight >= 0) {
32 return Logic.clampedListHeight(userListHeight, height, _dividerHeight, _minListHeight, _minInspectorHeight)
34 const contentHeight = listLoader.item ? listLoader.item.contentHeight : 0
35 return Math.min(Math.max(contentHeight, ScreenTools.defaultFontPixelHeight * 6), height * 0.4)
38 function openInspector() {
42 function closeInspector() {
43 _inspectorOpen = false
46 onHasSelectionChanged: {
52 onLayoutModeChanged: {
53 if (layoutMode === "drillIn" && hasSelection && !mainWindow.allowViewSwitch(0, false)) {
60 QGCPalette { id: qgcPal }
62 // Extends under the divider so only the top corners show as rounded
64 objectName: "planPanel_listBackground"
66 height: listLoader.height + radius
67 radius: ScreenTools.defaultBorderRadius
68 color: qgcPal.windowCard
69 visible: root.layoutMode === "split" && root.inspectorVisible
75 objectName: "planPanel_listLoader"
79 height: root.layoutMode === "split" ? (root.inspectorVisible ? root._splitListHeight : root.height) : root.height
80 visible: root.listVisible
81 sourceComponent: root.listComponent
85 target: listLoader.item
86 ignoreUnknownSignals: true
88 function onItemActivated() {
96 objectName: "planPanel_listInspectorDivider"
97 y: root._splitListHeight
99 height: root._dividerHeight
100 color: qgcPal.windowCard
101 visible: root.layoutMode === "split" && root.inspectorVisible
104 anchors.top: parent.top
107 color: qgcPal.borderSubtle
111 anchors.centerIn: parent
112 width: ScreenTools.defaultFontPixelHeight * 2.5
113 height: Math.max(ScreenTools.defaultFontPixelHeight * 0.25, 3)
115 color: dragArea.pressed ? qgcPal.accent : qgcPal.textSecondary
121 property real startY: 0
122 property real startHeight: 0
125 cursorShape: Qt.SizeVerCursor
127 onPressed: (mouse) => {
128 startY = mapToItem(root, mouse.x, mouse.y).y
129 startHeight = root._splitListHeight
132 onPositionChanged: (mouse) => {
134 root.userListHeight = Logic.clampedListHeight(startHeight + mapToItem(root, mouse.x, mouse.y).y - startY,
135 root.height, root._dividerHeight, root._minListHeight, root._minInspectorHeight)
139 onDoubleClicked: root.userListHeight = -1
146 objectName: "planPanel_inspectorLoader"
148 y: root.layoutMode === "split" ? root._splitListHeight + root._dividerHeight : 0
150 height: root.height - y
151 visible: root.inspectorVisible
152 sourceComponent: root.inspectorComponent
156 target: inspectorLoader.item
157 ignoreUnknownSignals: true
159 function onBackRequested() {
160 if (mainWindow.allowViewSwitch()) {
161 root.closeInspector()