2 * Copyright (C) 2013, 2015 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/>.
18import QtMultimedia 5.0
20import Ubuntu.Components 1.2
21import Unity.Notifications 1.0
24import Ubuntu.Components.ListItems 0.1 as ListItem
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
40 property bool fullscreen: false
41 property int maxHeight
43 readonly property bool draggable: (type === Notification.SnapDecision && state === "contracted") || type === Notification.Interactive || type === Notification.Ephemeral
44 readonly property bool darkOnBright: panel.indicators.shown || type === Notification.SnapDecision
45 readonly property color red: "#fc4949"
46 readonly property color green: "#3fb24f"
47 readonly property color sdLightGrey: "#eaeaea"
48 readonly property color sdDarkGrey: "#dddddd"
49 readonly property color sdFontColor: "#5d5d5d"
50 readonly property real contentSpacing: units.gu(2)
51 readonly property bool canBeClosed: type === Notification.Ephemeral
52 property bool hasMouse
53 property url background: ""
55 objectName: "background"
56 implicitHeight: type !== Notification.PlaceHolder ? (fullscreen ? maxHeight : outterColumn.height - shapedBack.anchors.topMargin + contentSpacing * 2) : 0
58 color: (type === Notification.Confirmation && notificationList.useModal && !greeter.shown) || darkOnBright ? sdLightGrey : Qt.rgba(0.132, 0.117, 0.109, 0.97)
59 opacity: 1 - (x / notification.width) // FIXME: non-zero initially because of LP: #1354406 workaround, we want this to start at 0 upon creation eventually
64 if (type == Notification.SnapDecision) {
65 if (ListView.view.currentIndex == index) {
68 if (ListView.view.count > 2) {
69 if (ListView.view.currentIndex == -1 && index == 1) {
72 result = "contracted";
86 audioRole: MediaPlayer.alert
87 source: hints["suppress-sound"] !== "true" && hints["sound-file"] !== undefined ? hints["sound-file"] : ""
90 Component.onCompleted: {
91 // Turn on screen as needed (Powerd.Notification means the screen
92 // stays on for a shorter amount of time)
93 if (type == Notification.SnapDecision) {
94 Powerd.setStatus(Powerd.On, Powerd.SnapDecision);
95 } else if (type != Notification.Confirmation) {
96 Powerd.setStatus(Powerd.On, Powerd.Notification);
99 // FIXME: using onCompleted because of LP: #1354406 workaround, has to be onOpacityChanged really
100 if (opacity == 1.0 && hints["suppress-sound"] !== "true" && sound.source !== "") {
109 UbuntuNumberAnimation {
110 duration: UbuntuAnimation.FastDuration
111 easing.type: Easing.OutBounce
116 if (type === Notification.Confirmation && opacity == 1.0 && hints["suppress-sound"] !== "true" && sound.source !== "") {
122 id: normalHeightBehavior
124 //enabled: menuItemFactory.progress == 1
126 UbuntuNumberAnimation {
127 duration: UbuntuAnimation.SnapDuration
134 PropertyChanges {target: notification; height: units.gu(10)}
138 PropertyChanges {target: notification; height: implicitHeight}
142 clip: fullscreen ? false : true
144 visible: type != Notification.PlaceHolder
152 leftMargin: notification.margins
153 rightMargin: notification.margins
154 topMargin: type === Notification.Confirmation ? units.gu(.5) : 0
157 opacity: parent.opacity
168 opacity: parent.opacity
172 if (draggable && notification.x > 0.75 * notification.width) {
173 notification.notification.close()
179 anchors.fill: fullscreen ? nonShapedBack : shapedBack
181 UnityMenuModelPaths {
184 source: hints["x-canonical-private-menu-model"]
186 busNameHint: "busName"
187 actionsHint: "actions"
188 menuObjectPathHint: "menuPath"
194 property string lastNameOwner: ""
196 busName: paths.busName
197 actions: paths.actions
198 menuObjectPath: paths.menuObjectPath
199 onNameOwnerChanged: {
200 if (lastNameOwner !== "" && nameOwner === "" && notification.notification !== undefined) {
201 notification.notification.close()
203 lastNameOwner = nameOwner
211 objectName: "interactiveArea"
213 drag.target: draggable ? notification : undefined
214 drag.axis: Drag.XAxis
216 drag.maximumX: notification.width
219 if (notification.type == Notification.Interactive) {
220 notification.notification.invokeAction(actionRepeater.itemAt(0).actionId)
221 } else if (hasMouse && canBeClosed) {
222 notification.notification.close()
224 notificationList.currentIndex = index;
228 if (notification.x < notification.width / 2) {
231 notification.x = notification.width
244 topMargin: fullscreen ? 0 : type === Notification.Confirmation ? units.gu(1) : units.gu(2)
247 spacing: type === Notification.Confirmation ? units.gu(1) : units.gu(2)
252 spacing: contentSpacing
256 margins: contentSpacing
263 width: type == Notification.Ephemeral && !bodyLabel.visible ? units.gu(3) : units.gu(6)
265 shaped: notification.hints["x-canonical-non-shaped-icon"] == "true" ? false : true
266 visible: iconSource !== undefined && iconSource !== "" && type !== Notification.Confirmation
271 width: secondaryIcon.visible ? parent.width - x - units.gu(4.5) : parent.width - x
273 anchors.verticalCenter: (icon.visible && !bodyLabel.visible) ? icon.verticalCenter : undefined
278 objectName: "summaryLabel"
283 visible: type !== Notification.Confirmation
285 color: darkOnBright ? sdFontColor : Theme.palette.selected.backgroundText
286 elide: Text.ElideRight
287 textFormat: Text.PlainText
293 objectName: "bodyLabel"
298 visible: body != "" && type !== Notification.Confirmation
300 color: darkOnBright ? sdFontColor : Theme.palette.selected.backgroundText
301 wrapMode: Text.WordWrap
302 maximumLineCount: type == Notification.SnapDecision ? 12 : 2
303 elide: Text.ElideRight
304 textFormat: Text.PlainText
311 objectName: "secondaryIcon"
314 visible: status === Image.Ready
315 fillMode: Image.PreserveAspectCrop
319 ListItem.ThinDivider {
320 visible: type == Notification.SnapDecision
325 objectName: "centeredIcon"
328 shaped: notification.hints["x-canonical-non-shaped-icon"] == "true" ? false : true
329 fileSource: icon.fileSource
330 visible: fileSource !== undefined && fileSource !== "" && type === Notification.Confirmation
331 anchors.horizontalCenter: parent.horizontalCenter
336 objectName: "valueLabel"
338 anchors.horizontalCenter: parent.horizontalCenter
339 visible: type === Notification.Confirmation && body !== ""
341 color: darkOnBright ? sdFontColor : Theme.palette.selected.backgroundText
342 wrapMode: Text.WordWrap
344 elide: Text.ElideRight
345 textFormat: Text.PlainText
350 objectName: "valueIndicator"
351 visible: type === Notification.Confirmation
352 property double value
357 margins: contentSpacing
361 color: darkOnBright ? UbuntuColors.darkGrey : UbuntuColors.lightGrey
367 objectName: "innerBar"
368 width: valueIndicator.width * valueIndicator.value / 100
370 color: notification.hints["x-canonical-value-bar-tint"] === "true" ? UbuntuColors.orange : darkOnBright ? UbuntuColors.lightGrey : "white"
378 objectName: "dialogListView"
386 top: fullscreen ? parent.top : undefined
387 bottom: fullscreen ? parent.bottom : undefined
391 model: unityMenuModel
393 NotificationMenuItemFactory {
397 left: dialogColumn.left
398 right: dialogColumn.right
401 menuModel: unityMenuModel
404 maxHeight: notification.maxHeight
405 background: notification.background
408 notification.fullscreen = Qt.binding(function() { return fullscreen; });
411 notification.notification.invokeAction(actionRepeater.itemAt(0).actionId)
423 margins: contentSpacing
426 spacing: contentSpacing
428 visible: notification.type === Notification.SnapDecision && oneOverTwoRepeaterTop.count === 3
431 id: oneOverTwoRepeaterTop
433 model: notification.actions
435 id: oneOverTwoLoaderTop
437 property string actionId: id
438 property string actionLabel: label
441 id: oneOverTwoButtonTop
444 objectName: "notify_oot_button" + index
445 width: oneOverTwoCase.width
446 text: oneOverTwoLoaderTop.actionLabel
447 color: notification.hints["x-canonical-private-affirmative-tint"] == "true" ? green : sdDarkGrey
448 onClicked: notification.notification.invokeAction(oneOverTwoLoaderTop.actionId)
451 sourceComponent: index == 0 ? oneOverTwoButtonTop : undefined
456 spacing: contentSpacing
459 id: oneOverTwoRepeaterBottom
461 model: notification.actions
463 id: oneOverTwoLoaderBottom
465 property string actionId: id
466 property string actionLabel: label
469 id: oneOverTwoButtonBottom
472 objectName: "notify_oot_button" + index
473 width: oneOverTwoCase.width / 2 - spacing * 2
474 text: oneOverTwoLoaderBottom.actionLabel
475 color: index == 1 && notification.hints["x-canonical-private-rejection-tint"] == "true" ? red : sdDarkGrey
476 onClicked: notification.notification.invokeAction(oneOverTwoLoaderBottom.actionId)
479 sourceComponent: (index == 1 || index == 2) ? oneOverTwoButtonBottom : undefined
488 objectName: "buttonRow"
492 margins: contentSpacing
494 visible: notification.type === Notification.SnapDecision && actionRepeater.count > 0 && !oneOverTwoCase.visible
495 spacing: contentSpacing
496 layoutDirection: Qt.RightToLeft
499 id: notifySwipeButtonLoader
500 active: notification.hints["x-canonical-snap-decisions-swipe"] === "true"
502 sourceComponent: SwipeToAct {
503 objectName: "notify_swipe_button"
504 width: buttonRow.width
505 leftIconName: "call-end"
506 rightIconName: "call-start"
507 clickToAct: notification.hasMouse
509 notification.notification.invokeAction(notification.actions.data(0, ActionModel.RoleActionId))
513 notification.notification.invokeAction(notification.actions.data(1, ActionModel.RoleActionId))
520 model: notification.actions
524 property string actionId: id
525 property string actionLabel: label
526 active: !notifySwipeButtonLoader.active
532 objectName: "notify_button" + index
533 width: buttonRow.width / 2 - spacing * 2
534 text: loader.actionLabel
536 var result = sdDarkGrey;
537 if (index == 0 && notification.hints["x-canonical-private-affirmative-tint"] == "true") {
540 if (index == 1 && notification.hints["x-canonical-private-rejection-tint"] == "true") {
545 onClicked: notification.notification.invokeAction(loader.actionId)
548 sourceComponent: (index == 0 || index == 1) ? actionButton : undefined
555 objectName: "notify_button2"
560 margins: contentSpacing
563 visible: notification.type == Notification.SnapDecision && actionRepeater.count > 3 && !oneOverTwoCase.visible
564 model: notification.actions
568 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