on dbc9718 help sign in
unity8/Notifications/Notification.qml
156 lines 4.5 kB history raw
1/*
2 * Copyright (C) 2013 Canonical, Ltd.
3 *
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.
7 *
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.
12 *
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/>.
15 */
17import QtQuick 2.0
18import Ubuntu.Components 0.1
19import Unity.Notifications 1.0
21UbuntuShape {
22 id: notification
24 property alias iconSource: avatarIcon.source
25 property alias secondaryIconSource: secondaryIcon.source
26 property alias summary: summaryLabel.text
27 property alias body: bodyLabel.text
28 property var actions
29 property var notificationId
30 property var type
31 property var notification
33 implicitHeight: childrenRect.height
34 color: Qt.rgba(0, 0, 0, 0.85)
35 opacity: 0
37 MouseArea {
38 id: interactiveArea
40 anchors.fill: contentColumn
41 objectName: "interactiveArea"
42 enabled: notification.type == Notification.Interactive
43 onClicked: notification.notification.invokeAction(actionRepeater.itemAt(0).actionId)
44 }
46 Column {
47 id: contentColumn
49 anchors {
50 left: parent.left
51 right: parent.right
52 top: parent.top
53 margins: spacing
54 }
55 height: childrenRect.height + spacing
56 spacing: units.gu(1)
58 Row {
59 id: topRow
61 spacing: contentColumn.spacing
62 anchors {
63 left: parent.left
64 right: parent.right
65 }
67 UbuntuShape {
68 id: icon
70 objectName: "icon"
71 width: units.gu(6)
72 height: units.gu(6)
73 visible: iconSource !== undefined && iconSource != ""
74 image: Image {
75 id: avatarIcon
77 fillMode: Image.PreserveAspectCrop
78 }
79 }
81 Image {
82 id: secondaryIcon
84 objectName: "secondaryIcon"
85 width: units.gu(2)
86 height: units.gu(2)
87 visible: source !== undefined && source != ""
88 fillMode: Image.PreserveAspectCrop
89 }
91 Column {
92 id: labelColumn
93 width: parent.width - x
95 Label {
96 id: summaryLabel
98 objectName: "summaryLabel"
99 anchors {
100 left: parent.left
101 right: parent.right
102 }
103 fontSize: "medium"
104 font.bold: true
105 color: "#f3f3e7"
106 elide: Text.ElideRight
107 }
109 Label {
110 id: bodyLabel
112 objectName: "bodyLabel"
113 anchors {
114 left: parent.left
115 right: parent.right
116 }
117 visible: body != ""
118 fontSize: "small"
119 color: "#f3f3e7"
120 opacity: 0.6
121 wrapMode: Text.WordWrap
122 maximumLineCount: 10
123 elide: Text.ElideRight
124 }
125 }
126 }
128 Row {
129 id: buttonRow
131 objectName: "buttonRow"
132 spacing: contentColumn.spacing
133 layoutDirection: Qt.RightToLeft
134 visible: notification.type == Notification.SnapDecision
135 anchors {
136 left: parent.left
137 right: parent.right
138 }
140 Repeater {
141 id: actionRepeater
142 model: notification.actions
144 Button {
145 objectName: "button" + index
146 color: Positioner.isFirstItem ? "#d85317" : "#cdcdcb"
147 width: (buttonRow.width - buttonRow.spacing) / 2
148 height: units.gu(4)
149 text: label
150 property string actionId: id
151 onClicked: notification.notification.invokeAction(id)
152 }
153 }
154 }
155 }