on 1290955 help sign in
unity8/Notifications/Notification.qml
153 lines 4.4 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
20UbuntuShape {
21 id: notification
23 property string type
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
30 signal actionInvoked(string buttonId)
32 implicitHeight: childrenRect.height
33 color: Qt.rgba(0, 0, 0, 0.85)
34 opacity: 0
36 MouseArea {
37 id: interactiveArea
39 anchors.fill: contentColumn
40 objectName: "interactiveArea"
41 enabled: notification.type == "Notifications.Type.Interactive"
42 onClicked: notification.actionInvoked(actions.get(0).id)
43 }
45 Column {
46 id: contentColumn
48 anchors {
49 left: parent.left
50 right: parent.right
51 top: parent.top
52 margins: spacing
53 }
54 height: childrenRect.height + spacing
55 spacing: units.gu(1)
57 Row {
58 id: topRow
60 spacing: contentColumn.spacing
61 anchors {
62 left: parent.left
63 right: parent.right
64 }
66 UbuntuShape {
67 id: icon
69 objectName: "icon"
70 width: units.gu(6)
71 height: units.gu(6)
72 visible: iconSource !== undefined && iconSource != ""
73 image: Image {
74 id: avatarIcon
76 fillMode: Image.PreserveAspectCrop
77 }
78 }
80 Image {
81 id: secondaryIcon
83 objectName: "secondaryIcon"
84 width: units.gu(2)
85 height: units.gu(2)
86 visible: source !== undefined && source != ""
87 fillMode: Image.PreserveAspectCrop
88 }
90 Column {
91 id: labelColumn
92 width: parent.width - x
94 Label {
95 id: summaryLabel
97 objectName: "summaryLabel"
98 anchors {
99 left: parent.left
100 right: parent.right
101 }
102 fontSize: "medium"
103 font.bold: true
104 color: "#f3f3e7"
105 elide: Text.ElideRight
106 }
108 Label {
109 id: bodyLabel
111 objectName: "bodyLabel"
112 anchors {
113 left: parent.left
114 right: parent.right
115 }
116 visible: body != ""
117 fontSize: "small"
118 color: "#f3f3e7"
119 opacity: 0.6
120 wrapMode: Text.WordWrap
121 maximumLineCount: 10
122 elide: Text.ElideRight
123 }
124 }
125 }
127 Row {
128 id: buttonRow
130 objectName: "buttonRow"
131 spacing: contentColumn.spacing
132 layoutDirection: Qt.RightToLeft
133 visible: notification.type == "Notifications.Type.SnapDecision"
134 anchors {
135 left: parent.left
136 right: parent.right
137 }
139 Repeater {
140 model: notification.actions
142 Button {
143 objectName: "button" + index
144 color: Positioner.isFirstItem ? "#d85317" : "#cdcdcb"
145 width: (buttonRow.width - buttonRow.spacing) / 2
146 height: units.gu(4)
147 text: label
148 onClicked: notification.actionInvoked(id)
149 }
150 }
151 }
152 }