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