Changeset View
Changeset View
Standalone View
Standalone View
applets/notifications/package/contents/ui/NotificationPopup.qml
Show First 20 Lines • Show All 66 Lines • ▼ Show 20 Line(s) | 31 | PlasmaCore.Dialog { | |||
---|---|---|---|---|---|
67 | 67 | | |||
68 | Behavior on y { | 68 | Behavior on y { | ||
69 | NumberAnimation { | 69 | NumberAnimation { | ||
70 | duration: units.longDuration | 70 | duration: units.longDuration | ||
71 | easing.type: Easing.OutQuad | 71 | easing.type: Easing.OutQuad | ||
72 | } | 72 | } | ||
73 | } | 73 | } | ||
74 | 74 | | |||
75 | mainItem: KQuickControlsAddons.MouseEventListener { | 75 | mainItem: NotificationItem { | ||
76 | id: root | 76 | id: notificationItem | ||
77 | hoverEnabled: true | ||||
78 | | ||||
77 | LayoutMirroring.enabled: Qt.application.layoutDirection === Qt.RightToLeft | 79 | LayoutMirroring.enabled: Qt.application.layoutDirection === Qt.RightToLeft | ||
78 | LayoutMirroring.childrenInherit: true | 80 | LayoutMirroring.childrenInherit: true | ||
79 | 81 | | |||
80 | width: notificationItem.width | 82 | height: implicitHeight | ||
81 | height: notificationItem.implicitHeight | | |||
82 | | ||||
83 | hoverEnabled: true | | |||
84 | | ||||
85 | onClicked: { | | |||
86 | // the MEL would close the notification before the action button | | |||
87 | // onClicked handler would fire effectively breaking notification actions | | |||
88 | if (notificationItem.pressedAction()) { | | |||
89 | return | | |||
90 | } | | |||
91 | | ||||
92 | if (notificationItem.hasDefaultAction) { | | |||
93 | // the notifications was clicked, trigger the default action if set | | |||
94 | notificationItem.action("default") | | |||
95 | } else { | | |||
96 | closeNotification(notificationProperties.source) | | |||
97 | // the popup will be closed in response to sourceRemoved | | |||
98 | } | | |||
99 | } | | |||
100 | onContainsMouseChanged: { | | |||
101 | if (containsMouse) { | | |||
102 | notificationTimer.stop() | | |||
103 | } else if (!containsMouse && visible) { | | |||
104 | notificationTimer.restart() | | |||
105 | } | | |||
106 | } | | |||
107 | 83 | | |||
108 | Timer { | 84 | Timer { | ||
109 | id: notificationTimer | 85 | id: notificationTimer | ||
110 | onTriggered: { | 86 | onTriggered: { | ||
111 | if (!notificationProperties.isPersistent) { | 87 | if (!notificationProperties.isPersistent) { | ||
112 | expireNotification(notificationProperties.source) | 88 | expireNotification(notificationProperties.source) | ||
113 | } | 89 | } | ||
114 | notificationPopup.notificationTimeout(); | 90 | notificationPopup.notificationTimeout(); | ||
115 | } | 91 | } | ||
116 | } | 92 | } | ||
117 | 93 | | |||
118 | NotificationItem { | 94 | onContainsMouseChanged: { | ||
119 | id: notificationItem | 95 | if (containsMouse) { | ||
96 | notificationTimer.stop() | ||||
97 | } else if (!containsMouse && visible) { | ||||
98 | notificationTimer.restart() | ||||
99 | } | ||||
100 | } | ||||
120 | 101 | | |||
121 | summary: notificationProperties.summary || "" | 102 | summary: notificationProperties.summary || "" | ||
122 | body: notificationProperties.body || "" | 103 | body: notificationProperties.body || "" | ||
123 | icon: notificationProperties.appIcon || "" | 104 | icon: notificationProperties.appIcon || "" | ||
124 | image: notificationProperties.image | 105 | image: notificationProperties.image | ||
125 | // explicit true/false or else it complains about assigning undefined to bool | 106 | // explicit true/false or else it complains about assigning undefined to bool | ||
126 | configurable: notificationProperties.configurable && !Settings.isMobile ? true : false | 107 | configurable: notificationProperties.configurable && !Settings.isMobile ? true : false | ||
127 | urls: notificationProperties.urls || [] | 108 | urls: notificationProperties.urls || [] | ||
128 | hasDefaultAction: notificationProperties.hasDefaultAction | 109 | hasDefaultAction: notificationProperties.hasDefaultAction || false | ||
129 | 110 | | |||
130 | width: Math.round(23 * units.gridUnit) | 111 | width: Math.round(23 * units.gridUnit) | ||
131 | maximumTextHeight: theme.mSize(theme.defaultFont).height * 10 | 112 | maximumTextHeight: theme.mSize(theme.defaultFont).height * 10 | ||
132 | 113 | | |||
133 | onClose: { | 114 | onClose: { | ||
134 | closeNotification(notificationProperties.source) | 115 | closeNotification(notificationProperties.source) | ||
135 | // the popup will be closed in response to sourceRemoved | 116 | // the popup will be closed in response to sourceRemoved | ||
136 | } | 117 | } | ||
137 | onConfigure: { | 118 | onConfigure: { | ||
138 | configureNotification(notificationProperties.appRealName, notificationProperties.eventId) | 119 | configureNotification(notificationProperties.appRealName, notificationProperties.eventId) | ||
139 | notificationPositioner.closePopup(notificationProperties.source); | 120 | notificationPositioner.closePopup(notificationProperties.source); | ||
140 | } | 121 | } | ||
141 | onAction: { | 122 | onAction: { | ||
142 | executeAction(notificationProperties.source, actionId) | 123 | executeAction(notificationProperties.source, actionId) | ||
143 | actions.clear() | 124 | actions.clear() | ||
144 | } | 125 | } | ||
145 | onOpenUrl: { | 126 | onOpenUrl: { | ||
146 | Qt.openUrlExternally(url) | 127 | Qt.openUrlExternally(url) | ||
147 | notificationPositioner.closePopup(notificationProperties.source); | 128 | notificationPositioner.closePopup(notificationProperties.source); | ||
148 | } | 129 | } | ||
149 | } | 130 | } | ||
150 | } | 131 | } | ||
151 | | ||||
152 | } | |