2023-04-09 13:35:35 +08:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2022-09-14 13:01:10 +08:00
|
|
|
import QtQuick
|
2022-03-27 14:49:41 +08:00
|
|
|
|
2024-01-25 03:23:29 +08:00
|
|
|
// https://gist.github.com/jonmcclung/bae669101d17b103e94790341301c129
|
|
|
|
// modified some code
|
2022-03-27 14:49:41 +08:00
|
|
|
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
|
2023-06-16 23:53:44 +08:00
|
|
|
clip: true
|
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
|
|
|
}
|
2023-02-26 16:51:29 +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
|
|
|
}
|