on xenial help sign in
fixes for topmost fullscreen notification, get rid of placeholder
commitc550de2c5c65167011aa0b7671bce3bf7a819413 authorLukáš Tinkl <lukas.tinkl@canonical.com> dateTue 2 Aug 2016, 12:28 (10 years ago) parent32de787
9 files changed+41−144
qml/Notifications/Notification.qml+14−27 qml/Notifications/NotificationMenuItemFactory.qml−2 qml/Notifications/Notifications.qml+3−25 tests/mocks/Unity/Notifications/MockNotificationModel.cpp+4−6 tests/mocks/Unity/Notifications/MockNotificationModel.h+2−4 tests/qmltests/Notifications/tst_Notifications.qml+6−23 tests/qmltests/Notifications/tst_OptionToggle.qml+1−16 tests/qmltests/Notifications/tst_SwipeToAct.qml+4−18 tests/qmltests/Notifications/tst_VisualSnapDecisionsQueue.qml+7−23
qml/Notifications/Notification.qml+14−27
@@ -55,29 +55,11 @@ StyledItem {
5555 name: "Ubuntu.Components.Themes.Ambiance"
5656 }
5757
58− signal dismissed()
59−
60− readonly property bool expanded: {
61− var result = false;
62−
63− if (type === Notification.SnapDecision) {
64− if (ListView.view.currentIndex === index || fullscreen) {
65− result = true;
66− } else {
67− if (ListView.view.count > 2) {
68− if (ListView.view.currentIndex === -1 && index == 1) {
69− result = true;
70− } else {
71− result = false;
72− }
73− } else {
74− result = true;
75− }
76− }
77− }
78−
79− return result;
80− }
58+ readonly property bool expanded: type === Notification.SnapDecision && // expand only snap decisions, if...
59+ (fullscreen || // - it's a fullscreen one
60+ ListView.view.currentIndex === index || // - it's the one the user clicked on
61+ (ListView.view.currentIndex === -1 && index == 0) // - the first one after the user closed the previous one
62+ )
8163
8264 NotificationAudio {
8365 id: sound
@@ -116,6 +98,13 @@ StyledItem {
11698 }
11799 }
118100
101+ Binding {
102+ target: ListView.view
103+ property: "topmostIsFullscreen"
104+ value: fullscreen
105+ when: index == 0
106+ }
107+
119108 function closeNotification() {
120109 if (index === ListView.view.currentIndex) { // reset to get the 1st snap decision expanded
121110 ListView.view.currentIndex = -1;
@@ -125,7 +114,6 @@ StyledItem {
125114 notification.notification.invokeAction(notification.actions.data(1, ActionModel.RoleActionId));
126115
127116 notification.notification.close();
128− notification.dismissed()
129117 }
130118
131119 Behavior on x {
@@ -144,7 +132,8 @@ StyledItem {
144132 }
145133 }
146134
147− Behavior on height {
135+ Behavior on implicitHeight {
136+ enabled: !fullscreen
148137 UbuntuNumberAnimation {
149138 duration: UbuntuAnimation.SnapDuration
150139 }
@@ -217,7 +206,6 @@ StyledItem {
217206 onNameOwnerChanged: {
218207 if (lastNameOwner !== "" && nameOwner === "" && notification.notification !== undefined) {
219208 notification.notification.close()
220− notification.dismissed()
221209 }
222210 lastNameOwner = nameOwner
223211 }
@@ -443,7 +431,6 @@ StyledItem {
443431 }
444432 onAccepted: {
445433 notification.notification.invokeAction(actionRepeater.itemAt(0).actionId)
446− notification.dismissed()
447434 }
448435 }
449436 }
qml/Notifications/NotificationMenuItemFactory.qml−2
@@ -155,13 +155,11 @@ Loader {
155155
156156 onCancel: {
157157 menuModel.activate(menuIndex, false);
158− notification.dismissed()
159158 }
160159
161160 onEmergencyCall: {
162161 shell.startLockedApp("dialer-app");
163162 menuModel.activate(menuIndex, false);
164− notification.dismissed()
165163 }
166164
167165 property var extendedData: menuData && menuData.ext || undefined
qml/Notifications/Notifications.qml+3−25
@@ -26,7 +26,7 @@ ListView {
2626 objectName: "notificationList"
2727 interactive: false
2828
29− readonly property bool hasNotification: count > 1 // placeholder is index 0
29+ readonly property bool hasNotification: count > 0
3030 property real margin
3131 property bool hasMouse
3232 property url background: ""
@@ -42,17 +42,10 @@ ListView {
4242 filterRegExp: RegExp(UnityNotifications.Notification.SnapDecision)
4343 }
4444
45− readonly property bool topmostIsFullscreen: fullscreenIndex != -1
45+ property bool topmostIsFullscreen: false
4646 spacing: topmostIsFullscreen ? 0 : units.gu(1)
4747
48− currentIndex: count > 1 ? 1 : -1
49−
50− property int fullscreenIndex: -1
51− onFullscreenIndexChanged: {
52− if (fullscreenIndex != -1) {
53− positionViewAtIndex(fullscreenIndex, ListView.Beginning);
54− }
55− }
48+ currentIndex: -1
5649
5750 delegate: Notification {
5851 objectName: "notification" + index
@@ -76,21 +69,6 @@ ListView {
7669 // elements in a notification
7770 // FIXME: disabled all transitions because of LP: #1354406 workaround
7871 //layer.enabled: add.running || remove.running || populate.running
79−
80− onFullscreenChanged: updateListTopMostIsFullscreen();
81−
82− function updateListTopMostIsFullscreen() {
83− if (fullscreen) {
84− fullscreenIndex = index;
85− }
86− }
87−
88− onDismissed: {
89− if (fullscreenIndex == index) {
90− fullscreenIndex = -1;
91− notificationList.positionViewAtBeginning();
92− }
93− }
9472 }
9573
9674 // FIXME: disabled all transitions because of LP: #1354406 workaround
tests/mocks/Unity/Notifications/MockNotificationModel.cpp+4−6
@@ -1,5 +1,5 @@
11/*
2− * Copyright 2015 Canonical Ltd.
2+ * Copyright 2015-2016 Canonical Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU Lesser General Public License as published by
@@ -13,8 +13,6 @@
1313 * You should have received a copy of the GNU Lesser General Public License
1414 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1515 *
16− * Authors:
17− * Mirco Mueller <mirco.mueller@canonical.com>
1816 */
1917
2018#include "MockNotificationModel.h"
@@ -118,10 +116,10 @@ void MockNotificationModel::remove(const int id) {
118116 }
119117}
120118
121−void MockNotificationModel::removeSecond() {
122− if(m_queue.size() < 2)
119+void MockNotificationModel::removeFirst() {
120+ if(m_queue.isEmpty())
123121 return;
124− removeInternal(1);
122+ removeInternal(0);
125123}
126124
127125void MockNotificationModel::removeInternal(int loc) {
tests/mocks/Unity/Notifications/MockNotificationModel.h+2−4
@@ -1,5 +1,5 @@
11/*
2− * Copyright 2015 Canonical Ltd.
2+ * Copyright 2015-2016 Canonical Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU Lesser General Public License as published by
@@ -13,8 +13,6 @@
1313 * You should have received a copy of the GNU Lesser General Public License
1414 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1515 *
16− * Authors:
17− * Mirco Mueller <mirco.mueller@canonical.com>
1816 */
1917
2018#ifndef MOCK_NOTIFICATION_MODEL_H
@@ -48,7 +46,7 @@ public:
4846
4947 Q_INVOKABLE int queued() const;
5048 Q_INVOKABLE void remove(const int id);
51− Q_INVOKABLE void removeSecond();
49+ Q_INVOKABLE void removeFirst();
5250
5351 int getCount() const;
5452
tests/qmltests/Notifications/tst_Notifications.qml+6−23
@@ -1,5 +1,5 @@
11/*
2− * Copyright 2015 Canonical Ltd.
2+ * Copyright 2015-2016 Canonical Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU Lesser General Public License as published by
@@ -31,21 +31,6 @@ Item {
3131 height: notificationsRect.height
3232 property int index: 0
3333
34− // add the default/PlaceHolder notification to the model
35− Component.onCompleted: {
36− var component = Qt.createComponent("Notification.qml")
37− var n = component.createObject("notification", {"nid": index++,
38− "type": Notification.PlaceHolder,
39− "hints": {},
40− "summary": "",
41− "body": "",
42− "icon": "",
43− "secondaryIcon": "",
44− "rawActions": []})
45− n.completed.connect(mockModel.onCompleted)
46− mockModel.append(n)
47− }
48−
4934 Row {
5035 id: rootRow
5136
@@ -157,15 +142,13 @@ Item {
157142 }
158143
159144 function clearNotifications() {
160− while(mockModel.count > 1) {
161− remove1stNotification()
145+ while(mockModel.count > 0) {
146+ remove1stNotification();
162147 }
163148 }
164149
165150 function remove1stNotification() {
166− if (mockModel.count > 1) {
167− mockModel.removeSecond()
168− }
151+ mockModel.removeFirst();
169152 }
170153
171154 Rectangle {
@@ -791,13 +774,13 @@ Item {
791774 waitForRendering(notifications);
792775
793776 // first one should be expanded by default
794− var notification1 = findChild(notifications, "notification1") // 0 is placeholder...
777+ var notification1 = findChild(notifications, "notification0")
795778 verify(!!notification1, "notification wasn't found");
796779 waitForRendering(notification1);
797780 verify(notification1.expanded);
798781
799782 // click the 2nd one, verify it's now expanded
800− var notification2 = findChild(notifications, "notification2") // 0 is placeholder...
783+ var notification2 = findChild(notifications, "notification1")
801784 verify(!!notification2, "notification wasn't found");
802785 waitForRendering(notification2);
803786 mouseClick(notification2);
tests/qmltests/Notifications/tst_OptionToggle.qml+1−16
@@ -1,5 +1,5 @@
11/*
2− * Copyright 2015 Canonical Ltd.
2+ * Copyright 2015-2016 Canonical Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU Lesser General Public License as published by
@@ -51,21 +51,6 @@ Row {
5151 function getRaw(id) {
5252 return mockNotification.createObject(mockModel)
5353 }
54−
55− // add the default/PlaceHolder notification to the model
56− Component.onCompleted: {
57− var n = {
58− type: Notification.PlaceHolder,
59− hints: {},
60− summary: "",
61− body: "",
62− icon: "",
63− secondaryIcon: "",
64− actions: []
65− }
66−
67− append(n)
68− }
6954 }
7055
7156 function addSnapDecisionNotification() {
tests/qmltests/Notifications/tst_SwipeToAct.qml+4−18
@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2014, 2015 Canonical, Ltd.
2+ * Copyright (C) 2014-2016 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -53,21 +53,6 @@ Item {
5353 function getRaw(id) {
5454 return mockNotification.createObject(mockModel)
5555 }
56−
57− // add the default/PlaceHolder notification to the model
58− Component.onCompleted: {
59− var n = {
60− type: Notification.PlaceHolder,
61− hints: {},
62− summary: "",
63− body: "",
64− icon: "",
65− secondaryIcon: "",
66− actions: []
67− }
68−
69− append(n)
70− }
7156 }
7257
7358 function addSwipeToActNotification() {
@@ -93,8 +78,9 @@ Item {
9378 }
9479
9580 function remove1stNotification() {
96− if (mockModel.count > 0)
97− mockModel.remove(0)
81+ if (mockModel.count > 0) {
82+ mockModel.remove(0);
83+ }
9884 }
9985
10086 Rectangle {
tests/qmltests/Notifications/tst_VisualSnapDecisionsQueue.qml+7−23
@@ -47,21 +47,6 @@ Row {
4747 function getRaw(id) {
4848 return mockNotification.createObject(mockModel)
4949 }
50−
51− // add the default/PlaceHolder notification to the model
52− Component.onCompleted: {
53− var n = {
54− type: Notification.PlaceHolder,
55− hints: {},
56− summary: "",
57− body: "",
58− icon: "",
59− secondaryIcon: "",
60− actions: []
61− }
62−
63− append(n)
64− }
6550 }
6651
6752 function addSomeSnapDecisionNotifications() {
@@ -123,14 +108,13 @@ Row {
123108 }
124109
125110 function clearNotifications() {
126− // remove all but the first (PlaceHolder) notification
127− mockModel.remove(1, mockModel.count - 1)
111+ mockModel.clear();
128112 }
129113
130114 function removeTopMostNotification() {
131− // leave real/first (PlaceHolder) notification untouched
132− if (mockModel.count > 1)
133− mockModel.remove(1)
115+ if (mockModel.count > 0) {
116+ mockModel.remove(0);
117+ }
134118 }
135119
136120 Rectangle {
@@ -205,11 +189,11 @@ Row {
205189 notifications.forceLayout();
206190 waitForRendering(notifications);
207191
208− var snap_decision = [findChild(notifications, "notification1"),
192+ var snap_decision = [findChild(notifications, "notification0"),
193+ findChild(notifications, "notification1"),
209194 findChild(notifications, "notification2"),
210195 findChild(notifications, "notification3"),
211− findChild(notifications, "notification4"),
212− findChild(notifications, "notification5")]
196+ findChild(notifications, "notification4")]
213197
214198 for (var index = 0; index < snap_decision.length; index++) {
215199 verify(snap_decision[index] !== undefined, index + ". snap-decision wasn't found");