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 readonly property color red: "#fc4949"
43 readonly property color green: "#3fb24f"
44 readonly property color sdLightGrey: "#eaeaea"
45 readonly property color sdDarkGrey: "#dddddd"
46 readonly property color sdFontColor: "#5d5d5d"
47 readonly property real contentSpacing: units.gu(2)
49 objectName: "background"
50 implicitHeight: type !== Notification.PlaceHolder ? (fullscreen ? maxHeight : outterColumn.height + contentSpacing * 2) : 0
52 color: type == Notification.SnapDecision ? sdLightGrey : Qt.rgba(0.132, 0.117, 0.109, 0.97)
58 if (type == Notification.SnapDecision) {
59 if (ListView.view.currentIndex == index) {
62 if (ListView.view.count > 2) {
63 if (ListView.view.currentIndex == -1 && index == 1) {
66 result = "contracted";
80 source: hints["suppress-sound"] != "true" && hints["sound-file"] != undefined ? hints["sound-file"] : ""
84 if (opacity == 1.0 && hints["suppress-sound"] != "true" && sound.source) {
90 id: normalHeightBehavior
92 //enabled: menuItemFactory.progress == 1
96 duration: UbuntuAnimation.SnapDuration
98 UbuntuNumberAnimation {
99 duration: UbuntuAnimation.SnapDuration
107 PropertyChanges {target: notification; height: units.gu(8)}
111 PropertyChanges {target: notification; height: implicitHeight}
115 clip: fullscreen ? false : true
117 visible: type != Notification.PlaceHolder
125 leftMargin: notification.margins
126 rightMargin: notification.margins
129 opacity: parent.opacity
139 opacity: parent.opacity
144 anchors.fill: fullscreen ? nonShapedBack : shapedBack
146 UnityMenuModelPaths {
149 source: hints["x-canonical-private-menu-model"]
151 busNameHint: "busName"
152 actionsHint: "actions"
153 menuObjectPathHint: "menuPath"
159 property string lastNameOwner: ""
161 busName: paths.busName
162 actions: paths.actions
163 menuObjectPath: paths.menuObjectPath
164 onNameOwnerChanged: {
165 if (lastNameOwner != "" && nameOwner == "" && notification.notification != undefined) {
166 notification.notification.close()
168 lastNameOwner = nameOwner
172 Behavior on implicitHeight {
176 UbuntuNumberAnimation {
177 duration: UbuntuAnimation.SnapDuration
181 // delay enabling height behavior until the add transition is complete
182 onOpacityChanged: if (opacity == 1) heightBehavior.enabled = true
188 objectName: "interactiveArea"
190 if (notification.type == Notification.Interactive) {
191 notification.notification.invokeAction(actionRepeater.itemAt(0).actionId)
193 notificationList.currentIndex = index;
206 topMargin: units.gu(2)
214 spacing: contentSpacing
218 margins: contentSpacing
225 width: type == Notification.Ephemeral && !bodyLabel.visible ? units.gu(3) : units.gu(6)
226 height: type == Notification.Ephemeral && !bodyLabel.visible ? units.gu(3) : units.gu(6)
227 shaped: notification.hints["x-canonical-non-shaped-icon"] == "true" ? false : true
228 visible: iconSource !== undefined && iconSource != ""
233 width: secondaryIcon.visible ? parent.width - x - units.gu(4.5) : parent.width - x
235 anchors.verticalCenter: (icon.visible && !bodyLabel.visible) ? icon.verticalCenter : undefined
240 objectName: "summaryLabel"
246 color: type == Notification.SnapDecision ? sdFontColor :Theme.palette.selected.backgroundText
247 elide: Text.ElideRight
253 objectName: "bodyLabel"
260 color: type == Notification.SnapDecision ? sdFontColor : Theme.palette.selected.backgroundText
261 opacity: type == Notification.SnapDecision ? 1.0 : 0.6
262 wrapMode: Text.WordWrap
264 elide: Text.ElideRight
271 objectName: "secondaryIcon"
274 visible: source !== undefined && source != ""
275 fillMode: Image.PreserveAspectCrop
279 ListItem.ThinDivider {
280 visible: type == Notification.SnapDecision
285 objectName: "dialogListView"
293 top: fullscreen ? parent.top : undefined
294 bottom: fullscreen ? parent.bottom : undefined
298 model: unityMenuModel
300 NotificationMenuItemFactory {
304 left: dialogColumn.left
305 right: dialogColumn.right
308 menuModel: unityMenuModel
311 maxHeight: notification.maxHeight
314 notification.fullscreen = Qt.binding(function() { return fullscreen; });
323 objectName: "buttonRow"
327 margins: contentSpacing
329 visible: notification.type == Notification.SnapDecision && actionRepeater.count > 0
331 layoutDirection: Qt.RightToLeft
336 model: notification.actions
340 property string actionId: id
341 property string actionLabel: label
347 objectName: "button" + index
348 width: buttonRow.width / 2 - spacing*2
349 text: loader.actionLabel
351 var result = sdDarkGrey;
352 if (index == 0 && notification.hints["x-canonical-private-affirmative-tint"] == "true") {
355 if (index == 1 && notification.hints["x-canonical-private-rejection-tint"] == "true") {
360 onClicked: notification.notification.invokeAction(loader.actionId)
363 sourceComponent: (index == 0 || index == 1) ? actionButton : undefined
371 objectName: "button2"
376 margins: contentSpacing
379 visible: notification.type == Notification.SnapDecision && actionRepeater.count > 3
381 onClicked: notification.notification.invokeAction(comboRepeater.itemAt(2).actionId)
383 expandedHeight: (comboRepeater.count - 2) * units.gu(4) + units.gu(.5)
384 comboList: Flickable {
385 // this has to be wrapped inside a flickable
386 // to work around a feature/bug? of the
387 // ComboButton SDK-element, making a regular
388 // unwrapped Column item flickable
396 comboButton.text = comboRepeater.itemAt(2).actionLabel
399 model: notification.actions
404 visible: status == Loader.Ready
405 property string actionId: id
406 property string actionLabel: label
407 readonly property var splitLabel: actionLabel.match(/(^([-a-z0-9]+):)?(.*)$/)
414 objectName: "button" + index
415 width: comboButton.width
416 height: comboIcon.height + units.gu(2)
419 notification.notification.invokeAction(actionId)
422 ListItem.ThinDivider {
431 leftMargin: units.gu(.5)
432 verticalCenter: parent.verticalCenter
444 left: comboIcon.right
445 leftMargin: units.gu(1)
446 verticalCenter: comboIcon.verticalCenter
454 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