linphone-desktop/tests/ui/modules/Common/Form/ExclusiveButtons.qml
2016-12-28 14:23:52 +01:00

49 lines
1.2 KiB
QML

import QtQuick 2.7
import Common.Styles 1.0
// =============================================================================
Row {
id: item
// ---------------------------------------------------------------------------
property int selectedButton: 0
property var texts
// ---------------------------------------------------------------------------
// Emitted when the selected button is changed.
// Gives the selected button id.
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)
}
}
}
}
}