summaryrefslogtreecommitdiffstats
path: root/framework/qml/NotificationPopup.qml
diff options
context:
space:
mode:
Diffstat (limited to 'framework/qml/NotificationPopup.qml')
-rw-r--r--framework/qml/NotificationPopup.qml82
1 files changed, 82 insertions, 0 deletions
diff --git a/framework/qml/NotificationPopup.qml b/framework/qml/NotificationPopup.qml
new file mode 100644
index 00000000..2a336f36
--- /dev/null
+++ b/framework/qml/NotificationPopup.qml
@@ -0,0 +1,82 @@
1import QtQuick 2.0
2import QtQuick.Controls 2.0
3
4import org.kde.kirigami 1.0 as Kirigami
5
6
7MouseArea {
8 id: popup
9
10 property alias title: message.text
11 property alias timeout: hideTimer.interval
12 property alias background: bg.color
13
14 function hide() {
15 if (hideTimer.running)
16 hideTimer.stop()
17 popup.opacity = 0.0
18 }
19
20 function show() {
21 console.warn("Trying to show the notification", title);
22 popup.opacity = 1.0
23 hideTimer.restart()
24 }
25
26 function notify(text) {
27 popup.title = text
28 bg.color = Kube.Colors.textColor
29 show()
30 }
31
32 Timer {
33 id: hideTimer
34 triggeredOnStart: false
35 repeat: false
36 interval: 5000
37 onTriggered: popup.hide()
38 }
39
40 width: Math.max(300, message.contentWidth + (Kirigami.Units.largeSpacing * 2))
41 height: Math.max(50, message.contentHeight + (Kirigami.Units.largeSpacing * 2))
42
43 visible: opacity > 0
44 opacity: 0.0
45
46 Behavior on opacity {
47 NumberAnimation {
48 duration: 200
49 easing.type: Easing.InOutQuad
50 property: "opacity"
51 }
52 }
53
54 Rectangle {
55 id: bg
56
57 anchors.fill: parent
58
59 opacity: 0.6
60 }
61
62 Label {
63 id: message
64
65 anchors {
66 verticalCenter: popup.verticalCenter
67 left: parent.left
68 leftMargin: Kirigami.Units.largeSpacing
69 right: parent.right
70 rightMargin: Kirigami.Units.largeSpacing
71 }
72
73 font.pixelSize: 16
74
75 color: Kube.Colors.highlightedTextColor
76 horizontalAlignment: Text.AlignHCenter
77 elide: Text.ElideRight
78 wrapMode: Text.Wrap
79 }
80
81 onClicked: hide()
82}