5import QGroundControl.Controls
9 objectName: toolStripAction ? toolStripAction.objectName : ""
10 width: contentLayoutItem.contentWidth + (contentMargins * 2)
12 hoverEnabled: !ScreenTools.isMobile
13 enabled: toolStripAction ? toolStripAction.enabled : true
14 visible: toolStripAction ? toolStripAction.visible : true
15 imageSource: (toolStripAction && modelData) ? (toolStripAction.showAlternateIcon ? modelData.alternateIconSource : modelData.iconSource) : ""
16 text: toolStripAction ? toolStripAction.text : ""
17 checked: toolStripAction ? toolStripAction.checked : false
18 checkable: toolStripAction ? (toolStripAction.dropPanelComponent || (modelData && modelData.checkable)) : false
20 property var toolStripAction: undefined
21 property var dropPanel: undefined
22 property alias radius: buttonBkRect.radius
23 property alias fontPointSize: innerText.font.pointSize
24 property alias imageSource: innerImage.source
25 property alias contentWidth: innerText.contentWidth
27 property bool forceImageScale11: false
28 property real imageScale: forceImageScale11 && (text == "") ? 0.8 : 0.6
29 property real contentMargins: innerText.height * 0.1
31 property color _currentContentColor: (checked || pressed) ? qgcPal.buttonHighlightText : qgcPal.text
32 property color _currentContentColorSecondary: (checked || pressed) ? qgcPal.text : qgcPal.buttonHighlight
34 signal dropped(int index)
36 onCheckedChanged: { if (toolStripAction) toolStripAction.checked = checked }
39 if (mainWindow.allowViewSwitch()) {
41 if (!toolStripAction.dropPanelComponent) {
42 toolStripAction.triggered(this)
44 var panelEdgeTopPoint = mapToItem(_root, width, 0)
45 dropPanel.show(panelEdgeTopPoint, toolStripAction.dropPanelComponent, this)
47 control.dropped(index)
49 } else if (checkable) {
54 QGCPalette { id: qgcPal; colorGroupEnabled: control.enabled }
59 anchors.margins: contentMargins
62 anchors.centerIn: parent
66 id: innerImageColorful
67 height: contentLayoutItem.height * imageScale
68 width: contentLayoutItem.width * imageScale
71 fillMode: Image.PreserveAspectFit
73 sourceSize.height: height
74 sourceSize.width: width
75 anchors.horizontalCenter: parent.horizontalCenter
76 source: control.imageSource
77 visible: source != "" && !!modelData && modelData.fullColorIcon
82 height: contentLayoutItem.height * imageScale
83 width: contentLayoutItem.width * imageScale
86 color: _currentContentColor
87 fillMode: Image.PreserveAspectFit
89 sourceSize.height: height
90 sourceSize.width: width
91 anchors.horizontalCenter: parent.horizontalCenter
92 visible: source != "" && !(modelData && modelData.fullColorIcon)
95 id: innerImageSecondColor
96 source: modelData ? modelData.alternateIconSource : ""
97 height: contentLayoutItem.height * imageScale
98 width: contentLayoutItem.width * imageScale
101 color: _currentContentColorSecondary
102 fillMode: Image.PreserveAspectFit
104 sourceSize.height: height
105 sourceSize.width: width
106 anchors.horizontalCenter: parent.horizontalCenter
107 visible: source != "" && !!modelData && modelData.biColorIcon
114 color: _currentContentColor
115 anchors.horizontalCenter: parent.horizontalCenter
116 font.bold: !innerImage.visible && !innerImageColorful.visible
117 opacity: !innerImage.visible ? 0.8 : 1.0
122 background: Rectangle {
124 color: (control.checked || control.pressed) ?
125 qgcPal.buttonHighlight :
126 ((control.enabled && control.hovered) ? qgcPal.toolStripHoverColor : "transparent")