QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
QGCToolBarButton.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Controls
3
4import QGroundControl
5import QGroundControl.Controls
6
7// Important Note: Toolbar buttons must manage their checked state manually in order to support
8// view switch prevention. This means they can't be checkable or autoExclusive.
9
10Button {
11 id: button
12 height: ScreenTools.defaultFontPixelHeight * 3
13 leftPadding: _horizontalMargin
14 rightPadding: _horizontalMargin
15 checkable: false
16
17 property bool logo: false
18
19 property real _horizontalMargin: ScreenTools.defaultFontPixelWidth
20
21 onCheckedChanged: checkable = false
22
23 background: Rectangle {
24 anchors.fill: parent
25 color: button.checked ? qgcPal.buttonHighlight : Qt.rgba(0,0,0,0)
26 border.color: "red"
27 border.width: QGroundControl.corePlugin.showTouchAreas ? 3 : 0
28 }
29
30 contentItem: Row {
31 spacing: ScreenTools.defaultFontPixelWidth
32 anchors.verticalCenter: button.verticalCenter
33 // Logo buttons render the multi-color SVG natively via VectorImage; non-logo buttons
34 // tint their monochrome icon through QGCColoredImage. Plain `Row` skips visible:false items.
35 QGCVectorImage {
36 visible: button.logo
37 height: ScreenTools.defaultFontPixelHeight * 2
38 width: height
39 source: visible ? button.icon.source : ""
40 anchors.verticalCenter: parent.verticalCenter
41
42 Rectangle {
43 objectName: "toolbar_qgcUpdateAvailableBadge"
44 z: 1 // VectorImage adds its rendered SVG as a later child
45 anchors.top: parent.top
46 anchors.right: parent.right
47 anchors.topMargin: -height * 0.25
48 anchors.rightMargin: -width * 0.25
49 width: ScreenTools.defaultFontPixelHeight
50 height: width
51 radius: width / 2
52 color: Qt.rgba(1, 1, 1, 0.75)
53 visible: QGroundControl.newStableVersion !== ""
54
55 QGCColoredImage {
56 anchors.fill: parent
57 source: "/res/UpdateAvailable.svg"
58 color: qgcPal.colorBlue
59 }
60 }
61 }
62 QGCColoredImage {
63 visible: !button.logo
64 height: ScreenTools.defaultFontPixelHeight * 2
65 width: height
66 sourceSize.height: parent.height
67 fillMode: Image.PreserveAspectFit
68 color: button.checked ? qgcPal.buttonHighlightText : qgcPal.buttonText
69 source: visible ? button.icon.source : ""
70 anchors.verticalCenter: parent.verticalCenter
71 }
72 Label {
73 id: _label
74 visible: text !== ""
75 text: button.text
76 color: button.checked ? qgcPal.buttonHighlightText : qgcPal.buttonText
77 anchors.verticalCenter: parent.verticalCenter
78 }
79 }
80}