on xenial help sign in
introduce a boolean "expanded" property as a replacement for the removed

expanded/contracted states

commit6576f2a2fd48a8294209a18a72641119ef356543 authorLukáš Tinkl <lukas.tinkl@canonical.com> dateWed 13 Apr 2016, 16:39 (11 years ago) parente82ae4e
2 files changed+17−17
qml/Notifications/Notification.qml+11−11 tests/qmltests/Notifications/tst_VisualSnapDecisionsQueue.qml+6−6
qml/Notifications/Notification.qml+11−11
@@ -55,21 +55,21 @@ StyledItem {
5555 name: "Ubuntu.Components.Themes.Ambiance"
5656 }
5757
58− state: {
59− var result = "";
58+ readonly property bool expanded: {
59+ var result = false;
6060
6161 if (type === Notification.SnapDecision) {
6262 if (ListView.view.currentIndex === index) {
63− result = "expanded";
63+ result = true;
6464 } else {
6565 if (ListView.view.count > 2) {
6666 if (ListView.view.currentIndex === -1 && index == 1) {
67− result = "expanded";
67+ result = true;
6868 } else {
69− result = "contracted";
69+ result = false;
7070 }
7171 } else {
72− result = "expanded";
72+ result = true;
7373 }
7474 }
7575 }
@@ -325,12 +325,12 @@ StyledItem {
325325 }
326326
327327 ListItem.ThinDivider {
328− visible: type === Notification.SnapDecision && notification.state !== "contracted"
328+ visible: type === Notification.SnapDecision && notification.expanded
329329 }
330330
331331 Icon {
332332 source: "arrow-down.png"
333− visible: type === Notification.SnapDecision && notification.state === "contracted"
333+ visible: type === Notification.SnapDecision && !notification.expanded
334334 width: units.gu(2)
335335 height: units.gu(0.6)
336336 anchors.horizontalCenter: parent.horizontalCenter
@@ -428,7 +428,7 @@ StyledItem {
428428
429429 spacing: notification.margins
430430
431− visible: notification.type === Notification.SnapDecision && oneOverTwoRepeaterTop.count === 3 && notification.state === "expanded"
431+ visible: notification.type === Notification.SnapDecision && oneOverTwoRepeaterTop.count === 3 && notification.expanded
432432
433433 Repeater {
434434 id: oneOverTwoRepeaterTop
@@ -497,7 +497,7 @@ StyledItem {
497497 left: parent.left
498498 right: parent.right
499499 }
500− visible: notification.type === Notification.SnapDecision && actionRepeater.count > 0 && !oneOverTwoCase.visible && notification.state === "expanded"
500+ visible: notification.type === Notification.SnapDecision && actionRepeater.count > 0 && !oneOverTwoCase.visible && notification.expanded
501501 spacing: notification.margins
502502 layoutDirection: Qt.RightToLeft
503503
@@ -567,7 +567,7 @@ StyledItem {
567567 right: parent.right
568568 }
569569
570− visible: notification.type === Notification.SnapDecision && actionRepeater.count > 3 && !oneOverTwoCase.visible && notification.state === "expanded"
570+ visible: notification.type === Notification.SnapDecision && actionRepeater.count > 3 && !oneOverTwoCase.visible && notification.expanded
571571 model: notification.actions
572572 expanded: false
573573 startIndex: 2
tests/qmltests/Notifications/tst_VisualSnapDecisionsQueue.qml+6−6
@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2014 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
@@ -216,9 +216,9 @@ Row {
216216 }
217217
218218 // check initial states once all five snap-decisions were appended to the model
219− compare(snap_decision[0].state, "expanded", "state of first snap-decision is not expanded");
219+ compare(snap_decision[0].expanded, true, "state of first snap-decision is not expanded");
220220 for (var index = 1; index < snap_decision.length; index++) {
221− compare(snap_decision[index].state, "contracted", "state of "+ index + ".snap-decision is not contracted");
221+ compare(snap_decision[index].expanded, false, "state of "+ index + ".snap-decision is not contracted");
222222 }
223223
224224 // click/tap on each snap-decision and verify only one is in expanded-state at any time
@@ -226,9 +226,9 @@ Row {
226226 mouseClick(snap_decision[index])
227227 for (var kindex = 0; kindex < snap_decision.length; kindex++) {
228228 if (kindex == index) {
229− compare(snap_decision[kindex].state, "expanded", "state of "+ kindex + ".snap-decision is not expanded");
229+ compare(snap_decision[kindex].expanded, true, "state of "+ kindex + ".snap-decision is not expanded");
230230 } else {
231− compare(snap_decision[kindex].state, "contracted", "state of "+ kindex + ".snap-decision is not contracted");
231+ compare(snap_decision[kindex].expanded, false, "state of "+ kindex + ".snap-decision is not contracted");
232232 }
233233 }
234234 }
@@ -241,7 +241,7 @@ Row {
241241
242242 for (var index = 1; index < snap_decision.length; index++) {
243243 removeTopMostNotification();
244− compare(snap_decision[index].state, "expanded", "state of " + index + ". snap-decision is not expanded");
244+ compare(snap_decision[index].expanded, true, "state of " + index + ". snap-decision is not expanded");
245245 }
246246 }
247247 }