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: showHighlight ? qgcPal.accentSubtle : qgcPal.windowCard
42 border.width: 1
43 border.color: showHighlight || (control.enabled && control.hovered) ? qgcPal.accent : qgcPal.borderSubtle
44 radius: ScreenTools.defaultBorderRadius
45
46 implicitWidth: titleBar.x + titleBar.contentWidth + ScreenTools.defaultFontPixelWidth
47
48 QGCColoredImage {
49 id: image
50 anchors.leftMargin: ScreenTools.defaultFontPixelWidth
51 anchors.left: parent.left
52 anchors.verticalCenter: parent.verticalCenter
53 width: ScreenTools.defaultFontPixelHeight * 2
54 height: ScreenTools.defaultFontPixelHeight * 2
55 fillMode: Image.PreserveAspectFit
56 mipmap: true
57 color: imageColor ? imageColor : (control.setupComplete ? titleBar.color : "red")
58 source: control.imageResource
59 sourceSize: control.sourceSize
60 }
61
62 QGCLabel {
63 id: titleBar
64 anchors.leftMargin: ScreenTools.defaultFontPixelWidth
65 anchors.left: image.right
66 anchors.verticalCenter: parent.verticalCenter
67 verticalAlignment: TextEdit.AlignVCenter
68 color: qgcPal.textPrimary
69 text: control.text
70 }
71 }
72
73 contentItem: Item {}
74}