2 * Copyright (C) 2013 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
19import Ubuntu.Components 1.1
20import 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
34 property var notificationId
37 property var notification
39 property bool fullscreen: false
40 property bool draggable: state == "contracted" || notification.type !== Notification.Confirmation
41 property int maxHeight
43 readonly property color red: "#fc4949"
44 readonly property color green: "#3fb24f"
45 readonly property color sdLightGrey: "#eaeaea"
46 readonly property color sdDarkGrey: "#dddddd"
47 readonly property color sdFontColor: "#5d5d5d"
48 readonly property real contentSpacing: units.gu(2)
50 objectName: "background"
51 implicitHeight: type !== Notification.PlaceHolder ? (fullscreen ? maxHeight : outterColumn.height + contentSpacing * 2) : 0
53 color: type == Notification.SnapDecision ? sdLightGrey : Qt.rgba(0.132, 0.117, 0.109, 0.97)
54 opacity: 1 - (x / notification.width) // FIXME: 1 because of LP: #1354406 workaround, has to be 0 really
59 if (type == Notification.SnapDecision) {
60 if (ListView.view.currentIndex == index) {
63 if (ListView.view.count > 2) {
64 if (ListView.view.currentIndex == -1 && index == 1) {
67 result = "contracted";
81 source: hints["suppress-sound"] != "true" && hints["sound-file"] != undefined ? hints["sound-file"] : ""
84 // FIXME: using onCompleted because of LP: #1354406 workaround, has to be onOpacityChanged really
85 Component.onCompleted: {
86 if (opacity == 1.0 && hints["suppress-sound"] != "true" && sound.source != "") {
95 UbuntuNumberAnimation {
96 duration: UbuntuAnimation.FastDuration
97 easing.type: Easing.OutBounce
102 id: normalHeightBehavior
104 //enabled: menuItemFactory.progress == 1
106 SequentialAnimation {
108 duration: UbuntuAnimation.SnapDuration
110 UbuntuNumberAnimation {
111 duration: UbuntuAnimation.SnapDuration
119 PropertyChanges {target: notification; height: units.gu(10)}
123 PropertyChanges {target: notification; height: implicitHeight}
127 clip: fullscreen ? false : true
129 visible: type != Notification.PlaceHolder
137 leftMargin: notification.margins
138 rightMargin: notification.margins
141 opacity: parent.opacity
152 opacity: parent.opacity
156 if (draggable && notification.x > 0.75 * notification.width) {
157 notification.notification.close()
163 anchors.fill: fullscreen ? nonShapedBack : shapedBack
165 UnityMenuModelPaths {
168 source: hints["x-canonical-private-menu-model"]
170 busNameHint: "busName"
171 actionsHint: "actions"
172 menuObjectPathHint: "menuPath"
178 property string lastNameOwner: ""
180 busName: paths.busName
181 actions: paths.actions
182 menuObjectPath: paths.menuObjectPath
183 onNameOwnerChanged: {
184 if (lastNameOwner != "" && nameOwner == "" && notification.notification != undefined) {
185 notification.notification.close()
187 lastNameOwner = nameOwner
191 Behavior on implicitHeight {
195 UbuntuNumberAnimation {
196 duration: UbuntuAnimation.SnapDuration
200 // delay enabling height behavior until the add transition is complete
201 onOpacityChanged: if (opacity == 1) heightBehavior.enabled = true
207 objectName: "interactiveArea"
209 drag.target: draggable ? notification : undefined
210 drag.axis: Drag.XAxis
212 drag.maximumX: notification.width
215 if (notification.type == Notification.Interactive) {
216 notification.notification.invokeAction(actionRepeater.itemAt(0).actionId)
218 notificationList.currentIndex = index;
223 notification.anchors.left = undefined
224 notification.anchors.right = undefined
228 if (notification.x < notification.width / 2) {
231 notification.x = notification.width
244 topMargin: fullscreen ? 0 : 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 != ""
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"
284 color: type == Notification.SnapDecision ? sdFontColor : Theme.palette.selected.backgroundText
285 elide: Text.ElideRight
286 textFormat: Text.PlainText
292 objectName: "bodyLabel"
299 color: type == Notification.SnapDecision ? sdFontColor : Theme.palette.selected.backgroundText
300 wrapMode: Text.WordWrap
301 maximumLineCount: type == Notification.SnapDecision ? 12 : 2
302 elide: Text.ElideRight
303 textFormat: Text.PlainText
310 objectName: "secondaryIcon"
313 visible: status === Image.Ready
314 fillMode: Image.PreserveAspectCrop
318 ListItem.ThinDivider {
319 visible: type == Notification.SnapDecision
324 objectName: "dialogListView"
332 top: fullscreen ? parent.top : undefined
333 bottom: fullscreen ? parent.bottom : undefined
337 model: unityMenuModel
339 NotificationMenuItemFactory {
343 left: dialogColumn.left
344 right: dialogColumn.right
347 menuModel: unityMenuModel
350 maxHeight: notification.maxHeight
353 notification.fullscreen = Qt.binding(function() { return fullscreen; });
356 notification.notification.invokeAction(actionRepeater.itemAt(0).actionId)
368 margins: contentSpacing
371 spacing: contentSpacing
373 visible: notification.type == Notification.SnapDecision && oneOverTwoRepeaterTop.count == 3
376 id: oneOverTwoRepeaterTop
378 model: notification.actions
380 id: oneOverTwoLoaderTop
382 property string actionId: id
383 property string actionLabel: label
386 id: oneOverTwoButtonTop
389 objectName: "notify_oot_button" + index
390 width: oneOverTwoCase.width
391 text: oneOverTwoLoaderTop.actionLabel
392 color: notification.hints["x-canonical-private-affirmative-tint"] == "true" ? green : sdDarkGrey
393 onClicked: notification.notification.invokeAction(oneOverTwoLoaderTop.actionId)
396 sourceComponent: index == 0 ? oneOverTwoButtonTop : undefined
401 spacing: contentSpacing
404 id: oneOverTwoRepeaterBottom
406 model: notification.actions
408 id: oneOverTwoLoaderBottom
410 property string actionId: id
411 property string actionLabel: label
414 id: oneOverTwoButtonBottom
417 objectName: "notify_oot_button" + index
418 width: oneOverTwoCase.width / 2 - spacing * 2
419 text: oneOverTwoLoaderBottom.actionLabel
420 color: index == 1 && notification.hints["x-canonical-private-rejection-tint"] == "true" ? red : sdDarkGrey
421 onClicked: notification.notification.invokeAction(oneOverTwoLoaderBottom.actionId)
424 sourceComponent: (index == 1 || index == 2) ? oneOverTwoButtonBottom : undefined
433 objectName: "buttonRow"
437 margins: contentSpacing
439 visible: notification.type == Notification.SnapDecision && actionRepeater.count > 0 && !oneOverTwoCase.visible
441 layoutDirection: Qt.RightToLeft
446 model: notification.actions
450 property string actionId: id
451 property string actionLabel: label
457 objectName: "notify_button" + index
458 width: buttonRow.width / 2 - spacing*2
459 text: loader.actionLabel
461 var result = sdDarkGrey;
462 if (index == 0 && notification.hints["x-canonical-private-affirmative-tint"] == "true") {
465 if (index == 1 && notification.hints["x-canonical-private-rejection-tint"] == "true") {
470 onClicked: notification.notification.invokeAction(loader.actionId)
473 sourceComponent: (index == 0 || index == 1) ? actionButton : undefined
481 objectName: "notify_button2"
486 margins: contentSpacing
489 visible: notification.type == Notification.SnapDecision && actionRepeater.count > 3 && !oneOverTwoCase.visible
491 onClicked: notification.notification.invokeAction(comboRepeater.itemAt(2).actionId)
493 expandedHeight: (comboRepeater.count - 2) * units.gu(4) + units.gu(.5)
494 comboList: Flickable {
495 // this has to be wrapped inside a flickable
496 // to work around a feature/bug? of the
497 // ComboButton SDK-element, making a regular
498 // unwrapped Column item flickable
506 comboButton.text = comboRepeater.count >= 3 ? comboRepeater.itemAt(2).actionLabel : ""
509 model: notification.actions
514 visible: status == Loader.Ready
515 property string actionId: id
516 property string actionLabel: label
517 readonly property var splitLabel: actionLabel.match(/(^([-a-z0-9]+):)?(.*)$/)
524 objectName: "notify_button" + index
525 width: comboButton.width
526 height: comboIcon.height + units.gu(2)
529 notification.notification.invokeAction(actionId)
532 ListItem.ThinDivider {
541 leftMargin: units.gu(.5)
542 verticalCenter: parent.verticalCenter
554 left: comboIcon.right
555 leftMargin: units.gu(1)
556 verticalCenter: comboIcon.verticalCenter
564 sourceComponent: (index > 2) ? comboEntry : undefined
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