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