2022-09-14 13:01:10 +08:00
|
|
|
import QtQuick
|
2022-03-27 14:49:41 +08:00
|
|
|
|
|
|
|
// copy from https://gist.github.com/jonmcclung/bae669101d17b103e94790341301c129
|
|
|
|
// and modified some code
|
|
|
|
ListView {
|
2022-04-30 15:27:56 +08:00
|
|
|
function show(text, duration) {
|
|
|
|
if (duration === undefined) {
|
|
|
|
duration = 3000;
|
2022-03-27 14:49:41 +08:00
|
|
|
}
|
2022-04-30 15:27:56 +08:00
|
|
|
model.insert(0, {text: text, duration: duration});
|
|
|
|
}
|
2022-03-27 14:49:41 +08:00
|
|
|
|
2022-04-30 15:27:56 +08:00
|
|
|
id: root
|
2022-03-27 14:49:41 +08:00
|
|
|
|
2022-04-30 15:27:56 +08:00
|
|
|
z: Infinity
|
|
|
|
spacing: 5
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.bottomMargin: 10
|
|
|
|
verticalLayoutDirection: ListView.BottomToTop
|
2022-03-27 14:49:41 +08:00
|
|
|
|
2022-04-30 15:27:56 +08:00
|
|
|
interactive: false
|
2022-03-27 14:49:41 +08:00
|
|
|
|
2022-04-30 15:27:56 +08:00
|
|
|
displaced: Transition {
|
|
|
|
NumberAnimation {
|
|
|
|
properties: "y"
|
|
|
|
easing.type: Easing.InOutQuad
|
2022-03-27 14:49:41 +08:00
|
|
|
}
|
2022-04-30 15:27:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
delegate: Toast {
|
|
|
|
Component.onCompleted: {
|
|
|
|
show(text, duration);
|
2022-03-27 14:49:41 +08:00
|
|
|
}
|
2022-04-30 15:27:56 +08:00
|
|
|
}
|
2022-03-27 14:49:41 +08:00
|
|
|
|
2022-04-30 15:27:56 +08:00
|
|
|
model: ListModel {id: model}
|
2022-03-27 14:49:41 +08:00
|
|
|
}
|