2022-03-27 06:49:41 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
|
|
|
|
Rectangle {
|
2022-04-30 07:27:56 +00:00
|
|
|
function show(text, duration) {
|
|
|
|
message.text = text;
|
|
|
|
time = Math.max(duration, 2 * fadeTime);
|
|
|
|
animation.start();
|
|
|
|
}
|
2022-03-27 06:49:41 +00:00
|
|
|
|
2022-04-30 07:27:56 +00:00
|
|
|
id: root
|
2022-03-27 06:49:41 +00:00
|
|
|
|
2022-04-30 07:27:56 +00:00
|
|
|
readonly property real defaultTime: 3000
|
|
|
|
property real time: defaultTime
|
|
|
|
readonly property real fadeTime: 300
|
2022-03-27 06:49:41 +00:00
|
|
|
|
2022-04-30 07:27:56 +00:00
|
|
|
anchors.horizontalCenter: parent != null ? parent.horizontalCenter : undefined
|
|
|
|
height: message.height + 20
|
|
|
|
width: message.width + 40
|
|
|
|
radius: 16
|
2022-03-27 06:49:41 +00:00
|
|
|
|
2022-04-30 07:27:56 +00:00
|
|
|
opacity: 0
|
|
|
|
color: "#F2808A87"
|
2022-03-27 06:49:41 +00:00
|
|
|
|
2022-04-30 07:27:56 +00:00
|
|
|
Text {
|
|
|
|
id: message
|
|
|
|
color: "white"
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
anchors.centerIn: parent
|
|
|
|
}
|
2022-03-27 06:49:41 +00:00
|
|
|
|
2022-04-30 07:27:56 +00:00
|
|
|
SequentialAnimation on opacity {
|
|
|
|
id: animation
|
|
|
|
running: false
|
2022-03-27 06:49:41 +00:00
|
|
|
|
|
|
|
|
2022-04-30 07:27:56 +00:00
|
|
|
NumberAnimation {
|
|
|
|
to: .9
|
|
|
|
duration: fadeTime
|
|
|
|
}
|
2022-03-27 06:49:41 +00:00
|
|
|
|
2022-04-30 07:27:56 +00:00
|
|
|
PauseAnimation {
|
|
|
|
duration: time - 2 * fadeTime
|
|
|
|
}
|
2022-03-27 06:49:41 +00:00
|
|
|
|
2022-04-30 07:27:56 +00:00
|
|
|
NumberAnimation {
|
|
|
|
to: 0
|
|
|
|
duration: fadeTime
|
|
|
|
}
|
2022-03-27 06:49:41 +00:00
|
|
|
|
2022-04-30 07:27:56 +00:00
|
|
|
onRunningChanged: {
|
|
|
|
if (!running) {
|
|
|
|
toast.model.remove(index);
|
|
|
|
}
|
2022-03-27 06:49:41 +00:00
|
|
|
}
|
2022-04-30 07:27:56 +00:00
|
|
|
}
|
2022-03-27 06:49:41 +00:00
|
|
|
}
|