QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
SubMenuButton.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Controls
3
4import QGroundControl
5import QGroundControl.Controls
6
7// Important Note: SubMenuButtons 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: control
12 text: "Button"
13 focusPolicy: Qt.ClickFocus
14 hoverEnabled: !ScreenTools.isMobile
15 implicitHeight: ScreenTools.defaultFontPixelHeight * 2.5
16
17 property bool setupComplete: true ///< true: setup complete indicator shows as completed
18 property var imageColor: undefined
19 property string imageResource: "/qmlimages/subMenuButtonImage.png" ///< Button image
20 property bool largeSize: false
21 property bool showHighlight: control.pressed | control.checked
22
23 property size sourceSize: Qt.size(ScreenTools.defaultFontPixelHeight * 2, ScreenTools.defaultFontPixelHeight * 2)
24
25 property ButtonGroup buttonGroup: null
26 onButtonGroupChanged: {
27 if (buttonGroup) {
28 buttonGroup.addButton(control)
29 }
30 }
31
32 onCheckedChanged: checkable = false
33
34 QGCPalette {
35 id: qgcPal
36 colorGroupEnabled: control.enabled
37 }
38
39 background: Rectangle {
40 id: innerRect
41 color: qgcPal.windowShade
42
43 implicitWidth: titleBar.x + titleBar.contentWidth + ScreenTools.defaultFontPixelWidth
44
45 Rectangle {
46 anchors.fill: parent
47 color: qgcPal.buttonHighlight
48 opacity: showHighlight ? 1 : control.enabled && control.hovered ? .2 : 0
49 }
50
51 QGCColoredImage {
52 id: image
53 anchors.leftMargin: ScreenTools.defaultFontPixelWidth
54 anchors.left: parent.left
55 anchors.verticalCenter: parent.verticalCenter
56 width: ScreenTools.defaultFontPixelHeight * 2
57 height: ScreenTools.defaultFontPixelHeight * 2
58 fillMode: Image.PreserveAspectFit
59 mipmap: true
60 color: imageColor ? imageColor : (control.setupComplete ? titleBar.color : "red")
61 source: control.imageResource
62 sourceSize: control.sourceSize
63 }
64
65 QGCLabel {
66 id: titleBar
67 anchors.leftMargin: ScreenTools.defaultFontPixelWidth
68 anchors.left: image.right
69 anchors.verticalCenter: parent.verticalCenter
70 verticalAlignment: TextEdit.AlignVCenter
71 color: showHighlight ? qgcPal.buttonHighlightText : qgcPal.buttonText
72 text: control.text
73 }
74 }
75
76 contentItem: Item {}
77}