linphone-desktop/tests/ui/modules/Common/Form/ExclusiveButtons.qml

42 lines
888 B
QML

import QtQuick 2.7
import Common.Styles 1.0
// ===================================================================
Row {
id: item
property var texts
property int selectedButton: 0
signal clicked (int button)
spacing: ExclusiveButtonsStyle.buttonsSpacing
Repeater {
model: texts
SmallButton {
anchors.verticalCenter: parent.verticalCenter
backgroundColor: selectedButton === index
? ExclusiveButtonsStyle.button.color.selected
: (down
? ExclusiveButtonsStyle.button.color.pressed
: (hovered
? ExclusiveButtonsStyle.button.color.hovered
: ExclusiveButtonsStyle.button.color.normal
)
)
text: modelData
onClicked: {
if (selectedButton !== index) {
selectedButton = index
item.clicked(index)
}
}
}
}
}