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 int maxHeight
42 property Gradient greenGradient : Gradient {
43 GradientStop { position: 0.0; color: "#3fb24f" }
44 GradientStop { position: 1.0; color: "#3fb24f" }
46 property Gradient darkgreyGradient: Gradient {
47 GradientStop { position: 0.0; color: "#4d4745" }
48 GradientStop { position: 1.0; color: "#4d4745" }
51 objectName: "background"
52 implicitHeight: type !== Notification.PlaceHolder ? (fullscreen ? maxHeight : contentColumn.height + contentColumn.spacing * 2) : 0
54 color: Qt.rgba(0.132, 0.117, 0.109, 0.97)
55 opacity: 1 // FIXME: 1 because of LP: #1354406 workaround, has to be 0 really
60 if (type == Notification.SnapDecision) {
61 if (ListView.view.currentIndex == index) {
64 if (ListView.view.count > 2) {
65 if (ListView.view.currentIndex == -1 && index == 1) {
68 result = "contracted";
82 source: hints["suppress-sound"] != "true" && hints["sound-file"] != undefined ? hints["sound-file"] : ""
85 // FIXME: using onCompleted because of LP: #1354406 workaround, has to be onOpacityChanged really
86 Component.onCompleted: {
87 if (opacity == 1.0 && hints["suppress-sound"] != "true" && sound.source) {
93 id: normalHeightBehavior
95 //enabled: menuItemFactory.progress == 1
99 duration: UbuntuAnimation.SnapDuration
101 UbuntuNumberAnimation {
102 duration: UbuntuAnimation.SnapDuration
110 PropertyChanges {target: notification; height: units.gu(8)}
114 PropertyChanges {target: notification; height: implicitHeight}
118 clip: fullscreen ? false : true
120 visible: type != Notification.PlaceHolder
128 leftMargin: notification.margins
129 rightMargin: notification.margins
132 opacity: parent.opacity
142 opacity: parent.opacity
147 anchors.fill: fullscreen ? nonShapedBack : shapedBack
149 UnityMenuModelPaths {
152 source: hints["x-canonical-private-menu-model"]
154 busNameHint: "busName"
155 actionsHint: "actions"
156 menuObjectPathHint: "menuPath"
162 property string lastNameOwner: ""
164 busName: paths.busName
165 actions: paths.actions
166 menuObjectPath: paths.menuObjectPath
167 onNameOwnerChanged: {
168 if (lastNameOwner != "" && nameOwner == "" && notification.notification != undefined) {
169 notification.notification.close()
171 lastNameOwner = nameOwner
175 Behavior on implicitHeight {
179 UbuntuNumberAnimation {
180 duration: UbuntuAnimation.SnapDuration
184 // delay enabling height behavior until the add transition is complete
185 onOpacityChanged: if (opacity == 1) heightBehavior.enabled = true
191 objectName: "interactiveArea"
193 if (notification.type == Notification.Interactive) {
194 notification.notification.invokeAction(actionRepeater.itemAt(0).actionId)
196 notificationList.currentIndex = index;
203 objectName: "contentColumn"
209 margins: fullscreen ? 0 : spacing
217 spacing: contentColumn.spacing
229 shaped: notification.hints["x-canonical-non-shaped-icon"] == "true" ? false : true
230 visible: iconSource !== undefined && iconSource != ""
236 objectName: "secondaryIcon"
239 visible: source !== undefined && source != ""
240 fillMode: Image.PreserveAspectCrop
245 width: parent.width - x
247 anchors.verticalCenter: (icon.visible && !bodyLabel.visible) ? icon.verticalCenter : undefined
252 objectName: "summaryLabel"
259 color: Theme.palette.selected.backgroundText
260 elide: Text.ElideRight
261 textFormat: Text.PlainText
267 objectName: "bodyLabel"
274 color: Theme.palette.selected.backgroundText
276 wrapMode: Text.WordWrap
278 elide: Text.ElideRight
279 textFormat: Text.PlainText
286 objectName: "dialogListView"
294 top: fullscreen ? parent.top : undefined
295 bottom: fullscreen ? parent.bottom : undefined
299 model: unityMenuModel
301 NotificationMenuItemFactory {
305 left: dialogColumn.left
306 right: dialogColumn.right
309 menuModel: unityMenuModel
312 maxHeight: notification.maxHeight
315 notification.fullscreen = Qt.binding(function() { return fullscreen; });
318 notification.notification.invokeAction(actionRepeater.itemAt(0).actionId)
327 objectName: "buttonRow"
332 visible: notification.type == Notification.SnapDecision && actionRepeater.count > 0
334 layoutDirection: Qt.RightToLeft
339 model: notification.actions
343 property string actionId: id
344 property string actionLabel: label
350 objectName: "button" + index
351 width: buttonRow.width / 2 - spacing
352 text: loader.actionLabel
353 gradient: notification.hints["x-canonical-private-button-tint"] == "true" && index == 0 ? greenGradient : darkgreyGradient
354 onClicked: notification.notification.invokeAction(loader.actionId)
357 sourceComponent: (index == 0 || index == 1) ? actionButton : undefined
365 objectName: "button2"
367 visible: notification.type == Notification.SnapDecision && actionRepeater.count > 3
368 gradient: darkgreyGradient
369 onClicked: notification.notification.invokeAction(comboRepeater.itemAt(2).actionId)
371 expandedHeight: (comboRepeater.count - 2) * units.gu(4) + units.gu(.5)
372 comboList: Flickable {
373 // this has to be wrapped inside a flickable
374 // to work around a feature/bug? of the
375 // ComboButton SDK-element, making a regular
376 // unwrapped Column item flickable
384 comboButton.text = comboRepeater.count >= 3 ? comboRepeater.itemAt(2).actionLabel : ""
387 model: notification.actions
392 visible: status == Loader.Ready
393 property string actionId: id
394 property string actionLabel: label
395 readonly property var splitLabel: actionLabel.match(/(^([-a-z0-9]+):)?(.*)$/)
402 objectName: "button" + index
403 width: comboButton.width
404 height: comboIcon.height + units.gu(2)
407 notification.notification.invokeAction(actionId)
410 ListItem.ThinDivider {
419 leftMargin: units.gu(.5)
420 verticalCenter: parent.verticalCenter
432 left: comboIcon.right
433 leftMargin: units.gu(1)
434 verticalCenter: comboIcon.verticalCenter
442 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