summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-03-16 12:05:52 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-03-16 12:05:52 +0100
commit106c84b5540e54741f41c62ea224e783a756297f (patch)
tree2b34924de8804cdc9c9b1dfbab2dadf6a9f3c21b
parent64cfb8daa16a49cd5cd4b2d2344d85db31739c0e (diff)
downloadkube-106c84b5540e54741f41c62ea224e783a756297f.tar.gz
kube-106c84b5540e54741f41c62ea224e783a756297f.zip
A first notification popup
-rw-r--r--components/mail/contents/ui/Mail.qml5
-rw-r--r--components/package/contents/ui/Notification.qml71
-rw-r--r--components/qmldir1
3 files changed, 77 insertions, 0 deletions
diff --git a/components/mail/contents/ui/Mail.qml b/components/mail/contents/ui/Mail.qml
index 334e5a96..3cc0d4f4 100644
--- a/components/mail/contents/ui/Mail.qml
+++ b/components/mail/contents/ui/Mail.qml
@@ -48,6 +48,7 @@ Controls2.ApplicationWindow {
48 if (n.type == KubeNotifications.Notification.Warning) { 48 if (n.type == KubeNotifications.Notification.Warning) {
49 console.warn("And it's a warning!", n.type) 49 console.warn("And it's a warning!", n.type)
50 } 50 }
51 notificationPopup.notify(n.message);
51 } 52 }
52 } 53 }
53 54
@@ -325,6 +326,10 @@ Controls2.ApplicationWindow {
325 } 326 }
326 //END AccountWizard 327 //END AccountWizard
327 328
329 KubeComponents.Notification {
330 id: notificationPopup
331 }
332
328 //BEGIN Search 333 //BEGIN Search
329 Controls2.Popup { 334 Controls2.Popup {
330 id: search 335 id: search
diff --git a/components/package/contents/ui/Notification.qml b/components/package/contents/ui/Notification.qml
new file mode 100644
index 00000000..62128961
--- /dev/null
+++ b/components/package/contents/ui/Notification.qml
@@ -0,0 +1,71 @@
1import QtQuick 2.0
2import QtQuick.Controls 2.0
3import org.kde.kirigami 1.0 as Kirigami
4
5MouseArea {
6 id: popup
7 anchors.top: parent.top
8 anchors.horizontalCenter: parent.horizontalCenter
9 width: Math.max(300, message.contentWidth + (Kirigami.Units.gridUnit * 2))
10 height: message.contentHeight + (Kirigami.Units.gridUnit * 2)
11 property alias title: message.text
12 property alias timeout: hideTimer.interval
13 property alias background: bg.color
14 visible: opacity > 0
15 opacity: 0.0
16
17 Behavior on opacity {
18 NumberAnimation {
19 duration: 200
20 easing.type: Easing.InOutQuad
21 property: "opacity"
22 }
23 }
24
25 Rectangle {
26 id: bg
27 anchors.fill: parent
28 }
29
30 Timer {
31 id: hideTimer
32 triggeredOnStart: false
33 repeat: false
34 interval: 5000
35 onTriggered: popup.hide()
36 }
37
38 function hide() {
39 if (hideTimer.running)
40 hideTimer.stop()
41 popup.opacity = 0.0
42 }
43
44 function show() {
45 console.warn("Trying to show the notification", title);
46 popup.opacity = 1.0
47 hideTimer.restart()
48 }
49
50 function notify(text) {
51 popup.title = text
52 bg.color = Kirigami.Theme.highlightColor
53 show()
54 }
55
56 Label {
57 id: message
58 anchors.verticalCenter: popup.verticalCenter
59 font.pixelSize: 16
60 color: Kirigami.Theme.highlightedTextColor
61 anchors.left: parent.left
62 anchors.leftMargin: Kirigami.Units.gridUnit
63 anchors.right: parent.right
64 anchors.rightMargin: Kirigami.Units.gridUnit
65 horizontalAlignment: Text.AlignHCenter
66 elide: Text.ElideRight
67 wrapMode: Text.Wrap
68 }
69
70 onClicked: hide()
71}
diff --git a/components/qmldir b/components/qmldir
index 1135ce4e..94ac9caf 100644
--- a/components/qmldir
+++ b/components/qmldir
@@ -11,3 +11,4 @@ EditAccountDialog 1.0 EditAccountDialog.qml
11OverlayDialog 1.0 OverlayDialog.qml 11OverlayDialog 1.0 OverlayDialog.qml
12Outbox 1.0 Outbox.qml 12Outbox 1.0 Outbox.qml
13People 1.0 People.qml 13People 1.0 People.qml
14Notification 1.0 Notification.qml