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