Commit b286809e authored by Ronan Abhamon's avatar Ronan Abhamon

fix(ExclusiveButtons): supports unlimited buttons

parent 23aa0376
...@@ -3,45 +3,31 @@ import QtQuick 2.7 ...@@ -3,45 +3,31 @@ import QtQuick 2.7
// =================================================================== // ===================================================================
Row { Row {
property alias text1: button1.text property int selectedButton: 0
property alias text2: button2.text property variant texts
property bool button1IsSelected: true
signal buttonChanged (int button) signal buttonChanged (int button)
spacing: 8 spacing: 8
SmallButton { Repeater {
anchors.verticalCenter: parent.verticalCenter model: texts
backgroundColor: button1IsSelected SmallButton {
? '#8E8E8E' anchors.verticalCenter: parent.verticalCenter
: (button1.down backgroundColor: selectedButton === index
? '#FE5E00' ? '#8E8E8E'
: '#D1D1D1' : (button.down
) ? '#FE5E00'
id: button1 : '#D1D1D1'
onClicked: { )
if (!button1IsSelected) { id: button
button1IsSelected = true text: modelData
buttonChanged(1)
}
}
}
SmallButton { onClicked: {
anchors.verticalCenter: parent.verticalCenter if (selectedButton !== index) {
backgroundColor: !button1IsSelected selectedButton = index
? '#8E8E8E' buttonChanged(index)
: (button2.down }
? '#FE5E00'
: '#D1D1D1'
)
id: button2
onClicked: {
if (button1IsSelected) {
button1IsSelected = false
buttonChanged(2)
} }
} }
} }
......
...@@ -35,8 +35,10 @@ ColumnLayout { ...@@ -35,8 +35,10 @@ ColumnLayout {
ExclusiveButtons { ExclusiveButtons {
Layout.preferredHeight: parent.height Layout.preferredHeight: parent.height
text1: qsTr('selectAllContacts') texts: [
text2: qsTr('selectConnectedContacts') qsTr('selectAllContacts'),
qsTr('selectConnectedContacts')
]
} }
LightButton { LightButton {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment