on xenial help sign in
Made notification-background adjust to new fullscreen-hint... margins still need to be zero'ed for the fullscreen-case.
cd80588Mirco Müller
Notifications/Notification.qml+213−182
@@ -20,7 +20,7 @@ import Unity.Notifications 1.0
20import QMenuModel 0.1
20import QMenuModel 0.1
21import Utils 0.1
21import Utils 0.1
22
22
23−UbuntuShape {
23+Item {
24 id: notification
24 id: notification
25
25
26 property alias iconSource: avatarIcon.source
26 property alias iconSource: avatarIcon.source
@@ -32,266 +32,297 @@ UbuntuShape {
32 property var type
32 property var type
33 property var hints
33 property var hints
34 property var notification
34 property var notification
35+ property color color
36+ property bool fullscreen
35
37
38+ fullscreen: notification.hints["x-canonical-private-fullscreen"] == "true" ? true : false
36 objectName: "background"
39 objectName: "background"
37− implicitHeight: type != Notification.PlaceHolder ? contentColumn.height + contentColumn.spacing * 2 : 0
40+ implicitHeight: type != Notification.PlaceHolder ? (fullscreen ? notificationList.fullHeight : contentColumn.height + contentColumn.spacing * 2) : 0
41+
42+ //parent.anchors.leftMargin: fullscreen ? 0 : notificationList.margin
43+ //parent.anchors.rightMargin: fullscreen ? 0 : notificationList.margin
44+ //parent.anchors.topMargin: fullscreen ? notificationList.panelHeight : notificationList.panelHeight + notificationList.margin
45+
38 color: Qt.rgba(0.132, 0.117, 0.109, 0.97)
46 color: Qt.rgba(0.132, 0.117, 0.109, 0.97)
39 opacity: 0
47 opacity: 0
40− radius: "medium"
41
48
42 clip: true
49 clip: true
43 visible: type != Notification.PlaceHolder
50 visible: type != Notification.PlaceHolder
44
51
45− UnityMenuModelPaths {
52+ UbuntuShape {
46− id: paths
53+ id: shapedBack
47−
48− source: hints["x-canonical-private-menu-model"]
49
54
50− busNameHint: "busName"
55+ visible: !fullscreen
51− actionsHint: "actions"
56+ anchors.fill: parent
52− menuObjectPathHint: "menuPath"
57+ color: parent.color
58+ opacity: parent.opacity
59+ radius: "medium"
53 }
60 }
54
61
55− UnityMenuModel {
62+ Rectangle {
56− id: unityMenuModel
63+ id: nonShapedBack
57
64
58− busName: paths.busName
65+ visible: fullscreen
59− actions: paths.actions
66+ anchors.fill: parent
60− menuObjectPath: paths.menuObjectPath
67+ color: parent.color
68+ opacity: parent.opacity
61 }
69 }
62
70
63− Behavior on implicitHeight {
71+ Item {
64− id: heightBehavior
72+ id: contents
73+ anchors.fill: parent
65
74
66− enabled: false
75+ UnityMenuModelPaths {
67− UbuntuNumberAnimation {
76+ id: paths
68− duration: UbuntuAnimation.SnapDuration
69− }
70− }
71
77
72− // delay enabling height behavior until the add transition is complete
78+ source: hints["x-canonical-private-menu-model"]
73− onOpacityChanged: if (opacity == 1) heightBehavior.enabled = true
74
79
75− MouseArea {
80+ busNameHint: "busName"
76− id: interactiveArea
81+ actionsHint: "actions"
82+ menuObjectPathHint: "menuPath"
83+ }
77
84
78− anchors.fill: contentColumn
85+ UnityMenuModel {
79− objectName: "interactiveArea"
86+ id: unityMenuModel
80− enabled: notification.type == Notification.Interactive
81− onClicked: notification.notification.invokeAction(actionRepeater.itemAt(0).actionId)
82− }
83
87
84− Column {
88+ busName: paths.busName
85− id: contentColumn
89+ actions: paths.actions
90+ menuObjectPath: paths.menuObjectPath
91+ }
86
92
87− anchors {
93+ Behavior on implicitHeight {
88− left: parent.left
94+ id: heightBehavior
89− right: parent.right
95+
90− top: parent.top
96+ enabled: false
91− margins: spacing
97+ UbuntuNumberAnimation {
98+ duration: UbuntuAnimation.SnapDuration
99+ }
92 }
100 }
93
101
94− spacing: units.gu(1)
102+ // delay enabling height behavior until the add transition is complete
103+ onOpacityChanged: if (opacity == 1) heightBehavior.enabled = true
95
104
96− Row {
105+ MouseArea {
97− id: topRow
106+ id: interactiveArea
107+
108+ anchors.fill: contentColumn
109+ objectName: "interactiveArea"
110+ enabled: notification.type == Notification.Interactive
111+ onClicked: notification.notification.invokeAction(actionRepeater.itemAt(0).actionId)
112+ }
113+
114+ Column {
115+ id: contentColumn
98
116
99− spacing: contentColumn.spacing
100 anchors {
117 anchors {
101 left: parent.left
118 left: parent.left
102 right: parent.right
119 right: parent.right
120+ top: parent.top
121+ margins: spacing
103 }
122 }
104
123
105− UbuntuShape {
124+ spacing: units.gu(1)
106− id: icon
107
125
108− objectName: "icon"
126+ Row {
109− width: units.gu(6)
127+ id: topRow
110− height: units.gu(6)
111− visible: iconSource !== undefined && iconSource != ""
112− image: Image {
113− id: avatarIcon
114
128
115− fillMode: Image.PreserveAspectCrop
129+ spacing: contentColumn.spacing
130+ anchors {
131+ left: parent.left
132+ right: parent.right
116 }
133 }
117− }
118
134
119− Image {
135+ UbuntuShape {
120− id: secondaryIcon
136+ id: icon
121
137
122− objectName: "secondaryIcon"
138+ objectName: "icon"
123− width: units.gu(2)
139+ width: units.gu(6)
124− height: units.gu(2)
140+ height: units.gu(6)
125− visible: source !== undefined && source != ""
141+ visible: iconSource !== undefined && iconSource != ""
126− fillMode: Image.PreserveAspectCrop
142+ image: Image {
127− }
143+ id: avatarIcon
128
144
129− Column {
145+ fillMode: Image.PreserveAspectCrop
130− id: labelColumn
146+ }
131− width: parent.width - x
147+ }
148+
149+ Image {
150+ id: secondaryIcon
151+
152+ objectName: "secondaryIcon"
153+ width: units.gu(2)
154+ height: units.gu(2)
155+ visible: source !== undefined && source != ""
156+ fillMode: Image.PreserveAspectCrop
157+ }
132
158
133− anchors.verticalCenter: (icon.visible && !bodyLabel.visible) ? icon.verticalCenter : undefined
159+ Column {
160+ id: labelColumn
161+ width: parent.width - x
134
162
135− Label {
163+ anchors.verticalCenter: (icon.visible && !bodyLabel.visible) ? icon.verticalCenter : undefined
136− id: summaryLabel
137
164
165+ Label {
166+ id: summaryLabel
167+
138− objectName: "summaryLabel"
168+ objectName: "summaryLabel"
139− anchors {
169+ anchors {
140− left: parent.left
170+ left: parent.left
141− right: parent.right
171+ right: parent.right
172+ }
173+ fontSize: "medium"
174+ font.bold: true
175+ color: Theme.palette.selected.backgroundText
176+ elide: Text.ElideRight
142 }
177 }
143− fontSize: "medium"
144− font.bold: true
145− color: Theme.palette.selected.backgroundText
146− elide: Text.ElideRight
147− }
148
178
149− Label {
179+ Label {
150− id: bodyLabel
180+ id: bodyLabel
151
181
152− objectName: "bodyLabel"
182+ objectName: "bodyLabel"
153− anchors {
183+ anchors {
154− left: parent.left
184+ left: parent.left
155− right: parent.right
185+ right: parent.right
186+ }
187+ visible: body != ""
188+ fontSize: "small"
189+ color: Theme.palette.selected.backgroundText
190+ opacity: 0.6
191+ wrapMode: Text.WordWrap
192+ maximumLineCount: 10
193+ elide: Text.ElideRight
156 }
194 }
157− visible: body != ""
158− fontSize: "small"
159− color: Theme.palette.selected.backgroundText
160− opacity: 0.6
161− wrapMode: Text.WordWrap
162− maximumLineCount: 10
163− elide: Text.ElideRight
164 }
195 }
165 }
196 }
166− }
167
197
168− Column {
198+ Column {
169− objectName: "dialogListView"
199+ objectName: "dialogListView"
170− spacing: units.gu(2)
200+ spacing: units.gu(2)
171
201
172− visible: count > 0
202+ visible: count > 0
173
203
174− anchors.left: parent.left; anchors.right: parent.right
204+ anchors.left: parent.left; anchors.right: parent.right
175
205
176− Repeater {
206+ Repeater {
177− model: unityMenuModel
207+ model: unityMenuModel
178
208
179− NotificationMenuItemFactory {
209+ NotificationMenuItemFactory {
180− anchors.left: parent.left; anchors.right: parent.right
210+ anchors.left: parent.left; anchors.right: parent.right
181
211
182− menuModel: unityMenuModel
212+ menuModel: unityMenuModel
183− menuData: model
213+ menuData: model
184− menuIndex: index
214+ menuIndex: index
215+ }
185 }
216 }
186 }
217 }
187− }
188
218
189− Item {
219+ Item {
190− id: buttonRow
220+ id: buttonRow
191
221
192− objectName: "buttonRow"
222+ objectName: "buttonRow"
193− anchors {
223+ anchors {
194− left: parent.left
224+ left: parent.left
195− right: parent.right
225+ right: parent.right
196− }
226+ }
197− visible: notification.type == Notification.SnapDecision && actionRepeater.count > 0
227+ visible: notification.type == Notification.SnapDecision && actionRepeater.count > 0
198− height: units.gu(5)
228+ height: units.gu(5)
199
229
200− property real buttonWidth: (width - contentColumn.spacing) / 2
230+ property real buttonWidth: (width - contentColumn.spacing) / 2
201− property bool expanded
231+ property bool expanded
202
232
203− Button {
233+ Button {
204− id: leftButton
234+ id: leftButton
205
235
206− objectName: "button1"
236+ objectName: "button1"
207− width: parent.expanded ? parent.width : parent.buttonWidth
237+ width: parent.expanded ? parent.width : parent.buttonWidth
208− anchors {
238+ anchors {
209− top: parent.top
239+ top: parent.top
210− bottom: parent.bottom
240+ bottom: parent.bottom
211− }
241+ }
212− text: notification.type == Notification.SnapDecision && actionRepeater.count >= 2 ? actionRepeater.itemAt(1).actionLabel : ""
242+ text: notification.type == Notification.SnapDecision && actionRepeater.count >= 2 ? actionRepeater.itemAt(1).actionLabel : ""
213− gradient: UbuntuColors.greyGradient
243+ gradient: UbuntuColors.greyGradient
214− onClicked: {
244+ onClicked: {
215− if (actionRepeater.count > 2) {
245+ if (actionRepeater.count > 2) {
216− buttonRow.expanded = !buttonRow.expanded
246+ buttonRow.expanded = !buttonRow.expanded
217− } else {
247+ } else {
218− notification.notification.invokeAction(actionRepeater.itemAt(1).actionId)
248+ notification.notification.invokeAction(actionRepeater.itemAt(1).actionId)
249+ }
250+ }
251+
252+ Behavior on width {
253+ UbuntuNumberAnimation {
254+ duration: UbuntuAnimation.SnapDuration
255+ }
219 }
256 }
220 }
257 }
221
258
222− Behavior on width {
259+ Button {
223− UbuntuNumberAnimation {
260+ id: rightButton
224− duration: UbuntuAnimation.SnapDuration
261+
262+ objectName: "button0"
263+ anchors {
264+ left: leftButton.right
265+ leftMargin: contentColumn.spacing
266+ right: parent.right
225 }
267 }
268+ text: notification.type == Notification.SnapDecision && actionRepeater.count >= 1 ? actionRepeater.itemAt(0).actionLabel : ""
269+ anchors {
270+ top: parent.top
271+ bottom: parent.bottom
272+ }
273+ gradient: notification.hints["x-canonical-private-button-tint"] == "true" ? UbuntuColors.orangeGradient : UbuntuColors.greyGradient
274+ visible: width > 0
275+ onClicked: notification.notification.invokeAction(actionRepeater.itemAt(0).actionId)
226 }
276 }
227 }
277 }
228
278
229− Button {
279+ Column {
230− id: rightButton
231−
232− objectName: "button0"
280+ objectName: "buttonColumn"
281+ spacing: contentColumn.spacing
233 anchors {
282 anchors {
234− left: leftButton.right
283+ left: parent.left
235− leftMargin: contentColumn.spacing
236 right: parent.right
284 right: parent.right
237 }
285 }
238− text: notification.type == Notification.SnapDecision && actionRepeater.count >= 1 ? actionRepeater.itemAt(0).actionLabel : ""
239− anchors {
240− top: parent.top
241− bottom: parent.bottom
242− }
243− gradient: notification.hints["x-canonical-private-button-tint"] == "true" ? UbuntuColors.orangeGradient : UbuntuColors.greyGradient
244− visible: width > 0
245− onClicked: notification.notification.invokeAction(actionRepeater.itemAt(0).actionId)
246− }
247− }
248
286
249− Column {
287+ // calculate initial position before Column takes over
250− objectName: "buttonColumn"
251− spacing: contentColumn.spacing
288+ y: buttonRow.y + buttonRow.height + contentColumn.spacing
252− anchors {
253− left: parent.left
254− right: parent.right
255− }
256
289
257− // calculate initial position before Column takes over
290+ visible: notification.type == Notification.SnapDecision
258− y: buttonRow.y + buttonRow.height + contentColumn.spacing
291+ height: buttonRow.expanded ? implicitHeight : 0
259
292
260− visible: notification.type == Notification.SnapDecision
293+ Repeater {
261− height: buttonRow.expanded ? implicitHeight : 0
294+ id: actionRepeater
262
295
263− Repeater {
296+ model: notification.actions
264− id: actionRepeater
297+ delegate: Loader {
298+ id: loader
265
299
266− model: notification.actions
300+ property string actionId: id
267− delegate: Loader {
301+ property string actionLabel: label
268− id: loader
269
302
270− property string actionId: id
303+ anchors {
271− property string actionLabel: label
304+ left: parent.left
305+ right: parent.right
306+ }
272
307
273− anchors {
308+ Component {
274− left: parent.left
309+ id: actionButton
275− right: parent.right
276− }
277
310
278− Component {
311+ Button {
279− id: actionButton
312+ objectName: "button" + index
313+ anchors {
314+ left: parent.left
315+ right: parent.right
316+ }
280
317
281− Button {
318+ text: loader.actionLabel
282− objectName: "button" + index
319+ height: units.gu(5)
283− anchors {
320+ gradient: UbuntuColors.greyGradient
284− left: parent.left
321+ onClicked: notification.notification.invokeAction(loader.actionId)
285− right: parent.right
286 }
322 }
287−
288− text: loader.actionLabel
289− height: units.gu(5)
290− gradient: UbuntuColors.greyGradient
291− onClicked: notification.notification.invokeAction(loader.actionId)
292 }
323 }
324+ sourceComponent: (index == 0 || index == 1) ? undefined : actionButton
293 }
325 }
294− sourceComponent: (index == 0 || index == 1) ? undefined : actionButton
295 }
326 }
296 }
327 }
297 }
328 }
Notifications/NotificationMenuItemFactory.qml+4−1
@@ -75,8 +75,11 @@ Loader {
75
75
76 Component {
76 Component {
77 id: pinLock
77 id: pinLock
78− PinLockscreen {
78+
79+ Lockscreen {
79 anchors.left: parent.left; anchors.right: parent.right
80 anchors.left: parent.left; anchors.right: parent.right
81+ height: units.gu(60)
82+ background: shell.background
80
83
81 Component.onCompleted: {
84 Component.onCompleted: {
82 menuModel.loadExtendedAttributes(menuIndex, {'x-canonical-pin-length': 'int'});
85 menuModel.loadExtendedAttributes(menuIndex, {'x-canonical-pin-length': 'int'});
Shell.qml+7−3
@@ -688,13 +688,17 @@ FocusScope {
688 id: notifications
688 id: notifications
689
689
690 model: NotificationBackend.Model
690 model: NotificationBackend.Model
691+ property real margin: units.gu(1)
692+ property real fullHeight: parent.height
693+ property real panelHeight: panel.panelHeight
694+
691 anchors {
695 anchors {
692 top: parent.top
696 top: parent.top
693 right: parent.right
697 right: parent.right
694 bottom: parent.bottom
698 bottom: parent.bottom
695− leftMargin: units.gu(1)
699+ leftMargin: margin
696− rightMargin: units.gu(1)
700+ rightMargin: margin
697− topMargin: panel.panelHeight + units.gu(1)
701+ topMargin: panel.panelHeight + margin
698 }
702 }
699 states: [
703 states: [
700 State {
704 State {