QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
OnboardLogPage.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Controls
3import QtQuick.Layouts
4
5import QGroundControl
6import QGroundControl.Controls
7
8AnalyzePage {
9 id: onboardLogPage
10 pageComponent: pageComponent
11 pageDescription: qsTr("Onboard Logs allows you to download binary log files from your vehicle. Click Refresh to get list of available logs.")
12
13 property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
14 readonly property bool _vehicleArmed: _activeVehicle ? _activeVehicle.armed : false
15 readonly property bool _actionsAllowed: !_vehicleArmed && !OnboardLogController.requestingList && !OnboardLogController.downloadingLogs
16
17 QGCPalette { id: qgcPal; colorGroupEnabled: true }
18
19 function _updateNavigationBlocked() {
20 if (OnboardLogController.downloadingLogs) {
21 globals.navigationBlockedReason = qsTr("Wait for the log download to complete or cancel it first")
22 } else {
23 globals.navigationBlockedReason = ""
24 }
25 }
26
27 Connections {
28 target: OnboardLogController
29 function onDownloadingLogsChanged() { onboardLogPage._updateNavigationBlocked() }
30 }
31
32 Component.onCompleted: _updateNavigationBlocked()
33 Component.onDestruction: globals.navigationBlockedReason = ""
34
35 Component {
36 id: pageComponent
37
38 RowLayout {
39 width: availableWidth
40 height: availableHeight
41
42 Component.onCompleted: {
43 if (!onboardLogPage._vehicleArmed) {
44 OnboardLogController.refresh()
45 }
46 }
47
48 QGCFlickable {
49 Layout.fillWidth: true
50 Layout.fillHeight: true
51 contentWidth: gridLayout.width
52 contentHeight: gridLayout.height
53
54 GridLayout {
55 id: gridLayout
56 rows: OnboardLogController.model.count + 1
57 columns: 5
58 flow: GridLayout.TopToBottom
59 columnSpacing: ScreenTools.defaultFontPixelWidth
60 rowSpacing: 0
61
62 Item { } // First column is for checkboxes, so add empty item to align headers with log entries
63
64 Repeater {
65 model: OnboardLogController.model
66
67 QGCCheckBox {
68 objectName: "onboardLogCheckbox_" + index
69
70 Binding on checkState {
71 value: object.selected ? Qt.Checked : Qt.Unchecked
72 }
73
74 onClicked: object.selected = checked
75 }
76 }
77
78 QGCLabel { text: qsTr("Id") }
79
80 Repeater {
81 model: OnboardLogController.model
82
83 QGCLabel { text: object.id }
84 }
85
86 QGCLabel { text: qsTr("Date") }
87
88 Repeater {
89 model: OnboardLogController.model
90
91 QGCLabel {
92 objectName: "onboardLogDate_" + index
93
94 text: {
95 if (!object.received) {
96 return ""
97 }
98
99 // getUTCFullYear() is NaN for an invalid date
100 const year = object.time.getUTCFullYear()
101 if (Number.isNaN(year) || year < 2010) {
102 return qsTr("Date Unknown")
103 }
104
105 return object.time.toLocaleString(undefined)
106 }
107 }
108 }
109
110 QGCLabel { text: qsTr("Size") }
111
112 Repeater {
113 model: OnboardLogController.model
114
115 QGCLabel { text: object.sizeStr }
116 }
117
118 QGCLabel { text: qsTr("Status") }
119
120 Repeater {
121 model: OnboardLogController.model
122
123 QGCLabel {
124 objectName: "onboardLogStatus_" + index
125 text: object.status
126 }
127 }
128 }
129 }
130
131 ColumnLayout {
132 spacing: ScreenTools.defaultFontPixelWidth
133 Layout.alignment: Qt.AlignTop
134 Layout.fillWidth: false
135
136 QGCLabel {
137 objectName: "onboardLog_armedWarning"
138 Layout.fillWidth: true
139 // Zero preferred width stops the label widening the column; it wraps to the button width
140 Layout.preferredWidth: 0
141 visible: onboardLogPage._vehicleArmed
142 text: qsTr("Disabled while the vehicle is armed")
143 color: qgcPal.warningText
144 wrapMode: Text.WordWrap
145 }
146
147 QGCButton {
148 objectName: "onboardLog_refreshButton"
149 Layout.fillWidth: true
150 enabled: onboardLogPage._actionsAllowed
151 text: qsTr("Refresh")
152
153 onClicked: {
154 if (!QGroundControl.multiVehicleManager.activeVehicle || QGroundControl.multiVehicleManager.activeVehicle.isOfflineEditingVehicle) {
155 QGroundControl.showMessageDialog(onboardLogPage, qsTr("Onboard Log Refresh"), qsTr("You must be connected to a vehicle in order to download onboard logs."))
156 return
157 }
158
159 OnboardLogController.refresh()
160 }
161 }
162
163 QGCButton {
164 objectName: "onboardLog_selectAllButton"
165 Layout.fillWidth: true
166 enabled: onboardLogPage._actionsAllowed && (OnboardLogController.model.count > 0)
167 text: OnboardLogController.allLogsSelected ? qsTr("Deselect All") : qsTr("Select All")
168 onClicked: OnboardLogController.selectAll(!OnboardLogController.allLogsSelected)
169 }
170
171 QGCButton {
172 objectName: "onboardLog_downloadButton"
173 Layout.fillWidth: true
174 enabled: onboardLogPage._actionsAllowed && (OnboardLogController.selectedCount > 0)
175 text: qsTr("Download")
176
177 onClicked: {
178 if (ScreenTools.isMobile) {
179 OnboardLogController.download()
180 return
181 }
182
183 fileDialog.title = qsTr("Select save directory")
184 fileDialog.folder = QGroundControl.settingsManager.appSettings.logSavePath
185 fileDialog.selectFolder = true
186 fileDialog.openForLoad()
187 }
188
189 QGCFileDialog {
190 id: fileDialog
191 onAcceptedForLoad: (file) => {
192 OnboardLogController.download(file)
193 close()
194 }
195 }
196 }
197
198 QGCButton {
199 objectName: "onboardLog_sortButton"
200 Layout.fillWidth: true
201 enabled: onboardLogPage._actionsAllowed && (OnboardLogController.model.count > 1)
202 text: OnboardLogController.sortAscending ? qsTr("Sort Descending") : qsTr("Sort Ascending")
203 onClicked: OnboardLogController.toggleSortByDate()
204 }
205
206 QGCButton {
207 objectName: "onboardLog_eraseSelectedButton"
208 Layout.fillWidth: true
209 visible: OnboardLogController.transport === "ftp"
210 enabled: onboardLogPage._actionsAllowed && (OnboardLogController.selectedCount > 0)
211 text: qsTr("Erase Selected")
212 onClicked: QGroundControl.showMessageDialog(
213 onboardLogPage,
214 qsTr("Delete Selected Onboard Log Files"),
215 qsTr("The selected onboard log files will be erased permanently. Is this really what you want?"),
216 Dialog.Yes | Dialog.No,
217 function() { OnboardLogController.eraseSelected() }
218 )
219 }
220
221 QGCButton {
222 objectName: "onboardLog_eraseAllButton"
223 Layout.fillWidth: true
224 enabled: onboardLogPage._actionsAllowed && (OnboardLogController.model.count > 0)
225 text: qsTr("Erase All")
226 onClicked: QGroundControl.showMessageDialog(
227 onboardLogPage,
228 qsTr("Delete All Onboard Log Files"),
229 qsTr("All onboard log files will be erased permanently. Is this really what you want?"),
230 Dialog.Yes | Dialog.No,
231 function() { OnboardLogController.eraseAll() }
232 )
233 }
234
235 QGCButton {
236 objectName: "onboardLog_cancelButton"
237 Layout.fillWidth: true
238 text: qsTr("Cancel")
239 enabled: OnboardLogController.requestingList || OnboardLogController.downloadingLogs
240 onClicked: OnboardLogController.cancel()
241 }
242 }
243 }
244 }
245}