5import QGroundControl.Controls
9 width: contentLayoutItem.contentWidth + (contentMargins * 2)
11 hoverEnabled: !ScreenTools.isMobile
12 enabled: toolStripAction.enabled
13 visible: toolStripAction.visible
14 imageSource: toolStripAction.showAlternateIcon ? modelData.alternateIconSource : modelData.iconSource
15 text: toolStripAction.text
16 checked: toolStripAction.checked
17 checkable: toolStripAction.dropPanelComponent || modelData.checkable
19 property var toolStripAction: undefined
20 property var dropPanel: undefined
21 property alias radius: buttonBkRect.radius
22 property alias fontPointSize: innerText.font.pointSize
23 property alias imageSource: innerImage.source
24 property alias contentWidth: innerText.contentWidth
26 property bool forceImageScale11: false
27 property real imageScale: forceImageScale11 && (text == "") ? 0.8 : 0.6
28 property real contentMargins: innerText.height * 0.1
30 property color _currentContentColor: (checked || pressed) ? qgcPal.buttonHighlightText : qgcPal.windowTransparentText
31 property color _currentContentColorSecondary: (checked || pressed) ? qgcPal.windowTransparentText : qgcPal.buttonHighlight
33 signal dropped(int index)
35 onCheckedChanged: toolStripAction.checked = checked
38 if (mainWindow.allowViewSwitch()) {
40 if (!toolStripAction.dropPanelComponent) {
41 toolStripAction.triggered(this)
43 var panelEdgeTopPoint = mapToItem(_root, width, 0)
44 dropPanel.show(panelEdgeTopPoint, toolStripAction.dropPanelComponent, this)
46 control.dropped(index)
48 } else if (checkable) {
53 QGCPalette { id: qgcPal; colorGroupEnabled: control.enabled }
58 anchors.margins: contentMargins
61 anchors.centerIn: parent
65 id: innerImageColorful
66 height: contentLayoutItem.height * imageScale
67 width: contentLayoutItem.width * imageScale
70 fillMode: Image.PreserveAspectFit
72 sourceSize.height: height
73 sourceSize.width: width
74 anchors.horizontalCenter: parent.horizontalCenter
75 source: control.imageSource
76 visible: source != "" && modelData.fullColorIcon
81 height: contentLayoutItem.height * imageScale
82 width: contentLayoutItem.width * imageScale
85 color: _currentContentColor
86 fillMode: Image.PreserveAspectFit
88 sourceSize.height: height
89 sourceSize.width: width
90 anchors.horizontalCenter: parent.horizontalCenter
91 visible: source != "" && !modelData.fullColorIcon
94 id: innerImageSecondColor
95 source: modelData.alternateIconSource
96 height: contentLayoutItem.height * imageScale
97 width: contentLayoutItem.width * imageScale
100 color: _currentContentColorSecondary
101 fillMode: Image.PreserveAspectFit
103 sourceSize.height: height
104 sourceSize.width: width
105 anchors.horizontalCenter: parent.horizontalCenter
106 visible: source != "" && modelData.biColorIcon
113 color: _currentContentColor
114 anchors.horizontalCenter: parent.horizontalCenter
115 font.bold: !innerImage.visible && !innerImageColorful.visible
116 opacity: !innerImage.visible ? 0.8 : 1.0
121 background: Rectangle {
123 color: (control.checked || control.pressed) ?
124 qgcPal.buttonHighlight :
125 ((control.enabled && control.hovered) ? qgcPal.toolStripHoverColor : "transparent")