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
|
|
|
|
|
|
|
Rectangle {
|
2022-04-30 15:27:56 +08:00
|
|
|
function show(text, duration) {
|
|
|
|
message.text = text;
|
|
|
|
time = Math.max(duration, 2 * fadeTime);
|
|
|
|
animation.start();
|
|
|
|
}
|
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
|
|
|
readonly property real defaultTime: 3000
|
|
|
|
property real time: defaultTime
|
|
|
|
readonly property real fadeTime: 300
|
2022-03-27 14:49:41 +08:00
|
|
|
|
2024-01-25 03:23:29 +08:00
|
|
|
anchors.horizontalCenter: parent != null ? parent.horizontalCenter
|
|
|
|
: undefined
|
2022-04-30 15:27:56 +08:00
|
|
|
height: message.height + 20
|
|
|
|
width: message.width + 40
|
|
|
|
radius: 16
|
2022-03-27 14:49:41 +08:00
|
|
|
|
2022-04-30 15:27:56 +08:00
|
|
|
opacity: 0
|
2022-03-27 14:49:41 +08:00
|
|
|
|
2022-04-30 15:27:56 +08:00
|
|
|
Text {
|
|
|
|
id: message
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
anchors.centerIn: parent
|
|
|
|
}
|
2022-03-27 14:49:41 +08:00
|
|
|
|
2022-04-30 15:27:56 +08:00
|
|
|
SequentialAnimation on opacity {
|
|
|
|
id: animation
|
|
|
|
running: false
|
2022-03-27 14:49:41 +08:00
|
|
|
|
|
|
|
|
2022-04-30 15:27:56 +08:00
|
|
|
NumberAnimation {
|
|
|
|
to: .9
|
|
|
|
duration: fadeTime
|
|
|
|
}
|
2022-03-27 14:49:41 +08:00
|
|
|
|
2022-04-30 15:27:56 +08:00
|
|
|
PauseAnimation {
|
|
|
|
duration: time - 2 * fadeTime
|
|
|
|
}
|
2022-03-27 14:49:41 +08:00
|
|
|
|
2022-04-30 15:27:56 +08:00
|
|
|
NumberAnimation {
|
|
|
|
to: 0
|
|
|
|
duration: fadeTime
|
|
|
|
}
|
2022-03-27 14:49:41 +08:00
|
|
|
|
2022-04-30 15:27:56 +08:00
|
|
|
onRunningChanged: {
|
|
|
|
if (!running) {
|
|
|
|
toast.model.remove(index);
|
|
|
|
}
|
2022-03-27 14:49:41 +08:00
|
|
|
}
|
2022-04-30 15:27:56 +08:00
|
|
|
}
|
2022-03-27 14:49:41 +08:00
|
|
|
}
|