5import QGroundControl.Controls
7/// Mutually exclusive buttons joined into a single bar. Selecting a button emits activated; the owner updates
8/// currentIndex in response, so a binding on currentIndex is never replaced.
11 implicitWidth: buttonRow.implicitWidth + border.width * 2
12 implicitHeight: buttonRow.implicitHeight + border.width * 2
14 border.color: qgcPal.borderSubtle
15 radius: ScreenTools.defaultBorderRadius * 2
17 property var model: [] ///< Button labels
18 property int currentIndex: 0
20 /// Emitted only when the user selects a different button
21 signal activated(int index)
23 QGCPalette { id: qgcPal; colorGroupEnabled: control.enabled }
27 x: control.border.width
28 y: control.border.width
37 checked: index === control.currentIndex
39 leftPadding: ScreenTools.defaultFontPixelWidth * 1.5
40 rightPadding: leftPadding
41 topPadding: ScreenTools.defaultFontPixelHeight * 0.3
42 bottomPadding: topPadding
44 required property int index
45 required property string modelData
47 readonly property real _outerRadius: Math.max(control.radius - control.border.width, 0)
49 background: Rectangle {
50 color: button.checked ? qgcPal.borderSubtle : (button.hovered ? qgcPal.windowCard : "transparent")
51 topLeftRadius: button.index === 0 ? button._outerRadius : 0
52 bottomLeftRadius: topLeftRadius
53 topRightRadius: button.index === buttonRepeater.count - 1 ? button._outerRadius : 0
54 bottomRightRadius: topRightRadius
57 contentItem: QGCLabel {
60 color: button.checked ? qgcPal.textPrimary : qgcPal.textSecondary
61 horizontalAlignment: Text.AlignHCenter
62 verticalAlignment: Text.AlignVCenter
66 if (index !== control.currentIndex) {
67 control.activated(index)