blob: 2d04575b1a7bfbf97766302dc8cc9c56065115f1 (
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
|
import QtQuick 2.0
import QtQuick.Controls 2.0
import org.kde.kirigami 1.0 as Kirigami
import org.kube.framework 1.0 as Kube
MouseArea {
id: popup
property alias title: message.text
property alias timeout: hideTimer.interval
property alias background: bg.color
function hide() {
if (hideTimer.running)
hideTimer.stop()
popup.opacity = 0.0
}
function show() {
console.warn("Trying to show the notification", title);
popup.opacity = 1.0
hideTimer.restart()
}
function notify(text) {
popup.title = text
bg.color = Kube.Colors.textColor
show()
}
Timer {
id: hideTimer
triggeredOnStart: false
repeat: false
interval: 5000
onTriggered: popup.hide()
}
width: Math.max(300, message.contentWidth + (Kirigami.Units.largeSpacing * 2))
height: Math.max(50, message.contentHeight + (Kirigami.Units.largeSpacing * 2))
visible: opacity > 0
opacity: 0.0
Behavior on opacity {
NumberAnimation {
duration: 200
easing.type: Easing.InOutQuad
property: "opacity"
}
}
Rectangle {
id: bg
anchors.fill: parent
opacity: 0.6
}
Kube.Label {
id: message
anchors {
verticalCenter: popup.verticalCenter
left: parent.left
leftMargin: Kirigami.Units.largeSpacing
right: parent.right
rightMargin: Kirigami.Units.largeSpacing
}
font.pixelSize: 16
color: Kube.Colors.highlightedTextColor
horizontalAlignment: Text.AlignHCenter
elide: Text.ElideRight
wrapMode: Text.Wrap
}
onClicked: hide()
}
|