Сделать 2 и более кнопок в выезжающем меню
Я использовал SwipeDelegate для реализации алгоритма Swipe to Delete.
И после мне понадобилось сделать 2 кнопки в выезжающем меню.
Вот мой код, на данный момент он не рабочий:
SwipeDelegate {
id: swipeDelegate
width: parent.width
height: 80
text: "#model.name#"
leftPadding: 0
rightPadding: 0
verticalPadding: 0
topPadding: 0
property string thisName: ""
property string thisHost: ""
property string thisPort: ""
property string thisUser: ""
property string thisPass: ""
property string thisEmb: ""
contentItem: Rectangle {
id: frameBase
width: parent.width
height: parent.height
x: 0
y: 0
Row {
width: parent.width
height: parent.height
spacing: 10
anchors.fill: parent
Image {
id: server
width: 80
height: 80
source: "Res/images/objects/connection_vserver_mac_32.png"
}
Column {
id: col
x: 90
width: 270
height: 80
spacing: 10
Text {
id: label
text: qsTr(thisName)
font{
bold: true
italic: true
pixelSize: 34
}
}
Row {
Text {
id: host
text: qsTr(thisHost)
font{
italic: true
pixelSize: 24
}
}
spacing: 20
Text {
id: port
text: qsTr(thisPort)
font{
italic: true
pixelSize: 24
}
}
}
}
}
MouseArea {
x: parent.x
height: parent.height
width: parent.width-80
onClicked: {
stackView.push("Server.qml")
vConnection.open(thisHost, thisUser, thisPass)
console.log("Connecting")
}
}
}
ListView.onRemove: SequentialAnimation {
PropertyAction {
target: swipeDelegate
property: "ListView.delayRemove"
value: true
}
NumberAnimation {
target: swipeDelegate
property: "height"
to: 0
easing.type: Easing.InOutQuad
}
PropertyAction {
target: swipeDelegate;
property: "ListView.delayRemove";
value: false
}
}
swipe.right: Row {
Label {
id: edit
text: qsTr("Edit")
color: "white"
verticalAlignment: Label.AlignVCenter
padding: 12
height: parent.height
anchors.right: parent.right
background: Rectangle {
color: deleteLabel.SwipeDelegate.pressed ? Qt.darker("grey", 1.1) : "grey"
MouseArea {
anchors.fill: parent
onClicked:{
console.log("Editing " + index)
}
}
}
}
Label {
id: deleteLabel
text: qsTr("Delete")
color: "white"
verticalAlignment: Label.AlignVCenter
padding: 12
height: parent.height
anchors.right: parent.right
background: Rectangle {
color: deleteLabel.SwipeDelegate.pressed ? Qt.darker("tomato", 1.1) : "tomato"
MouseArea {
anchors.fill: parent
onClicked:{
console.log(index)
settings.deleting(index)
bookmarks.model.remove(index)
}
}
}
}
}
}
Задумка в том, что-бы сделать 2 кнопки в боковом меню, тобежи: первая справа -- кнопка Delete, вторая справа -- Edit.