QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
AppLogging.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Controls
3import QtQuick.Dialogs
4import QtQuick.Layouts
5
6import QGroundControl
7import QGroundControl.Controls
8import QGroundControl.FactControls
9
10Item {
11 id: root
12
13 property bool listViewLoadCompleted: false
14
15 Item {
16 id: panel
17 anchors.fill: parent
18
19 Rectangle {
20 id: logwindow
21 anchors.fill: parent
22 anchors.margins: ScreenTools.defaultFontPixelWidth
23 color: qgcPal.window
24
25 Component {
26 id: delegateItem
27 Rectangle {
28 color: index % 2 == 0 ? qgcPal.window : qgcPal.windowShade
29 height: Math.round(ScreenTools.defaultFontPixelHeight * 0.5 + field.height)
30 width: listView.width
31
32 QGCLabel {
33 id: field
34 text: display
35 width: parent.width
36 wrapMode: Text.Wrap
37 anchors.verticalCenter: parent.verticalCenter
38 }
39 }
40 }
41
42 QGCListView {
43 id: listView
44 anchors.top: parent.top
45 anchors.left: parent.left
46 anchors.right: parent.right
47 anchors.bottom: followTail.top
48 anchors.bottomMargin: ScreenTools.defaultFontPixelWidth
49 clip: true
50 model: debugMessageModel
51 delegate: delegateItem
52
53 function scrollToEnd() {
54 if (listViewLoadCompleted) {
55 if (followTail.checked) {
56 listView.positionViewAtEnd();
57 }
58 }
59 }
60
61 Component.onCompleted: {
62 listViewLoadCompleted = true
63 listView.scrollToEnd()
64 }
65
66 Connections {
67 target: debugMessageModel
68 function onDataChanged(topLeft, bottomRight, roles) { listView.scrollToEnd() }
69 }
70 }
71
72 QGCFileDialog {
73 id: writeDialog
74 folder: QGroundControl.settingsManager.appSettings.logSavePath
75 nameFilters: [qsTr("Log files (*.txt)"), qsTr("All Files (*)")]
76 title: qsTr("Select log save file")
77 onAcceptedForSave: (file) => {
78 debugMessageModel.writeMessages(file);
79 visible = false;
80 }
81 }
82
83 Connections {
84 target: debugMessageModel
85 function onWriteStarted() { writeButton.enabled = false }
86 function onWriteFinished(success) { writeButton.enabled = true }
87 }
88
89 QGCButton {
90 id: writeButton
91 anchors.bottom: parent.bottom
92 anchors.left: parent.left
93 onClicked: writeDialog.openForSave()
94 text: qsTr("Save App Log")
95 }
96
97 QGCLabel {
98 id: gstLabel
99 anchors.left: writeButton.right
100 anchors.leftMargin: ScreenTools.defaultFontPixelWidth
101 anchors.verticalCenter: gstCombo.verticalCenter
102 text: qsTr("GStreamer Debug Level")
103 visible: QGroundControl.settingsManager.appSettings.gstDebugLevel.visible
104 }
105
106 FactComboBox {
107 id: gstCombo
108 anchors.left: gstLabel.right
109 anchors.leftMargin: ScreenTools.defaultFontPixelWidth / 2
110 anchors.bottom: parent.bottom
111 fact: QGroundControl.settingsManager.appSettings.gstDebugLevel
112 visible: QGroundControl.settingsManager.appSettings.gstDebugLevel.visible
113 sizeToContents: true
114 }
115
116 QGCButton {
117 id: followTail
118 anchors.right: filterButton.left
119 anchors.rightMargin: ScreenTools.defaultFontPixelWidth
120 anchors.bottom: parent.bottom
121 text: qsTr("Show Latest")
122 checkable: true
123 checked: true
124
125 onCheckedChanged: {
126 if (checked && listViewLoadCompleted) {
127 listView.positionViewAtEnd();
128 }
129 }
130 }
131
132 QGCButton {
133 id: filterButton
134 anchors.bottom: parent.bottom
135 anchors.right: parent.right
136 text: qsTr("Set Logging")
137 onClicked: filtersDialogFactory.open()
138 }
139 }
140 }
141
142 QGCPopupDialogFactory {
143 id: filtersDialogFactory
144
145 dialogComponent: filtersDialogComponent
146 }
147
148 Component {
149 id: filtersDialogComponent
150
151 QGCPopupDialog {
152 title: qsTr("Logging")
153 buttons: Dialog.Close
154
155 ColumnLayout {
156 width: maxContentAvailableWidth
157
158 SettingsGroupLayout {
159 heading: qsTr("Search")
160 Layout.fillWidth: true
161
162 RowLayout {
163 Layout.fillWidth: true
164 spacing: ScreenTools.defaultFontPixelHeight / 2
165
166 QGCTextField {
167 Layout.fillWidth: true
168 id: searchText
169 text: ""
170 enabled: true
171 }
172
173 QGCButton {
174 text: qsTr("Clear")
175 onClicked: searchText.text = ""
176 }
177 }
178 }
179
180 SettingsGroupLayout {
181 heading: qsTr("Enabled Categories")
182 Layout.fillWidth: true
183
184 Flow {
185 Layout.fillWidth: true
186 spacing: ScreenTools.defaultFontPixelHeight / 2
187
188 Repeater {
189 model: QGroundControl.flatLoggingCategoriesModel()
190
191 QGCCheckBoxSlider {
192 Layout.fillWidth: true
193 Layout.maximumHeight: visible ? implicitHeight : 0
194 text: object.fullCategory
195 visible: object.enabled
196 checked: object.enabled
197 onClicked: object.enabled = checked
198 }
199 }
200
201 QGCButton {
202 text: qsTr("Disable All")
203 onClicked: QGroundControl.disableAllLoggingCategories()
204 }
205 }
206 }
207
208 // Shown when not filtered
209 Flow {
210 Layout.fillWidth: true
211 spacing: ScreenTools.defaultFontPixelHeight / 2
212 visible: searchText.text === ""
213
214 Repeater {
215 model: QGroundControl.treeLoggingCategoriesModel()
216
217 ColumnLayout {
218 spacing: ScreenTools.defaultFontPixelHeight / 2
219
220 RowLayout {
221 spacing: ScreenTools.defaultFontPixelWidth
222
223 QGCLabel {
224 Layout.preferredWidth: ScreenTools.defaultFontPixelWidth
225 text: object.expanded ? qsTr("-") : qsTr("+")
226 horizontalAlignment: Text.AlignLeft
227 visible: object.children
228
229 QGCMouseArea {
230 anchors.fill: parent
231 onClicked: object.expanded = !object.expanded
232 }
233 }
234
235 QGCCheckBoxSlider {
236 Layout.fillWidth: true
237 text: object.shortCategory
238 checked: object.enabled
239 onClicked: object.enabled = checked
240 }
241 }
242
243 Repeater {
244 model: object.expanded ? object.children : undefined
245
246 QGCCheckBoxSlider {
247 Layout.fillWidth: true
248 text: " " + object.shortCategory
249 checked: object.enabled
250 onClicked: object.enabled = checked
251 }
252 }
253 }
254 }
255 }
256
257 // Shown when filtered
258 Flow {
259 Layout.fillWidth: true
260 spacing: ScreenTools.defaultFontPixelHeight / 2
261 visible: searchText.text !== ""
262
263 Repeater {
264 model: QGroundControl.flatLoggingCategoriesModel()
265
266 QGCCheckBoxSlider {
267 Layout.fillWidth: true
268 Layout.maximumHeight: visible ? implicitHeight : 0
269 text: object.fullCategory
270 visible: text.match(`(${searchText.text})`, "i")
271 checked: object.enabled
272 onClicked: object.enabled = checked
273 }
274 }
275 }
276 }
277 }
278 }
279}