QML UI: press and hold for delete dive on dive list

This looks a little rough, but I think it works well. I'm sure it could
be prettier, though. The next patch will just do the white space cleanup
for the additional indentation level.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2016-04-02 07:49:28 -05:00
parent 69c10808af
commit 0a0d7b48e9

View file

@ -42,7 +42,23 @@ Kirigami.ScrollablePage {
} }
} }
property bool deleteButtonVisible: false
onPressAndHold: {
deleteButtonVisible = true
timer.restart()
}
Row {
width: parent.width - Kirigami.Units.gridUnit
height: childrenRect.height - Kirigami.Units.smallSpacing
spacing: horizontalPadding
add: Transition {
NumberAnimation { property: "opacity"; from: 0; to: 1.0; duration: 400 }
NumberAnimation { property: "scale"; from: 0; to: 1.0; duration: 400 }
}
Item { Item {
id: diveListEntry
width: parent.width - Kirigami.Units.gridUnit width: parent.width - Kirigami.Units.gridUnit
height: childrenRect.height - Kirigami.Units.smallSpacing height: childrenRect.height - Kirigami.Units.smallSpacing
@ -113,6 +129,40 @@ Kirigami.ScrollablePage {
} }
} }
} }
Rectangle {
visible: deleteButtonVisible
height: diveListEntry.height - Kirigami.Units.smallSpacing
width: height - 3 * Kirigami.Units.smallSpacing
color: "#FF3030"
antialiasing: true
radius: Kirigami.Units.smallSpacing
Kirigami.Icon {
anchors {
horizontalCenter: parent.horizontalCenter
verticalCenter: parent.verticalCenter
}
source: "trash-empty"
}
MouseArea {
anchors.fill: parent
enabled: parent.visible
onClicked: {
parent.visible = false
timer.stop()
manager.deleteDive(dive.id)
}
}
}
Item {
Timer {
id: timer
interval: 4000
onTriggered: {
deleteButtonVisible = false
}
}
}
}
} }
} }