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: {
61 if (type === Notification.SnapDecision) {
62 if (ListView.view.currentIndex === index) {
65 if (ListView.view.count > 2) {
66 if (ListView.view.currentIndex === -1 && index == 1) {
83 source: hints["suppress-sound"] !== "true" && hints["sound-file"] !== undefined ? hints["sound-file"] : ""
86 Component.onCompleted: {
87 // Turn on screen as needed (Powerd.Notification means the screen
88 // stays on for a shorter amount of time)
89 if (type === Notification.SnapDecision) {
90 Powerd.setStatus(Powerd.On, Powerd.SnapDecision);
91 } else if (type !== Notification.Confirmation) {
92 Powerd.setStatus(Powerd.On, Powerd.Notification);
95 // FIXME: using onCompleted because of LP: #1354406 workaround, has to be onOpacityChanged really
96 if (opacity == defaultOpacity && hints["suppress-sound"] !== "true" && sound.source !== "") {
101 function closeNotification() {
102 if (notification.actions.count > 1) { // perform the "reject" action
103 notification.notification.invokeAction(notification.actions.data(1, ActionModel.RoleActionId));
105 notification.notification.close();
109 UbuntuNumberAnimation { easing.type: Easing.OutBounce }
113 if (type === Notification.Confirmation && opacity == defaultOpacity && hints["suppress-sound"] !== "true" && sound.source !== "") {
119 UbuntuNumberAnimation {
120 duration: UbuntuAnimation.SnapDuration
124 visible: type !== Notification.PlaceHolder
129 margins: shapedBack.visible ? -units.gu(1) : -units.gu(1.5)
131 source: "../Stages/graphics/dropshadow2gu.sci"
132 opacity: notification.opacity * 0.5
138 objectName: "shapedBack"
143 leftMargin: notification.margins
144 rightMargin: notification.margins
145 topMargin: index == 0 ? notification.margins : 0
147 backgroundColor: parent.color
149 aspect: UbuntuShape.Flat
161 if (Math.abs(notification.x) > 0.75 * notification.width) {
168 anchors.fill: fullscreen ? nonShapedBack : shapedBack
170 UnityMenuModelPaths {
173 source: hints["x-canonical-private-menu-model"]
175 busNameHint: "busName"
176 actionsHint: "actions"
177 menuObjectPathHint: "menuPath"
183 property string lastNameOwner: ""
185 busName: paths.busName
186 actions: paths.actions
187 menuObjectPath: paths.menuObjectPath
188 onNameOwnerChanged: {
189 if (lastNameOwner !== "" && nameOwner === "" && notification.notification !== undefined) {
190 notification.notification.close()
192 lastNameOwner = nameOwner
200 objectName: "interactiveArea"
202 drag.target: notification
203 drag.axis: Drag.XAxis
204 drag.minimumX: -notification.width
205 drag.maximumX: notification.width
209 if (notification.type === Notification.Interactive) {
210 notification.notification.invokeAction(actionRepeater.itemAt(0).actionId)
212 notificationList.currentIndex = index;
216 if (Math.abs(notification.x) < notification.width / 2) {
219 notification.x = notification.width
225 objectName: "closeButton"
229 visible: hasMouse && (containsMouse || interactiveArea.containsMouse)
233 color: theme.palette.normal.negative
234 anchors.horizontalCenter: parent.left
235 anchors.horizontalCenterOffset: notification.parent.state === "narrow" ? notification.margins / 2 : 0
236 anchors.verticalCenter: parent.top
237 anchors.verticalCenterOffset: notification.parent.state === "narrow" ? notification.margins / 2 : 0
239 onClicked: closeNotification();
244 objectName: "outterColumn"
250 margins: !fullscreen ? notification.margins : 0
253 spacing: notification.margins
258 spacing: notification.margins
270 shaped: notification.hints["x-canonical-non-shaped-icon"] !== "true"
271 visible: iconSource !== "" && type !== Notification.Confirmation
276 width: secondaryIcon.visible ? parent.width - x - units.gu(3) : parent.width - x
277 anchors.verticalCenter: (icon.visible && !bodyLabel.visible) ? icon.verticalCenter : undefined
278 spacing: units.gu(.4)
283 objectName: "summaryLabel"
288 visible: type !== Notification.Confirmation
290 font.weight: Font.Light
291 color: theme.palette.normal.backgroundSecondaryText
292 elide: Text.ElideRight
293 textFormat: Text.PlainText
299 objectName: "bodyLabel"
304 visible: body != "" && type !== Notification.Confirmation
306 font.weight: Font.Light
307 color: theme.palette.normal.backgroundTertiaryText
309 maximumLineCount: type === Notification.SnapDecision ? 12 : 2
310 elide: Text.ElideRight
311 textFormat: Text.PlainText
319 objectName: "secondaryIcon"
322 visible: status === Image.Ready
323 fillMode: Image.PreserveAspectCrop
327 ListItem.ThinDivider {
328 visible: type === Notification.SnapDecision && notification.expanded
332 name: "toolkit_chevron-down_3gu"
333 visible: type === Notification.SnapDecision && !notification.expanded
336 anchors.horizontalCenter: parent.horizontalCenter
337 color: theme.palette.normal.base
342 objectName: "centeredIcon"
345 shaped: notification.hints["x-canonical-non-shaped-icon"] !== "true"
346 fileSource: icon.fileSource
347 visible: fileSource !== "" && type === Notification.Confirmation
348 anchors.horizontalCenter: parent.horizontalCenter
353 objectName: "valueLabel"
355 anchors.horizontalCenter: parent.horizontalCenter
356 visible: type === Notification.Confirmation && body !== ""
358 font.weight: Font.Light
359 color: theme.palette.normal.backgroundSecondaryText
360 wrapMode: Text.WordWrap
362 elide: Text.ElideRight
363 textFormat: Text.PlainText
368 objectName: "valueIndicator"
369 visible: type === Notification.Confirmation
372 showProgressPercentage: false
382 objectName: "dialogListView"
383 spacing: notification.margins
390 top: fullscreen ? parent.top : undefined
391 bottom: fullscreen ? parent.bottom : undefined
395 model: unityMenuModel
397 NotificationMenuItemFactory {
401 left: dialogColumn.left
402 right: dialogColumn.right
405 menuModel: unityMenuModel
408 maxHeight: notification.maxHeight
409 background: notification.background
412 notification.fullscreen = Qt.binding(function() { return fullscreen; });
415 notification.notification.invokeAction(actionRepeater.itemAt(0).actionId)
429 spacing: notification.margins
431 visible: notification.type === Notification.SnapDecision && oneOverTwoRepeaterTop.count === 3 && notification.expanded
434 id: oneOverTwoRepeaterTop
436 model: notification.actions
438 id: oneOverTwoLoaderTop
440 property string actionId: id
441 property string actionLabel: label
444 id: oneOverTwoButtonTop
447 objectName: "notify_oot_button" + index
448 width: oneOverTwoCase.width
449 text: oneOverTwoLoaderTop.actionLabel
450 outline: notification.hints["x-canonical-private-affirmative-tint"] !== "true"
451 color: notification.hints["x-canonical-private-affirmative-tint"] === "true" ? theme.palette.normal.positive
452 : theme.palette.normal.foreground
453 onClicked: notification.notification.invokeAction(oneOverTwoLoaderTop.actionId)
456 sourceComponent: index == 0 ? oneOverTwoButtonTop : undefined
461 spacing: notification.margins
464 id: oneOverTwoRepeaterBottom
466 model: notification.actions
468 id: oneOverTwoLoaderBottom
470 property string actionId: id
471 property string actionLabel: label
474 id: oneOverTwoButtonBottom
477 objectName: "notify_oot_button" + index
478 width: oneOverTwoCase.width / 2 - spacing / 2
479 text: oneOverTwoLoaderBottom.actionLabel
480 outline: notification.hints["x-canonical-private-rejection-tint"] !== "true"
481 color: index == 1 && notification.hints["x-canonical-private-rejection-tint"] === "true" ? theme.palette.normal.negative
482 : theme.palette.normal.foreground
483 onClicked: notification.notification.invokeAction(oneOverTwoLoaderBottom.actionId)
486 sourceComponent: (index == 1 || index == 2) ? oneOverTwoButtonBottom : undefined
495 objectName: "buttonRow"
500 visible: notification.type === Notification.SnapDecision && actionRepeater.count > 0 && !oneOverTwoCase.visible && notification.expanded
501 spacing: notification.margins
502 layoutDirection: Qt.RightToLeft
505 id: notifySwipeButtonLoader
506 active: notification.hints["x-canonical-snap-decisions-swipe"] === "true"
508 sourceComponent: SwipeToAct {
509 objectName: "notify_swipe_button"
510 width: buttonRow.width
511 leftIconName: "call-end"
512 rightIconName: "call-start"
513 clickToAct: notification.hasMouse
515 notification.notification.invokeAction(notification.actions.data(0, ActionModel.RoleActionId))
519 notification.notification.invokeAction(notification.actions.data(1, ActionModel.RoleActionId))
526 model: notification.actions
530 property string actionId: id
531 property string actionLabel: label
532 active: !notifySwipeButtonLoader.active
538 objectName: "notify_button" + index
539 width: buttonRow.width / 2 - spacing / 2
540 text: loader.actionLabel
541 outline: (index == 0 && notification.hints["x-canonical-private-affirmative-tint"] !== "true") ||
542 (index == 1 && notification.hints["x-canonical-private-rejection-tint"] !== "true")
544 var result = theme.palette.normal.foreground;
545 if (index == 0 && notification.hints["x-canonical-private-affirmative-tint"] === "true") {
546 result = theme.palette.normal.positive;
548 if (index == 1 && notification.hints["x-canonical-private-rejection-tint"] === "true") {
549 result = theme.palette.normal.negative;
553 onClicked: notification.notification.invokeAction(loader.actionId)
556 sourceComponent: (index == 0 || index == 1) ? actionButton : undefined
563 objectName: "notify_button2"
570 visible: notification.type === Notification.SnapDecision && actionRepeater.count > 3 && !oneOverTwoCase.visible && notification.expanded
571 model: notification.actions
575 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