Changeset View
Changeset View
Standalone View
Standalone View
applets/notifications/package/contents/ui/NotificationPopup.qml
Show First 20 Lines • Show All 140 Lines • ▼ Show 20 Line(s) | 140 | onTriggered: { | |||
---|---|---|---|---|---|
141 | if (notificationPopup.dismissTimeout) { | 141 | if (notificationPopup.dismissTimeout) { | ||
142 | notificationPopup.dismissClicked(); | 142 | notificationPopup.dismissClicked(); | ||
143 | } else { | 143 | } else { | ||
144 | notificationPopup.expired(); | 144 | notificationPopup.expired(); | ||
145 | } | 145 | } | ||
146 | } | 146 | } | ||
147 | } | 147 | } | ||
148 | 148 | | |||
149 | Timer { | | |||
150 | id: timeoutIndicatorDelayTimer | | |||
151 | // only show indicator for the last ten seconds of timeout | | |||
152 | readonly property int remainingTimeout: 10000 | | |||
153 | interval: Math.max(0, timer.interval - remainingTimeout) | | |||
154 | running: interval > 0 && timer.running | | |||
155 | } | | |||
156 | | ||||
157 | Rectangle { | | |||
158 | id: timeoutIndicatorRect | | |||
159 | anchors { | | |||
160 | right: parent.right | | |||
161 | rightMargin: -notificationPopup.margins.right | | |||
162 | bottom: parent.bottom | | |||
163 | bottomMargin: -notificationPopup.margins.bottom | | |||
164 | } | | |||
165 | width: units.devicePixelRatio * 3 | | |||
166 | color: theme.highlightColor | | |||
167 | opacity: timeoutIndicatorAnimation.running ? 0.6 : 0 | | |||
168 | visible: units.longDuration > 1 | | |||
169 | Behavior on opacity { | | |||
170 | NumberAnimation { | 149 | NumberAnimation { | ||
171 | duration: units.longDuration | 150 | target: notificationItem | ||
172 | } | 151 | property: "remainingTime" | ||
173 | } | 152 | from: timer.interval | ||
174 | | ||||
175 | NumberAnimation { | | |||
176 | id: timeoutIndicatorAnimation | | |||
177 | target: timeoutIndicatorRect | | |||
178 | property: "height" | | |||
179 | from: area.height + notificationPopup.margins.top + notificationPopup.margins.bottom | | |||
180 | to: 0 | 153 | to: 0 | ||
181 | duration: Math.min(timer.interval, timeoutIndicatorDelayTimer.remainingTimeout) | 154 | duration: timer.interval | ||
182 | running: timer.running && !timeoutIndicatorDelayTimer.running && units.longDuration > 1 | 155 | running: timer.running && units.longDuration > 1 | ||
183 | } | | |||
184 | } | 156 | } | ||
185 | 157 | | |||
186 | NotificationItem { | 158 | NotificationItem { | ||
187 | id: notificationItem | 159 | id: notificationItem | ||
188 | // let the item bleed into the dialog margins so the close button margins cancel out | 160 | // let the item bleed into the dialog margins so the close button margins cancel out | ||
189 | y: closable || dismissable || configurable ? -notificationPopup.margins.top : 0 | 161 | y: closable || dismissable || configurable ? -notificationPopup.margins.top : 0 | ||
190 | headingRightPadding: -notificationPopup.margins.right | 162 | headingRightPadding: -notificationPopup.margins.right | ||
191 | width: parent.width | 163 | width: parent.width | ||
192 | hovered: area.containsMouse | 164 | hovered: area.containsMouse | ||
193 | maximumLineCount: 8 | 165 | maximumLineCount: 8 | ||
194 | bodyCursorShape: notificationPopup.hasDefaultAction ? Qt.PointingHandCursor : 0 | 166 | bodyCursorShape: notificationPopup.hasDefaultAction ? Qt.PointingHandCursor : 0 | ||
195 | 167 | | |||
196 | thumbnailLeftPadding: -notificationPopup.margins.left | 168 | thumbnailLeftPadding: -notificationPopup.margins.left | ||
197 | thumbnailRightPadding: -notificationPopup.margins.right | 169 | thumbnailRightPadding: -notificationPopup.margins.right | ||
198 | thumbnailTopPadding: -notificationPopup.margins.top | 170 | thumbnailTopPadding: -notificationPopup.margins.top | ||
199 | thumbnailBottomPadding: -notificationPopup.margins.bottom | 171 | thumbnailBottomPadding: -notificationPopup.margins.bottom | ||
200 | 172 | | |||
173 | timeout: timer.running ? timer.interval : 0 | ||||
174 | | ||||
201 | closable: true | 175 | closable: true | ||
202 | onBodyClicked: { | 176 | onBodyClicked: { | ||
203 | if (area.acceptedButtons & mouse.button) { | 177 | if (area.acceptedButtons & mouse.button) { | ||
204 | area.clicked(null /*mouse*/); | 178 | area.clicked(null /*mouse*/); | ||
205 | } | 179 | } | ||
206 | } | 180 | } | ||
207 | onCloseClicked: notificationPopup.closeClicked() | 181 | onCloseClicked: notificationPopup.closeClicked() | ||
208 | onDismissClicked: notificationPopup.dismissClicked() | 182 | onDismissClicked: notificationPopup.dismissClicked() | ||
Show All 12 Lines |