QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
VehicleMessageList.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Controls
3import QtQuick.Layouts
4
5import QGroundControl
6import QGroundControl.Controls
7
8TextArea {
9 id: messageText
10 Layout.preferredWidth: ScreenTools.defaultFontPixelWidth * 50
11 height: contentHeight
12 readOnly: true
13 textFormat: TextEdit.RichText
14 color: qgcPal.textPrimary
15 placeholderText: qsTr("No Messages")
16 placeholderTextColor: qgcPal.textPrimary
17 padding: 0
18 wrapMode: TextEdit.Wrap
19
20 property bool noMessages: messageText.length === 0
21
22 property var _fact: null
23
24 function formatMessage(message) {
25 message = message.replace(new RegExp("<#E>", "g"), "color: " + qgcPal.errorText + "; font: " + (ScreenTools.defaultFontPointSize.toFixed(0) - 1) + "pt monospace;");
26 message = message.replace(new RegExp("<#I>", "g"), "color: " + qgcPal.warningText + "; font: " + (ScreenTools.defaultFontPointSize.toFixed(0) - 1) + "pt monospace;");
27 message = message.replace(new RegExp("<#N>", "g"), "color: " + qgcPal.textPrimary + "; font: " + (ScreenTools.defaultFontPointSize.toFixed(0) - 1) + "pt monospace;");
28 return message;
29 }
30
31 Component.onCompleted: {
32 messageText.text = formatMessage(_activeVehicle.formattedMessages)
33 }
34
35 Connections {
36 target: _activeVehicle
37 function onNewFormattedMessage(formattedMessage) { messageText.insert(0, formatMessage(formattedMessage)) }
38 function onFormattedMessagesChanged() { messageText.text = formatMessage(_activeVehicle.formattedMessages) }
39 }
40
41 FactPanelController {
42 id: controller
43 }
44
45 onLinkActivated: (link) => {
46 if (link.startsWith('param://')) {
47 var paramName = link.substr(8);
48 _fact = controller.getParameterFact(-1, paramName, true)
49 if (_fact != null) {
50 paramEditorDialogFactory.open()
51 }
52 } else {
53 Qt.openUrlExternally(link);
54 }
55 }
56
57 QGCPopupDialogFactory {
58 id: paramEditorDialogFactory
59
60 dialogComponent: paramEditorDialogComponent
61 }
62
63 Component {
64 id: paramEditorDialogComponent
65
66 ParameterEditorDialog {
67 title: qsTr("Edit Parameter")
68 fact: messageText._fact
69 destroyOnClose: true
70 }
71 }
72}