Debian Codegraph @

notify/example/notify-example.qml

raw
1 import QtQuick 2.4
2 import Lomiri.Components 1.3
3 import "../src"
4
5
6 MainView {
7 id: mainView
8 width: units.gu(100)
9 height: units.gu(70)
10
11 Page {
12 title: "Notify example"
13
14 Column {
15 anchors {
16 left: parent.left
17 right: parent.right
18 top: parent.top
19 margins: units.gu(10)
20 }
21 spacing: units.gu(1.5)
22 Button {
23 width: parent.width
24 text: "Notify"
25 onClicked: notify.send("Hello notification")
26 }
27 Button {
28 width: parent.width
29 text: "Notify with body"
30 onClicked: notify.send("Hello notification", "With notification body, you can add a bit more context here.")
31 }
32 Button {
33 width: parent.width
34 text: "Notify on left (Long display time. 6 secs)"
35 onClicked: notify.send("Hello notification", "From the left", leftConfig)
36
37 NotifyConfiguration {
38 id: leftConfig
39 position: Item.Left
40 displayTime: 6000
41 }
42 }
43 Button {
44 width: parent.width
45 text: "Notify in center (short display time. 1.5 sec)"
46 onClicked: notify.send("Hello notification", "I'm in the center!", centerConfig)
47
48 NotifyConfiguration {
49 id: centerConfig
50 position: Item.Center
51 displayTime: 1500
52 }
53 }
54 Button {
55 width: parent.width
56 text: "Notify with action"
57 onClicked: notify.send("Hello notification", "Click me to trigger action", actionConfig)
58 }
59 Button {
60 width: parent.width
61 text: "Notify no body with action"
62 onClicked: notify.send("Hello notification", actionConfig)
63 }
64 Button {
65 width: parent.width
66 text: "Notify with Icon"
67 onClicked: notify.send("Hello notification", iconConfig)
68
69 NotifyConfiguration {
70 id: iconConfig
71 iconName: "edit-clear"
72 iconColor: LomiriColors.red
73 }
74 }
75 Button {
76 width: parent.width
77 text: "Custom notification"
78 onClicked: notify.send("Custom notify", customConfig)
79
80 NotifyConfiguration {
81 id: customConfig
82 source: Qt.resolvedUrl("./CustomNotification.qml")
83 }
84 }
85 }
86
87 NotifyConfiguration {
88 id: actionConfig
89 action: Action {
90 onTriggered: {
91 notify.send("Action triggered!")
92 }
93 }
94 }
95 }
96
97 Notify {
98 id: notify
99 anchors.fill: parent
100 }
101 }