QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
PlanViewRightPanel.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Controls
3import QtQuick.Layouts
4
5import QGroundControl
6import QGroundControl.Controls
7
8Item {
9 required property var editorMap
10 required property var planMasterController
11
12 signal editingLayerChangeRequested(int layer)
13
14 id: root
15
16 property var _missionController: planMasterController.missionController
17 property real _toolsMargin: ScreenTools.defaultFontPixelWidth * 0.75
18
19 property bool useNewPlanPanel: QGroundControl.settingsManager.planViewSettings.useNewPlanPanel.rawValue
20
21 readonly property bool _useNewPlanPanel: useNewPlanPanel
22
23 function selectNextNotReady() {
24 for (var i = 0; i < _missionController.visualItems.count; i++) {
25 var vmi = _missionController.visualItems.get(i)
26 if (vmi.readyForSaveState === VisualMissionItem.NotReadyForSaveData) {
27 _missionController.setCurrentPlanViewSeqNum(vmi.sequenceNumber, true)
28 break
29 }
30 }
31 }
32
33 QGCPalette { id: qgcPal }
34
35 Rectangle {
36 id: rightPanelBackground
37 anchors.fill: parent
38 color: qgcPal.window
39 opacity: 0.85
40 visible: !root._useNewPlanPanel
41 }
42
43
44 // Open/Close panel
45 Item {
46 id: panelOpenCloseButton
47 anchors.right: parent.left
48 anchors.verticalCenter: parent.verticalCenter
49 // The tabbed panel has its tab pills at the top of this edge so the button moves to the bottom
50 anchors.verticalCenterOffset: root._useNewPlanPanel ? parent.height / 2 - height / 2 - _toolsMargin : 0
51 width: toggleButtonRect.width - toggleButtonRect.radius * (root._useNewPlanPanel ? 2 : 1)
52 height: toggleButtonRect.height
53 clip: true
54
55 property bool _expanded: root.anchors.right == root.parent.right
56
57 Rectangle {
58 id: toggleButtonRect
59 // The tabbed panel styles the button like its tab pills, with the inner side tucked under the panel
60 width: root._useNewPlanPanel ? ScreenTools.defaultFontPixelHeight * 2.2 : ScreenTools.defaultFontPixelWidth * 2.25
61 height: root._useNewPlanPanel ? ScreenTools.defaultFontPixelHeight * 2.2 : width * 3
62 radius: ScreenTools.defaultBorderRadius
63 color: root._useNewPlanPanel ? qgcPal.windowPanel : rightPanelBackground.color
64 opacity: root._useNewPlanPanel ? 1 : rightPanelBackground.opacity
65 border.width: root._useNewPlanPanel ? 1 : 0
66 border.color: qgcPal.borderSubtle
67
68 QGCLabel {
69 id: toggleButtonLabel
70 anchors.centerIn: parent
71 anchors.horizontalCenterOffset: root._useNewPlanPanel ? -toggleButtonRect.radius : 0
72 text: panelOpenCloseButton._expanded ? ">" : "<"
73 color: qgcPal.textPrimary
74 }
75
76 }
77
78 QGCMouseArea {
79 anchors.fill: parent
80
81 onClicked: {
82 if (panelOpenCloseButton._expanded) {
83 // Close panel
84 root.anchors.right = undefined
85 root.anchors.left = root.parent.right
86 } else {
87 // Open panel
88 root.anchors.left = undefined
89 root.anchors.right = root.parent.right
90 }
91 }
92 }
93 }
94
95 //-------------------------------------------------------
96 // Right Panel Controls
97 Item {
98 anchors.fill: rightPanelBackground
99
100 DeadMouseArea {
101 anchors.fill: parent
102 }
103
104 Loader {
105 id: planTreeLoader
106 anchors.fill: parent
107 active: !root._useNewPlanPanel
108
109 sourceComponent: PlanTreeView {
110 objectName: "planView_planTree"
111 editorMap: root.editorMap
112 planMasterController: root.planMasterController
113 onEditingLayerChangeRequested: (layer) => root.editingLayerChangeRequested(layer)
114 }
115 }
116
117 Loader {
118 id: planPanelLoader
119 anchors.fill: parent
120 active: root._useNewPlanPanel
121
122 sourceComponent: PlanPanel {
123 editorMap: root.editorMap
124 planMasterController: root.planMasterController
125 onEditingLayerChangeRequested: (layer) => root.editingLayerChangeRequested(layer)
126 }
127 }
128 }
129
130 /// Called when the user picks a mission item on the map
131 function showItemInspector() {
132 if (planPanelLoader.item) {
133 planPanelLoader.item.showItemInspector()
134 }
135 }
136
137 function selectLayer(nodeType) {
138 // Ensure panel is open
139 if (!panelOpenCloseButton._expanded) {
140 root.anchors.left = undefined
141 root.anchors.right = root.parent.right
142 }
143 if (planPanelLoader.item) {
144 planPanelLoader.item.selectLayer(nodeType)
145 } else if (planTreeLoader.item) {
146 planTreeLoader.item.selectLayer(nodeType)
147 }
148 }
149}