5import QGroundControl.Controls
10 z: QGroundControl.zOrderTopMost
12 readonly property real _defaultTextHeight: ScreenTools.defaultFontPixelHeight
13 readonly property real _defaultTextWidth: ScreenTools.defaultFontPixelWidth
14 readonly property real _horizontalMargin: _defaultTextWidth / 2
15 readonly property real _verticalMargin: _defaultTextHeight / 2
17 property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
18 property var _currentPage: null
19 property var _currentItem: null
20 // Destroy the in-panel page item while panelContainer is still alive, before the
21 // loader clears the source and tears down this component.
22 Component.onDestruction: mainWindow.destroyInPanelAnalyzePage()
24 function _loadPage(source) {
25 // Clear reference before calling mainWindow.createAnalyzePage (which destroys the old item).
28 // mainWindow creates and owns the item (QObject parent = mainWindow) so it
29 // survives AnalyzeView being unloaded in the popped-out case.
30 // anchors.fill: parent in AnalyzePage.qml automatically fills panelContainer.
31 _currentItem = mainWindow.createAnalyzePage(source)
33 _currentItem.parent = panelContainer
36 mainWindow.destroyInPanelAnalyzePage()
40 function _updatePanelSource() {
42 if (_currentPage.requiresVehicle && !_activeVehicle) {
45 _loadPage(_currentPage.url)
50 on_ActiveVehicleChanged: {
51 if (_currentPage && _currentPage.requiresVehicle) {
54 Qt.callLater(_updatePanelSource)
59 // This need to block click event leakage to underlying map.
66 width: buttonColumn.width
67 anchors.topMargin: _defaultTextHeight / 2
68 anchors.top: parent.top
69 anchors.bottom: parent.bottom
70 anchors.leftMargin: _horizontalMargin
71 anchors.left: parent.left
72 contentHeight: buttonColumn.height
73 flickableDirection: Flickable.VerticalFlick
78 width: _maxButtonWidth
79 spacing: _defaultTextHeight / 2
81 property real _maxButtonWidth: {
83 for (var i = 0; i < buttonRepeater.count; i++) {
84 var item = buttonRepeater.itemAt(i)
85 if (item) maxW = Math.max(maxW, item.implicitWidth)
92 model: QGroundControl.corePlugin ? QGroundControl.corePlugin.analyzePages : []
94 Component.onCompleted: {
96 itemAt(0).checked = true
97 _currentPage = QGroundControl.corePlugin.analyzePages[0]
98 panelContainer.title = _currentPage.title
104 objectName: "analyzeButton_" + modelData.title
105 imageResource: modelData.icon
107 text: modelData.title
108 width: buttonColumn._maxButtonWidth
111 _currentPage = modelData
112 panelContainer.title = modelData.title
123 anchors.topMargin: _verticalMargin
124 anchors.bottomMargin: _verticalMargin
125 anchors.leftMargin: _horizontalMargin
126 anchors.left: buttonScroll.right
127 anchors.top: parent.top
128 anchors.bottom: parent.bottom
130 color: qgcPal.windowShade
135 anchors.topMargin: _verticalMargin
136 anchors.bottomMargin: _verticalMargin
137 anchors.leftMargin: _horizontalMargin
138 anchors.rightMargin: _horizontalMargin
139 anchors.left: divider.right
140 anchors.right: parent.right
141 anchors.top: parent.top
142 anchors.bottom: parent.bottom
144 property string title
149 function onPopout() {
150 var existingItem = _currentItem
151 var pageTitle = panelContainer.title
152 var pageSource = _currentPage.url
153 var requiresVehicle = _currentPage ? _currentPage.requiresVehicle : false
154 // Clear references before handing item to the popup window.
156 // Tell mainWindow this item has moved to a popup so it is not destroyed
157 // when AnalyzeView is torn down.
158 mainWindow.analyzePageMovedToPopup()
159 existingItem.visible = false
160 // Hand the existing item to the popout window.
161 mainWindow.createWindowedAnalyzePage(pageTitle, pageSource, requiresVehicle, existingItem)
162 // Create a fresh in-panel instance.
163 _loadPage(pageSource)
169 anchors.centerIn: panelContainer
170 text: qsTr("Requires a connected vehicle")
171 visible: _currentPage && _currentPage.requiresVehicle && !_activeVehicle