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.text
15 placeholderText: qsTr("No Messages")
16 placeholderTextColor: qgcPal.text
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.warningText + "; 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.text + "; font: " + (ScreenTools.defaultFontPointSize.toFixed(0) - 1) + "pt monospace;");
28 return message;
29 }
30
31 Component.onCompleted: {
32 messageText.text = formatMessage(_activeVehicle.formattedMessages)
33 if (_activeVehicle) {
34 _activeVehicle.resetAllMessages()
35 }
36 }
37
38 Connections {
39 target: _activeVehicle
40 function onNewFormattedMessage(formattedMessage) { messageText.insert(0, formatMessage(formattedMessage)) }
41 }
42
43 FactPanelController {
44 id: controller
45 }
46
47 onLinkActivated: (link) => {
48 if (link.startsWith('param://')) {
49 var paramName = link.substr(8);
50 _fact = controller.getParameterFact(-1, paramName, true)
51 if (_fact != null) {
52 paramEditorDialogFactory.open()
53 }
54 } else {
55 Qt.openUrlExternally(link);
56 }
57 }
58
59 QGCPopupDialogFactory {
60 id: paramEditorDialogFactory
61
62 dialogComponent: paramEditorDialogComponent
63 }
64
65 Component {
66 id: paramEditorDialogComponent
67
68 ParameterEditorDialog {
69 title: qsTr("Edit Parameter")
70 fact: messageText._fact
71 destroyOnClose: true
72 }
73 }
74
75 Rectangle {
76 anchors.right: parent.right
77 anchors.top: parent.top
78 width: ScreenTools.defaultFontPixelHeight * 1.25
79 height: width
80 radius: width / 2
81 color: QGroundControl.globalPalette.button
82 border.color: QGroundControl.globalPalette.buttonText
83 visible: !noMessages
84
85 QGCColoredImage {
86 anchors.margins: ScreenTools.defaultFontPixelHeight * 0.25
87 anchors.centerIn: parent
88 anchors.fill: parent
89 sourceSize.height: height
90 source: "/res/TrashDelete.svg"
91 fillMode: Image.PreserveAspectFit
92 mipmap: true
93 smooth: true
94 color: qgcPal.text
95 }
96
97 QGCMouseArea {
98 fillItem: parent
99 onClicked: {
100 _activeVehicle.clearMessages()
101 mainWindow.closeIndicatorDrawer()
102 }
103 }
104 }
105}