QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
MAVLinkMessageButton.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Controls
3import QtQuick.Layouts
4
5import QGroundControl
6import QGroundControl.Controls
7
8Button {
9 id: control
10 autoExclusive: true
11 leftPadding: ScreenTools.defaultFontPixelWidth
12 rightPadding: leftPadding
13
14 property real _compIDWidth: ScreenTools.defaultFontPixelWidth * 3
15 property real _hzWidth: ScreenTools.defaultFontPixelWidth * 6
16 property real _nameWidth: nameLabel.contentWidth
17
18 background: Rectangle {
19 anchors.fill: parent
20 color: checked ? qgcPal.buttonHighlight : qgcPal.button
21 }
22
23 property double messageHz: 0
24 property int compID: 0
25
26 contentItem: RowLayout {
27 id: rowLayout
28 spacing: ScreenTools.defaultFontPixelWidth
29
30 QGCLabel {
31 text: control.compID
32 color: checked ? qgcPal.buttonHighlightText : qgcPal.buttonText
33 verticalAlignment: Text.AlignVCenter
34 Layout.minimumHeight: ScreenTools.isMobile ? (ScreenTools.defaultFontPixelHeight * 2) : (ScreenTools.defaultFontPixelHeight * 1.5)
35 Layout.minimumWidth: _compIDWidth
36 }
37 QGCLabel {
38 id: nameLabel
39 text: control.text
40 color: checked ? qgcPal.buttonHighlightText : qgcPal.buttonText
41 Layout.fillWidth: true
42 Layout.alignment: Qt.AlignVCenter
43 }
44 QGCLabel {
45 color: checked ? qgcPal.buttonHighlightText : qgcPal.buttonText
46 text: messageHz.toFixed(1) + 'Hz'
47 horizontalAlignment: Text.AlignRight
48 Layout.minimumWidth: _hzWidth
49 Layout.alignment: Qt.AlignVCenter
50 }
51 }
52
53 Component.onCompleted: maxButtonWidth = Math.max(maxButtonWidth, _compIDWidth + _hzWidth + _nameWidth + (rowLayout.spacing * 2) + (control.leftPadding * 2))
54}