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 > 1) {
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 (index === ListView.view.currentIndex) { // reset to get the 1st snap decision expanded
103 ListView.view.currentIndex = -1;
106 if (notification.actions.count > 1) { // 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 !== "") {
123 UbuntuNumberAnimation {
124 duration: UbuntuAnimation.SnapDuration
128 visible: type !== Notification.PlaceHolder
133 margins: shapedBack.visible ? -units.gu(1) : -units.gu(1.5)
135 source: "../Stages/graphics/dropshadow2gu.sci"
136 opacity: notification.opacity * 0.5
142 objectName: "shapedBack"
147 leftMargin: notification.margins
148 rightMargin: notification.margins
149 topMargin: index == 0 ? notification.margins : 0
151 backgroundColor: parent.color
153 aspect: UbuntuShape.Flat
165 if (Math.abs(notification.x) > 0.75 * notification.width) {
172 anchors.fill: fullscreen ? nonShapedBack : shapedBack
174 UnityMenuModelPaths {
177 source: hints["x-canonical-private-menu-model"]
179 busNameHint: "busName"
180 actionsHint: "actions"
181 menuObjectPathHint: "menuPath"
187 property string lastNameOwner: ""
189 busName: paths.busName
190 actions: paths.actions
191 menuObjectPath: paths.menuObjectPath
192 onNameOwnerChanged: {
193 if (lastNameOwner !== "" && nameOwner === "" && notification.notification !== undefined) {
194 notification.notification.close()
196 lastNameOwner = nameOwner
204 objectName: "interactiveArea"
206 drag.target: notification
207 drag.axis: Drag.XAxis
208 drag.minimumX: -notification.width
209 drag.maximumX: notification.width
213 if (notification.type === Notification.Interactive) {
214 notification.notification.invokeAction(actionRepeater.itemAt(0).actionId)
216 notificationList.currentIndex = index;
220 if (Math.abs(notification.x) < notification.width / 2) {
223 notification.x = notification.width
229 objectName: "closeButton"
233 visible: hasMouse && (containsMouse || interactiveArea.containsMouse)
237 color: theme.palette.normal.negative
238 anchors.horizontalCenter: parent.left
239 anchors.horizontalCenterOffset: notification.parent.state === "narrow" ? notification.margins / 2 : 0
240 anchors.verticalCenter: parent.top
241 anchors.verticalCenterOffset: notification.parent.state === "narrow" ? notification.margins / 2 : 0
243 onClicked: closeNotification();
248 objectName: "outterColumn"
254 margins: !fullscreen ? notification.margins : 0
257 spacing: notification.margins
262 spacing: notification.margins
274 shaped: notification.hints["x-canonical-non-shaped-icon"] !== "true"
275 visible: iconSource !== "" && type !== Notification.Confirmation
280 width: secondaryIcon.visible ? parent.width - x - units.gu(3) : parent.width - x
281 anchors.verticalCenter: (icon.visible && !bodyLabel.visible) ? icon.verticalCenter : undefined
282 spacing: units.gu(.4)
287 objectName: "summaryLabel"
292 visible: type !== Notification.Confirmation
294 font.weight: Font.Light
295 color: theme.palette.normal.backgroundSecondaryText
296 elide: Text.ElideRight
297 textFormat: Text.PlainText
303 objectName: "bodyLabel"
308 visible: body != "" && type !== Notification.Confirmation
310 font.weight: Font.Light
311 color: theme.palette.normal.backgroundTertiaryText
313 maximumLineCount: type === Notification.SnapDecision ? 12 : 2
314 elide: Text.ElideRight
315 textFormat: Text.PlainText
323 objectName: "secondaryIcon"
326 visible: status === Image.Ready
327 fillMode: Image.PreserveAspectCrop
331 ListItem.ThinDivider {
332 visible: type === Notification.SnapDecision && notification.expanded
336 name: "toolkit_chevron-down_3gu"
337 visible: type === Notification.SnapDecision && !notification.expanded
340 anchors.horizontalCenter: parent.horizontalCenter
341 color: theme.palette.normal.base
346 objectName: "centeredIcon"
349 shaped: notification.hints["x-canonical-non-shaped-icon"] !== "true"
350 fileSource: icon.fileSource
351 visible: fileSource !== "" && type === Notification.Confirmation
352 anchors.horizontalCenter: parent.horizontalCenter
357 objectName: "valueLabel"
359 anchors.horizontalCenter: parent.horizontalCenter
360 visible: type === Notification.Confirmation && body !== ""
362 font.weight: Font.Light
363 color: theme.palette.normal.backgroundSecondaryText
364 wrapMode: Text.WordWrap
366 elide: Text.ElideRight
367 textFormat: Text.PlainText
372 objectName: "valueIndicator"
373 visible: type === Notification.Confirmation
376 showProgressPercentage: false
386 objectName: "dialogListView"
387 spacing: notification.margins
394 top: fullscreen ? parent.top : undefined
395 bottom: fullscreen ? parent.bottom : undefined
399 model: unityMenuModel
401 NotificationMenuItemFactory {
405 left: dialogColumn.left
406 right: dialogColumn.right
409 menuModel: unityMenuModel
412 maxHeight: notification.maxHeight
413 background: notification.background
416 notification.fullscreen = Qt.binding(function() { return fullscreen; });
419 notification.notification.invokeAction(actionRepeater.itemAt(0).actionId)
433 spacing: notification.margins
435 visible: notification.type === Notification.SnapDecision && oneOverTwoRepeaterTop.count === 3 && notification.expanded
438 id: oneOverTwoRepeaterTop
440 model: notification.actions
442 id: oneOverTwoLoaderTop
444 property string actionId: id
445 property string actionLabel: label
448 id: oneOverTwoButtonTop
451 objectName: "notify_oot_button" + index
452 width: oneOverTwoCase.width
453 text: oneOverTwoLoaderTop.actionLabel
454 outline: notification.hints["x-canonical-private-affirmative-tint"] !== "true"
455 color: notification.hints["x-canonical-private-affirmative-tint"] === "true" ? theme.palette.normal.positive
456 : theme.palette.normal.foreground
457 onClicked: notification.notification.invokeAction(oneOverTwoLoaderTop.actionId)
460 sourceComponent: index == 0 ? oneOverTwoButtonTop : undefined
465 spacing: notification.margins
468 id: oneOverTwoRepeaterBottom
470 model: notification.actions
472 id: oneOverTwoLoaderBottom
474 property string actionId: id
475 property string actionLabel: label
478 id: oneOverTwoButtonBottom
481 objectName: "notify_oot_button" + index
482 width: oneOverTwoCase.width / 2 - spacing / 2
483 text: oneOverTwoLoaderBottom.actionLabel
484 outline: notification.hints["x-canonical-private-rejection-tint"] !== "true"
485 color: index == 1 && notification.hints["x-canonical-private-rejection-tint"] === "true" ? theme.palette.normal.negative
486 : theme.palette.normal.foreground
487 onClicked: notification.notification.invokeAction(oneOverTwoLoaderBottom.actionId)
490 sourceComponent: (index == 1 || index == 2) ? oneOverTwoButtonBottom : undefined
499 objectName: "buttonRow"
504 visible: notification.type === Notification.SnapDecision && actionRepeater.count > 0 && !oneOverTwoCase.visible && notification.expanded
505 spacing: notification.margins
506 layoutDirection: Qt.RightToLeft
509 id: notifySwipeButtonLoader
510 active: notification.hints["x-canonical-snap-decisions-swipe"] === "true"
512 sourceComponent: SwipeToAct {
513 objectName: "notify_swipe_button"
514 width: buttonRow.width
515 leftIconName: "call-end"
516 rightIconName: "call-start"
517 clickToAct: notification.hasMouse
519 notification.notification.invokeAction(notification.actions.data(0, ActionModel.RoleActionId))
523 notification.notification.invokeAction(notification.actions.data(1, ActionModel.RoleActionId))
530 model: notification.actions
534 property string actionId: id
535 property string actionLabel: label
536 active: !notifySwipeButtonLoader.active
542 objectName: "notify_button" + index
543 width: buttonRow.width / 2 - spacing / 2
544 text: loader.actionLabel
545 outline: (index == 0 && notification.hints["x-canonical-private-affirmative-tint"] !== "true") ||
546 (index == 1 && notification.hints["x-canonical-private-rejection-tint"] !== "true")
548 var result = theme.palette.normal.foreground;
549 if (index == 0 && notification.hints["x-canonical-private-affirmative-tint"] === "true") {
550 result = theme.palette.normal.positive;
552 if (index == 1 && notification.hints["x-canonical-private-rejection-tint"] === "true") {
553 result = theme.palette.normal.negative;
557 onClicked: notification.notification.invokeAction(loader.actionId)
560 sourceComponent: (index == 0 || index == 1) ? actionButton : undefined
567 objectName: "notify_button2"
574 visible: notification.type === Notification.SnapDecision && actionRepeater.count > 3 && !oneOverTwoCase.visible && notification.expanded
575 model: notification.actions
579 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