on xenial help sign in
implement close button and fix tests for it
commit470a813857aea501870451708971b1563dfcf148 authorMichael Zanetti <michael.zanetti@canonical.com> dateMon 29 Aug 2016, 18:41 (10 years ago) parent9c7f7ba
4 files changed+39−18
qml/Stage/Spread/SpreadDelegateInputArea.qml+27 qml/Stage/Spread/SpreadMaths.qml+1−1 qml/Stage/Stage.qml+1−9 tests/qmltests/tst_Shell.qml+10−8
qml/Stage/Spread/SpreadDelegateInputArea.qml+27
@@ -7,6 +7,7 @@ Item {
77 id: root
88
99 property bool closeable: true
10+ property int closeIconOffset: 0
1011 readonly property real minSpeedToClose: units.gu(40)
1112 property bool zeroVelocityCounts: false
1213
@@ -77,6 +78,32 @@ Item {
7778 onClicked: root.clicked()
7879 }
7980
81+ MouseArea {
82+ id: closeButtonMouseArea
83+ objectName: "closeMouseArea"
84+ anchors {
85+ left: parent.left;
86+ leftMargin: -width / 2
87+ top: parent.top;
88+ topMargin: root.closeIconOffset - height / 2
89+ }
90+ width: units.gu(3)
91+ height: width
92+ hoverEnabled: true
93+ onClicked: root.close()
94+
95+ Image {
96+ anchors.centerIn: parent
97+ width: units.gu(2)
98+ height: width
99+ sourceSize.width: width
100+ sourceSize.height: height
101+ source: "../graphics/window-close.svg"
102+ visible: mouseArea.containsMouse || closeButtonMouseArea.containsMouse
103+ }
104+ }
105+
106+
80107 MultiPointTouchArea {
81108 anchors.fill: parent
82109 mouseEnabled: false
qml/Stage/Spread/SpreadMaths.qml+1−1
@@ -63,7 +63,7 @@ Item {
6363 readonly property real shadowOpacity: 0.2 * (1 - rightStackingProgress) * (1 - leftStackingProgress)
6464
6565
66− readonly property real closeIconOffset: (scale - 1) * (-root.spreadHeight / 2)
66+ readonly property real closeIconOffset: (targetScale - 1) * (-spread.stackHeight / 2)
6767
6868 readonly property real tileInfoOpacity: Math.min(MathUtils.clamp(MathUtils.map(leftStackingProgress, 0 , 1/(spread.stackItemCount*3), 1, 0), 0 , 1),
6969 MathUtils.clamp(MathUtils.map(spreadPosition, 0.9 , 1, 1, 0), 0 , 1)) /** MathUtils.map(curvedSwitcherProgress, 0.7, 0.9, 0, 1)*/
qml/Stage/Stage.qml+1−9
@@ -640,13 +640,6 @@ AbstractStage {
640640 }
641641 }
642642
643−// Timer {
644−// interval: 1000
645−// repeat: true
646−// running: index == 0
647−// onTriggered: print("index", index, "focused:", appDelegate.focus, "x", appDelegate.x, "state", appDelegate.state)
648−// }
649−
650643 onFocusChanged: {
651644 if (appRepeater.startingUp)
652645 return;
@@ -676,7 +669,6 @@ AbstractStage {
676669 if (!appRepeater.startingUp) {
677670 // a top level window is always the focused one when it first appears, unfocusing
678671 // any preexisting one
679− print("***** focusing after starting up", model.application.appId)
680672 focus = true;
681673 }
682674 }
@@ -695,7 +687,6 @@ AbstractStage {
695687 for (var i = 0; i < appRepeater.count; i++) {
696688 var appDelegate = appRepeater.itemAt(i);
697689 if (appDelegate && !appDelegate.minimized && i != index) {
698− print("***** focusing because of previously focused window disappeared", appDelegate.application.appId)
699690 appDelegate.focus = true;
700691 return;
701692 }
@@ -1328,6 +1319,7 @@ AbstractStage {
13281319 anchors.fill: parent
13291320 enabled: false
13301321 closeable: model.application.appId !== "unity8-dash"
1322+ closeIconOffset: spreadMaths.closeIconOffset
13311323
13321324 onClicked: {
13331325 spreadItem.highlightedIndex = index;
tests/qmltests/tst_Shell.qml+10−8
@@ -50,6 +50,8 @@ Rectangle {
5050 shellLoader.active = true;
5151 }
5252
53+ property var shell: shellLoader.item ? shellLoader.item : null
54+
5355 Item {
5456 id: shellContainer
5557 anchors.left: root.left
@@ -302,7 +304,7 @@ Rectangle {
302304 }
303305
304306 Repeater {
305− id: appRepeater
307+ id: appCheckBoxRepeater
306308 model: ApplicationManager.availableApplications
307309 ApplicationCheckBox {
308310 appId: modelData
@@ -1707,11 +1709,8 @@ Rectangle {
17071709 function test_altBackTabNavigation() {
17081710 loadDesktopShellWithApps();
17091711
1710− print("findItem")
17111712 var spreadItem = findChild(shell, "spreadItem");
1712− print("starting verify")
17131713 verify(spreadItem !== null);
1714− print("verify done")
17151714
17161715 keyPress(Qt.Key_Alt)
17171716 keyClick(Qt.Key_Tab);
@@ -1769,21 +1768,24 @@ Rectangle {
17691768 function test_closeFromSpread() {
17701769 loadDesktopShellWithApps()
17711770
1772− var spreadRepeater = findInvisibleChild(shell, "spreadRepeater");
1773− verify(spreadRepeater !== null);
1771+ var appRepeater = findInvisibleChild(shell, "appRepeater");
1772+ verify(appRepeater !== null);
1773+
1774+ var spreadItem = findChild(shell, "spreadItem");
1775+ verify(spreadItem !== null);
17741776
17751777 keyPress(Qt.Key_Alt)
17761778 keyClick(Qt.Key_Tab);
17771779
17781780 var surfaceId = topLevelSurfaceList.idAt(2);
1779− var spreadDelegate2 = spreadRepeater.itemAt(2);
1781+ var spreadDelegate2 = appRepeater.itemAt(2);
17801782 var closeMouseArea = findChild(spreadDelegate2, "closeMouseArea");
17811783
17821784 // Move the mosue over tile 2 and verify the close button becomes visible
17831785 var x = 0;
17841786 var y = shell.height * .5;
17851787 mouseMove(shell, x, y)
1786− while (spreadRepeater.highlightedIndex !== 2 && x <= 4000) {
1788+ while (spreadItem.highlightedIndex !== 2 && x <= 4000) {
17871789 x+=10;
17881790 mouseMove(shell, x, y)
17891791 wait(0); // spin the loop so bindings get evaluated