5import QGroundControl.Controls
10 z: QGroundControl.zOrderTopMost
14 readonly property real _defaultTextHeight: ScreenTools.defaultFontPixelHeight
15 readonly property real _defaultTextWidth: ScreenTools.defaultFontPixelWidth
16 readonly property real _horizontalMargin: _defaultTextWidth / 2
17 readonly property real _verticalMargin: _defaultTextHeight / 2
19 property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
20 property var _currentPage: null
21 property var _currentItem: null
23 function _loadPage(source) {
25 _currentItem.destroy()
29 var component = Qt.createComponent(source)
30 if (component.status === Component.Ready) {
31 _currentItem = component.createObject(panelContainer)
36 function _updatePanelSource() {
38 if (_currentPage.requiresVehicle && !_activeVehicle) {
41 _loadPage(_currentPage.url)
46 on_ActiveVehicleChanged: {
47 if (_currentPage && _currentPage.requiresVehicle) {
50 Qt.callLater(_updatePanelSource)
55 // This need to block click event leakage to underlying map.
62 width: buttonColumn.width
63 anchors.topMargin: _defaultTextHeight / 2
64 anchors.top: parent.top
65 anchors.bottom: parent.bottom
66 anchors.leftMargin: _horizontalMargin
67 anchors.left: parent.left
68 contentHeight: buttonColumn.height
69 flickableDirection: Flickable.VerticalFlick
74 width: _maxButtonWidth
75 spacing: _defaultTextHeight / 2
77 property real _maxButtonWidth: {
79 for (var i = 0; i < buttonRepeater.count; i++) {
80 var item = buttonRepeater.itemAt(i)
81 if (item) maxW = Math.max(maxW, item.implicitWidth)
88 model: QGroundControl.corePlugin ? QGroundControl.corePlugin.analyzePages : []
90 Component.onCompleted: {
92 itemAt(0).checked = true
93 _currentPage = QGroundControl.corePlugin.analyzePages[0]
94 panelContainer.title = _currentPage.title
100 imageResource: modelData.icon
102 text: modelData.title
103 width: buttonColumn._maxButtonWidth
106 _currentPage = modelData
107 panelContainer.title = modelData.title
118 anchors.topMargin: _verticalMargin
119 anchors.bottomMargin: _verticalMargin
120 anchors.leftMargin: _horizontalMargin
121 anchors.left: buttonScroll.right
122 anchors.top: parent.top
123 anchors.bottom: parent.bottom
125 color: qgcPal.windowShade
130 anchors.topMargin: _verticalMargin
131 anchors.bottomMargin: _verticalMargin
132 anchors.leftMargin: _horizontalMargin
133 anchors.rightMargin: _horizontalMargin
134 anchors.left: divider.right
135 anchors.right: parent.right
136 anchors.top: parent.top
137 anchors.bottom: parent.bottom
139 property string title
143 function onPopout() {
144 var existingItem = _currentItem
145 var pageTitle = panelContainer.title
146 var pageSource = _currentPage.url
147 var requiresVehicle = _currentPage ? _currentPage.requiresVehicle : false
148 // Release ownership without destroying
150 existingItem.visible = false
151 // Hand the existing item to the popout window
152 mainWindow.createWindowedAnalyzePage(pageTitle, pageSource, requiresVehicle, existingItem)
153 // Create a fresh instance in-place
154 _loadPage(pageSource)
160 anchors.centerIn: panelContainer
161 text: qsTr("Requires a connected vehicle")
162 visible: _currentPage && _currentPage.requiresVehicle && !_activeVehicle