2 * Copyright (C) 2013-2016 Canonical, Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19import Ubuntu.Components 1.3
20import Ubuntu.Components.ListItems 1.3 as ListItem
21import Unity.Notifications 1.0
29 property alias iconSource: icon.fileSource
30 property alias secondaryIconSource: secondaryIcon.source
31 property alias summary: summaryLabel.text
32 property alias body: bodyLabel.text
33 property alias value: valueIndicator.value
35 property var notificationId
38 property var notification
39 property color color: theme.palette.normal.background
40 property bool fullscreen: false
41 property int maxHeight
42 property int margins: units.gu(1)
44 readonly property real defaultOpacity: 1.0
45 property bool hasMouse
46 property url background: ""
48 objectName: "background"
49 implicitHeight: type !== Notification.PlaceHolder ? (fullscreen ? maxHeight : outterColumn.height + shapedBack.anchors.topMargin + margins * 2) : 0
51 // FIXME: non-zero initially because of LP: #1354406 workaround, we want this to start at 0 upon creation eventually
52 opacity: defaultOpacity - Math.abs(x / notification.width)
54 theme: ThemeSettings {
55 name: "Ubuntu.Components.Themes.Ambiance"
58 readonly property bool expanded: type === Notification.SnapDecision && // expand only snap decisions, if...
59 (fullscreen || // - it's a fullscreen one
60 ListView.view.currentIndex === index || // - it's the one the user clicked on
61 (ListView.view.currentIndex === -1 && index == 0) // - the first one after the user closed the previous one
67 source: hints["suppress-sound"] !== "true" && hints["sound-file"] !== undefined ? hints["sound-file"] : ""
70 Component.onCompleted: {
71 if (type === Notification.PlaceHolder) {
75 // Turn on screen as needed (Powerd.Notification means the screen
76 // stays on for a shorter amount of time)
77 if (type === Notification.SnapDecision) {
78 Powerd.setStatus(Powerd.On, Powerd.SnapDecision);
79 } else if (type !== Notification.Confirmation) {
80 Powerd.setStatus(Powerd.On, Powerd.Notification);
83 // FIXME: using onCompleted because of LP: #1354406 workaround, has to be onOpacityChanged really
84 if (opacity == defaultOpacity && hints["suppress-sound"] !== "true" && sound.source !== "") {
89 Component.onDestruction: {
90 if (type === Notification.PlaceHolder) {
94 if (type === Notification.SnapDecision) {
95 Powerd.setStatus(Powerd.Off, Powerd.SnapDecision);
96 } else if (type !== Notification.Confirmation) {
97 Powerd.setStatus(Powerd.Off, Powerd.Notification);
101 function closeNotification() {
102 if (index === ListView.view.currentIndex) { // reset to get the 1st snap decision expanded
103 ListView.view.currentIndex = -1;
106 // perform the "reject" action
107 notification.notification.invokeAction(notification.actions.data(1, ActionModel.RoleActionId));
109 notification.notification.close();
113 UbuntuNumberAnimation { easing.type: Easing.OutBounce }
117 if (type === Notification.Confirmation && opacity == defaultOpacity && hints["suppress-sound"] !== "true" && sound.source !== "") {
122 onFullscreenChanged: {
124 notification.notification.urgency = Notification.Critical;
126 ListView.view.topmostIsFullscreen = fullscreen;
129 Behavior on implicitHeight {
131 UbuntuNumberAnimation {
132 duration: UbuntuAnimation.SnapDuration
136 visible: type !== Notification.PlaceHolder
141 margins: shapedBack.visible ? -units.gu(1) : -units.gu(1.5)
143 source: "../Stages/graphics/dropshadow2gu.sci"
144 opacity: notification.opacity * 0.5
150 objectName: "shapedBack"
155 leftMargin: notification.margins
156 rightMargin: notification.margins
157 topMargin: index == 0 ? notification.margins : 0
159 backgroundColor: parent.color
161 aspect: UbuntuShape.Flat
173 if (Math.abs(notification.x) > 0.75 * notification.width) {
180 anchors.fill: fullscreen ? nonShapedBack : shapedBack
182 UnityMenuModelPaths {
185 source: hints["x-canonical-private-menu-model"]
187 busNameHint: "busName"
188 actionsHint: "actions"
189 menuObjectPathHint: "menuPath"
195 property string lastNameOwner: ""
197 busName: paths.busName
198 actions: paths.actions
199 menuObjectPath: paths.menuObjectPath
200 onNameOwnerChanged: {
201 if (lastNameOwner !== "" && nameOwner === "" && notification.notification !== undefined) {
202 notification.notification.close()
204 lastNameOwner = nameOwner
212 objectName: "interactiveArea"
214 drag.target: !fullscreen ? notification : undefined
215 drag.axis: Drag.XAxis
216 drag.minimumX: -notification.width
217 drag.maximumX: notification.width
221 if (notification.type === Notification.Interactive) {
222 notification.notification.invokeAction(actionRepeater.itemAt(0).actionId)
224 notification.ListView.view.currentIndex = index;
228 if (Math.abs(notification.x) < notification.width / 2) {
231 notification.x = notification.width
237 objectName: "closeButton"
241 visible: hasMouse && (containsMouse || interactiveArea.containsMouse)
245 color: theme.palette.normal.negative
246 anchors.horizontalCenter: parent.left
247 anchors.horizontalCenterOffset: notification.parent.state === "narrow" ? notification.margins / 2 : 0
248 anchors.verticalCenter: parent.top
249 anchors.verticalCenterOffset: notification.parent.state === "narrow" ? notification.margins / 2 : 0
251 onClicked: closeNotification();
256 objectName: "outterColumn"
262 margins: !fullscreen ? notification.margins : 0
265 spacing: notification.margins
270 spacing: notification.margins
282 shaped: notification.hints["x-canonical-non-shaped-icon"] !== "true"
283 visible: iconSource !== "" && type !== Notification.Confirmation
288 width: secondaryIcon.visible ? parent.width - x - units.gu(3) : parent.width - x
289 anchors.verticalCenter: (icon.visible && !bodyLabel.visible) ? icon.verticalCenter : undefined
290 spacing: units.gu(.4)
295 objectName: "summaryLabel"
300 visible: type !== Notification.Confirmation
302 font.weight: Font.Light
303 color: theme.palette.normal.backgroundSecondaryText
304 elide: Text.ElideRight
305 textFormat: Text.PlainText
311 objectName: "bodyLabel"
316 visible: body != "" && type !== Notification.Confirmation
318 font.weight: Font.Light
319 color: theme.palette.normal.backgroundTertiaryText
321 maximumLineCount: type === Notification.SnapDecision ? 12 : 2
322 elide: Text.ElideRight
323 textFormat: Text.PlainText
331 objectName: "secondaryIcon"
334 visible: status === Image.Ready
335 fillMode: Image.PreserveAspectCrop
339 ListItem.ThinDivider {
340 visible: type === Notification.SnapDecision && notification.expanded
344 name: "toolkit_chevron-down_3gu"
345 visible: type === Notification.SnapDecision && !notification.expanded
348 anchors.horizontalCenter: parent.horizontalCenter
349 color: theme.palette.normal.base
354 objectName: "centeredIcon"
357 shaped: notification.hints["x-canonical-non-shaped-icon"] !== "true"
358 fileSource: icon.fileSource
359 visible: fileSource !== "" && type === Notification.Confirmation
360 anchors.horizontalCenter: parent.horizontalCenter
365 objectName: "valueLabel"
367 anchors.horizontalCenter: parent.horizontalCenter
368 visible: type === Notification.Confirmation && body !== ""
370 font.weight: Font.Light
371 color: theme.palette.normal.backgroundSecondaryText
372 wrapMode: Text.WordWrap
374 elide: Text.ElideRight
375 textFormat: Text.PlainText
380 objectName: "valueIndicator"
381 visible: type === Notification.Confirmation
384 showProgressPercentage: false
394 objectName: "dialogListView"
395 spacing: notification.margins
397 visible: count > 0 && (notification.expanded || notification.fullscreen)
402 top: fullscreen ? parent.top : undefined
403 bottom: fullscreen ? parent.bottom : undefined
407 model: unityMenuModel
409 NotificationMenuItemFactory {
413 left: dialogColumn.left
414 right: dialogColumn.right
417 menuModel: unityMenuModel
420 maxHeight: notification.maxHeight
421 background: notification.background
424 notification.fullscreen = Qt.binding(function() { return fullscreen; });
427 notification.notification.invokeAction(actionRepeater.itemAt(0).actionId)
441 spacing: notification.margins
443 visible: notification.type === Notification.SnapDecision && oneOverTwoRepeaterTop.count === 3 && notification.expanded
446 id: oneOverTwoRepeaterTop
448 model: notification.actions
450 id: oneOverTwoLoaderTop
452 property string actionId: id
453 property string actionLabel: label
456 id: oneOverTwoButtonTop
459 objectName: "notify_oot_button" + index
460 width: oneOverTwoCase.width
461 text: oneOverTwoLoaderTop.actionLabel
462 outline: notification.hints["x-canonical-private-affirmative-tint"] !== "true"
463 color: notification.hints["x-canonical-private-affirmative-tint"] === "true" ? theme.palette.normal.positive
464 : theme.palette.normal.foreground
465 onClicked: notification.notification.invokeAction(oneOverTwoLoaderTop.actionId)
468 sourceComponent: index == 0 ? oneOverTwoButtonTop : undefined
473 spacing: notification.margins
476 id: oneOverTwoRepeaterBottom
478 model: notification.actions
480 id: oneOverTwoLoaderBottom
482 property string actionId: id
483 property string actionLabel: label
486 id: oneOverTwoButtonBottom
489 objectName: "notify_oot_button" + index
490 width: oneOverTwoCase.width / 2 - spacing / 2
491 text: oneOverTwoLoaderBottom.actionLabel
492 outline: notification.hints["x-canonical-private-rejection-tint"] !== "true"
493 color: index == 1 && notification.hints["x-canonical-private-rejection-tint"] === "true" ? theme.palette.normal.negative
494 : theme.palette.normal.foreground
495 onClicked: notification.notification.invokeAction(oneOverTwoLoaderBottom.actionId)
498 sourceComponent: (index == 1 || index == 2) ? oneOverTwoButtonBottom : undefined
507 objectName: "buttonRow"
512 visible: notification.type === Notification.SnapDecision && actionRepeater.count > 0 && !oneOverTwoCase.visible && notification.expanded
513 spacing: notification.margins
514 layoutDirection: Qt.RightToLeft
517 id: notifySwipeButtonLoader
518 active: notification.hints["x-canonical-snap-decisions-swipe"] === "true"
520 sourceComponent: SwipeToAct {
521 objectName: "notify_swipe_button"
522 width: buttonRow.width
523 leftIconName: "call-end"
524 rightIconName: "call-start"
525 clickToAct: notification.hasMouse
527 notification.notification.invokeAction(notification.actions.data(0, ActionModel.RoleActionId))
531 notification.notification.invokeAction(notification.actions.data(1, ActionModel.RoleActionId))
538 model: notification.actions
542 property string actionId: id
543 property string actionLabel: label
544 active: !notifySwipeButtonLoader.active
550 objectName: "notify_button" + index
551 width: buttonRow.width / 2 - spacing / 2
552 text: loader.actionLabel
553 outline: (index == 0 && notification.hints["x-canonical-private-affirmative-tint"] !== "true") ||
554 (index == 1 && notification.hints["x-canonical-private-rejection-tint"] !== "true")
556 var result = theme.palette.normal.foreground;
557 if (index == 0 && notification.hints["x-canonical-private-affirmative-tint"] === "true") {
558 result = theme.palette.normal.positive;
560 if (index == 1 && notification.hints["x-canonical-private-rejection-tint"] === "true") {
561 result = theme.palette.normal.negative;
565 onClicked: notification.notification.invokeAction(loader.actionId)
568 sourceComponent: (index == 0 || index == 1) ? actionButton : undefined
575 objectName: "notify_button2"
582 visible: notification.type === Notification.SnapDecision && actionRepeater.count > 3 && !oneOverTwoCase.visible && notification.expanded
583 model: notification.actions
587 notification.notification.invokeAction(id)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list