summaryrefslogtreecommitdiff
path: root/raveos-gnome-theme/theme-data/sddm/sddm-rave-theme/Components/ToastNotification.qml
blob: 43817c4a451207492455b63458a98af65ad7cc95 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// Config created by Keyitdev https://git.rp1.hu/gabeszm/sddm-rave-theme
// Copyright (C) 2022-2025 Keyitdev
// Distributed under the GPLv3+ License https://www.gnu.org/licenses/gpl-3.0.html

import QtQuick 2.15
import QtQuick.Controls 2.15

Item {
    id: toastRoot

    anchors.top: parent.top
    anchors.horizontalCenter: parent.horizontalCenter
    width: parent.width
    height: toastRect.height + root.font.pointSize * 2
    z: 100

    property string message: ""
    property bool showing: false

    function show(msg) {
        message = msg
        showing = true
        hideTimer.restart()
    }

    function hide() {
        showing = false
    }

    Rectangle {
        id: toastRect

        anchors.horizontalCenter: parent.horizontalCenter
        y: toastRoot.showing ? root.font.pointSize * 2 : -height - 10

        Behavior on y {
            NumberAnimation { duration: 380; easing.type: Easing.OutBack }
        }

        width: toastRow.implicitWidth + root.font.pointSize * 3
        height: root.font.pointSize * 3
        radius: height / 2

        color: Qt.rgba(0.75, 0.08, 0.08, 0.88)
        border.color: Qt.rgba(1, 0.35, 0.35, 0.65)
        border.width: 1

        // Pulse animation border
        SequentialAnimation on border.color {
            running: toastRoot.showing
            loops: Animation.Infinite
            ColorAnimation { to: Qt.rgba(1, 0.5, 0.5, 0.9);  duration: 600; easing.type: Easing.InOutSine }
            ColorAnimation { to: Qt.rgba(1, 0.25, 0.25, 0.5); duration: 600; easing.type: Easing.InOutSine }
        }

        Row {
            id: toastRow
            anchors.centerIn: parent
            spacing: root.font.pointSize * 0.6

            Text {
                anchors.verticalCenter: parent.verticalCenter
                text: "⚠"
                color: "#ff8888"
                font.pointSize: root.font.pointSize * 0.9
            }

            Text {
                anchors.verticalCenter: parent.verticalCenter
                text: toastRoot.message
                color: "#ffffff"
                font.pointSize: root.font.pointSize * 0.85
                font.family: root.font.family
            }
        }
    }

    Timer {
        id: hideTimer
        interval: 3000
        onTriggered: toastRoot.hide()
    }
}