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: notification.notification && typeof notification.notification.fullscreen != "undefined" ?
41 notification.notification.fullscreen : false // fullscreen prop only exists in the mock
42 property int maxHeight
43 property int margins: units.gu(1)
45 readonly property real defaultOpacity: 1.0
46 property bool hasMouse
47 property url background: ""
49 objectName: "background"
50 implicitHeight: type !== Notification.PlaceHolder ? (fullscreen ? maxHeight : outterColumn.height + shapedBack.anchors.topMargin + margins * 2) : 0
52 // FIXME: non-zero initially because of LP: #1354406 workaround, we want this to start at 0 upon creation eventually
53 opacity: defaultOpacity - Math.abs(x / notification.width)
55 theme: ThemeSettings {
56 name: "Ubuntu.Components.Themes.Ambiance"
59 readonly property bool expanded: type === Notification.SnapDecision && // expand only snap decisions, if...
60 (fullscreen || // - it's a fullscreen one
61 ListView.view.currentIndex === index || // - it's the one the user clicked on
62 (ListView.view.currentIndex === -1 && index == 0) // - the first one after the user closed the previous one
68 source: hints["suppress-sound"] !== "true" && hints["sound-file"] !== undefined ? hints["sound-file"] : ""
71 Component.onCompleted: {
72 if (type === Notification.PlaceHolder) {
76 // Turn on screen as needed (Powerd.Notification means the screen
77 // stays on for a shorter amount of time)
78 if (type === Notification.SnapDecision) {
79 Powerd.setStatus(Powerd.On, Powerd.SnapDecision);
80 } else if (type !== Notification.Confirmation) {
81 Powerd.setStatus(Powerd.On, Powerd.Notification);
84 // FIXME: using onCompleted because of LP: #1354406 workaround, has to be onOpacityChanged really
85 if (opacity == defaultOpacity && hints["suppress-sound"] !== "true" && sound.source !== "") {
90 Component.onDestruction: {
91 if (type === Notification.PlaceHolder) {
95 if (type === Notification.SnapDecision) {
96 Powerd.setStatus(Powerd.Off, Powerd.SnapDecision);
97 } else if (type !== Notification.Confirmation) {
98 Powerd.setStatus(Powerd.Off, Powerd.Notification);
102 function closeNotification() {
103 if (index === ListView.view.currentIndex) { // reset to get the 1st snap decision expanded
104 ListView.view.currentIndex = -1;
107 // perform the "reject" action
108 notification.notification.invokeAction(notification.actions.data(1, ActionModel.RoleActionId));
110 notification.notification.close();
114 UbuntuNumberAnimation { easing.type: Easing.OutBounce }
118 if (type === Notification.Confirmation && opacity == defaultOpacity && hints["suppress-sound"] !== "true" && sound.source !== "") {
123 onFullscreenChanged: {
125 notification.notification.urgency = Notification.Critical;
127 ListView.view.topmostIsFullscreen = fullscreen;
130 Behavior on implicitHeight {
132 UbuntuNumberAnimation {
133 duration: UbuntuAnimation.SnapDuration
137 visible: type !== Notification.PlaceHolder
142 margins: shapedBack.visible ? -units.gu(1) : -units.gu(1.5)
144 source: "../Stages/graphics/dropshadow2gu.sci"
145 opacity: notification.opacity * 0.5
151 objectName: "shapedBack"
156 leftMargin: notification.margins
157 rightMargin: notification.margins
158 topMargin: index == 0 ? notification.margins : 0
160 backgroundColor: parent.color
162 aspect: UbuntuShape.Flat
174 if (Math.abs(notification.x) > 0.75 * notification.width) {
181 anchors.fill: fullscreen ? nonShapedBack : shapedBack
183 UnityMenuModelPaths {
186 source: hints["x-canonical-private-menu-model"]
188 busNameHint: "busName"
189 actionsHint: "actions"
190 menuObjectPathHint: "menuPath"
196 property string lastNameOwner: ""
198 busName: paths.busName
199 actions: paths.actions
200 menuObjectPath: paths.menuObjectPath
201 onNameOwnerChanged: {
202 if (lastNameOwner !== "" && nameOwner === "" && notification.notification !== undefined) {
203 notification.notification.close()
205 lastNameOwner = nameOwner
213 objectName: "interactiveArea"
215 drag.target: !fullscreen ? notification : undefined
216 drag.axis: Drag.XAxis
217 drag.minimumX: -notification.width
218 drag.maximumX: notification.width
222 if (notification.type === Notification.Interactive) {
223 notification.notification.invokeAction(actionRepeater.itemAt(0).actionId)
225 notification.ListView.view.currentIndex = index;
229 if (Math.abs(notification.x) < notification.width / 2) {
232 notification.x = notification.width
238 objectName: "closeButton"
242 visible: hasMouse && (containsMouse || interactiveArea.containsMouse)
246 color: theme.palette.normal.negative
247 anchors.horizontalCenter: parent.left
248 anchors.horizontalCenterOffset: notification.parent.state === "narrow" ? notification.margins / 2 : 0
249 anchors.verticalCenter: parent.top
250 anchors.verticalCenterOffset: notification.parent.state === "narrow" ? notification.margins / 2 : 0
252 onClicked: closeNotification();
257 objectName: "outterColumn"
263 margins: !fullscreen ? notification.margins : 0
266 spacing: notification.margins
271 spacing: notification.margins
283 shaped: notification.hints["x-canonical-non-shaped-icon"] !== "true"
284 visible: iconSource !== "" && type !== Notification.Confirmation
289 width: secondaryIcon.visible ? parent.width - x - units.gu(3) : parent.width - x
290 anchors.verticalCenter: (icon.visible && !bodyLabel.visible) ? icon.verticalCenter : undefined
291 spacing: units.gu(.4)
296 objectName: "summaryLabel"
301 visible: type !== Notification.Confirmation
303 font.weight: Font.Light
304 color: theme.palette.normal.backgroundSecondaryText
305 elide: Text.ElideRight
306 textFormat: Text.PlainText
312 objectName: "bodyLabel"
317 visible: body != "" && type !== Notification.Confirmation
319 font.weight: Font.Light
320 color: theme.palette.normal.backgroundTertiaryText
322 maximumLineCount: type === Notification.SnapDecision ? 12 : 2
323 elide: Text.ElideRight
324 textFormat: Text.PlainText
332 objectName: "secondaryIcon"
335 visible: status === Image.Ready
336 fillMode: Image.PreserveAspectCrop
340 ListItem.ThinDivider {
341 visible: type === Notification.SnapDecision && notification.expanded
345 name: "toolkit_chevron-down_3gu"
346 visible: type === Notification.SnapDecision && !notification.expanded
349 anchors.horizontalCenter: parent.horizontalCenter
350 color: theme.palette.normal.base
355 objectName: "centeredIcon"
358 shaped: notification.hints["x-canonical-non-shaped-icon"] !== "true"
359 fileSource: icon.fileSource
360 visible: fileSource !== "" && type === Notification.Confirmation
361 anchors.horizontalCenter: parent.horizontalCenter
366 objectName: "valueLabel"
368 anchors.horizontalCenter: parent.horizontalCenter
369 visible: type === Notification.Confirmation && body !== ""
371 font.weight: Font.Light
372 color: theme.palette.normal.backgroundSecondaryText
373 wrapMode: Text.WordWrap
375 elide: Text.ElideRight
376 textFormat: Text.PlainText
381 objectName: "valueIndicator"
382 visible: type === Notification.Confirmation
385 showProgressPercentage: false
395 objectName: "dialogListView"
396 spacing: notification.margins
398 visible: count > 0 && (notification.expanded || notification.fullscreen)
403 top: fullscreen ? parent.top : undefined
404 bottom: fullscreen ? parent.bottom : undefined
408 model: unityMenuModel
410 NotificationMenuItemFactory {
414 left: dialogColumn.left
415 right: dialogColumn.right
418 menuModel: unityMenuModel
421 maxHeight: notification.maxHeight
422 background: notification.background
425 notification.fullscreen = Qt.binding(function() { return fullscreen; });
428 notification.notification.invokeAction(actionRepeater.itemAt(0).actionId)
442 spacing: notification.margins
444 visible: notification.type === Notification.SnapDecision && oneOverTwoRepeaterTop.count === 3 && notification.expanded
447 id: oneOverTwoRepeaterTop
449 model: notification.actions
451 id: oneOverTwoLoaderTop
453 property string actionId: id
454 property string actionLabel: label
457 id: oneOverTwoButtonTop
460 objectName: "notify_oot_button" + index
461 width: oneOverTwoCase.width
462 text: oneOverTwoLoaderTop.actionLabel
463 outline: notification.hints["x-canonical-private-affirmative-tint"] !== "true"
464 color: notification.hints["x-canonical-private-affirmative-tint"] === "true" ? theme.palette.normal.positive
465 : theme.palette.normal.foreground
466 onClicked: notification.notification.invokeAction(oneOverTwoLoaderTop.actionId)
469 sourceComponent: index == 0 ? oneOverTwoButtonTop : undefined
474 spacing: notification.margins
477 id: oneOverTwoRepeaterBottom
479 model: notification.actions
481 id: oneOverTwoLoaderBottom
483 property string actionId: id
484 property string actionLabel: label
487 id: oneOverTwoButtonBottom
490 objectName: "notify_oot_button" + index
491 width: oneOverTwoCase.width / 2 - spacing / 2
492 text: oneOverTwoLoaderBottom.actionLabel
493 outline: notification.hints["x-canonical-private-rejection-tint"] !== "true"
494 color: index == 1 && notification.hints["x-canonical-private-rejection-tint"] === "true" ? theme.palette.normal.negative
495 : theme.palette.normal.foreground
496 onClicked: notification.notification.invokeAction(oneOverTwoLoaderBottom.actionId)
499 sourceComponent: (index == 1 || index == 2) ? oneOverTwoButtonBottom : undefined
508 objectName: "buttonRow"
513 visible: notification.type === Notification.SnapDecision && actionRepeater.count > 0 && !oneOverTwoCase.visible && notification.expanded
514 spacing: notification.margins
515 layoutDirection: Qt.RightToLeft
518 id: notifySwipeButtonLoader
519 active: notification.hints["x-canonical-snap-decisions-swipe"] === "true"
521 sourceComponent: SwipeToAct {
522 objectName: "notify_swipe_button"
523 width: buttonRow.width
524 leftIconName: "call-end"
525 rightIconName: "call-start"
526 clickToAct: notification.hasMouse
528 notification.notification.invokeAction(notification.actions.data(0, ActionModel.RoleActionId))
532 notification.notification.invokeAction(notification.actions.data(1, ActionModel.RoleActionId))
539 model: notification.actions
543 property string actionId: id
544 property string actionLabel: label
545 active: !notifySwipeButtonLoader.active
551 objectName: "notify_button" + index
552 width: buttonRow.width / 2 - spacing / 2
553 text: loader.actionLabel
554 outline: (index == 0 && notification.hints["x-canonical-private-affirmative-tint"] !== "true") ||
555 (index == 1 && notification.hints["x-canonical-private-rejection-tint"] !== "true")
557 var result = theme.palette.normal.foreground;
558 if (index == 0 && notification.hints["x-canonical-private-affirmative-tint"] === "true") {
559 result = theme.palette.normal.positive;
561 if (index == 1 && notification.hints["x-canonical-private-rejection-tint"] === "true") {
562 result = theme.palette.normal.negative;
566 onClicked: notification.notification.invokeAction(loader.actionId)
569 sourceComponent: (index == 0 || index == 1) ? actionButton : undefined
576 objectName: "notify_button2"
583 visible: notification.type === Notification.SnapDecision && actionRepeater.count > 3 && !oneOverTwoCase.visible && notification.expanded
584 model: notification.actions
588 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