diff options
-rw-r--r-- | components/mail/contents/ui/Mail.qml | 5 | ||||
-rw-r--r-- | components/package/contents/ui/Notification.qml | 71 | ||||
-rw-r--r-- | components/qmldir | 1 |
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 @@ | |||
1 | import QtQuick 2.0 | ||
2 | import QtQuick.Controls 2.0 | ||
3 | import org.kde.kirigami 1.0 as Kirigami | ||
4 | |||
5 | MouseArea { | ||
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 | |||
11 | OverlayDialog 1.0 OverlayDialog.qml | 11 | OverlayDialog 1.0 OverlayDialog.qml |
12 | Outbox 1.0 Outbox.qml | 12 | Outbox 1.0 Outbox.qml |
13 | People 1.0 People.qml | 13 | People 1.0 People.qml |
14 | Notification 1.0 Notification.qml | ||