on xenial help sign in
implement close button and fix tests for it
470a813Michael Zanetti
qml/Stage/Spread/SpreadDelegateInputArea.qml+27
@@ -7,6 +7,7 @@ Item {
7 id: root
7 id: root
8
8
9 property bool closeable: true
9 property bool closeable: true
10+ property int closeIconOffset: 0
10 readonly property real minSpeedToClose: units.gu(40)
11 readonly property real minSpeedToClose: units.gu(40)
11 property bool zeroVelocityCounts: false
12 property bool zeroVelocityCounts: false
12
13
@@ -77,6 +78,32 @@ Item {
77 onClicked: root.clicked()
78 onClicked: root.clicked()
78 }
79 }
79
80
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+
80 MultiPointTouchArea {
107 MultiPointTouchArea {
81 anchors.fill: parent
108 anchors.fill: parent
82 mouseEnabled: false
109 mouseEnabled: false
qml/Stage/Spread/SpreadMaths.qml+1−1
@@ -63,7 +63,7 @@ Item {
63 readonly property real shadowOpacity: 0.2 * (1 - rightStackingProgress) * (1 - leftStackingProgress)
63 readonly property real shadowOpacity: 0.2 * (1 - rightStackingProgress) * (1 - leftStackingProgress)
64
64
65
65
66− readonly property real closeIconOffset: (scale - 1) * (-root.spreadHeight / 2)
66+ readonly property real closeIconOffset: (targetScale - 1) * (-spread.stackHeight / 2)
67
67
68 readonly property real tileInfoOpacity: Math.min(MathUtils.clamp(MathUtils.map(leftStackingProgress, 0 , 1/(spread.stackItemCount*3), 1, 0), 0 , 1),
68 readonly property real tileInfoOpacity: Math.min(MathUtils.clamp(MathUtils.map(leftStackingProgress, 0 , 1/(spread.stackItemCount*3), 1, 0), 0 , 1),
69 MathUtils.clamp(MathUtils.map(spreadPosition, 0.9 , 1, 1, 0), 0 , 1)) /** MathUtils.map(curvedSwitcherProgress, 0.7, 0.9, 0, 1)*/
69 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 {
640 }
640 }
641 }
641 }
642
642
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−
650 onFocusChanged: {
643 onFocusChanged: {
651 if (appRepeater.startingUp)
644 if (appRepeater.startingUp)
652 return;
645 return;
@@ -676,7 +669,6 @@ AbstractStage {
676 if (!appRepeater.startingUp) {
669 if (!appRepeater.startingUp) {
677 // a top level window is always the focused one when it first appears, unfocusing
670 // a top level window is always the focused one when it first appears, unfocusing
678 // any preexisting one
671 // any preexisting one
679− print("***** focusing after starting up", model.application.appId)
680 focus = true;
672 focus = true;
681 }
673 }
682 }
674 }
@@ -695,7 +687,6 @@ AbstractStage {
695 for (var i = 0; i < appRepeater.count; i++) {
687 for (var i = 0; i < appRepeater.count; i++) {
696 var appDelegate = appRepeater.itemAt(i);
688 var appDelegate = appRepeater.itemAt(i);
697 if (appDelegate && !appDelegate.minimized && i != index) {
689 if (appDelegate && !appDelegate.minimized && i != index) {
698− print("***** focusing because of previously focused window disappeared", appDelegate.application.appId)
699 appDelegate.focus = true;
690 appDelegate.focus = true;
700 return;
691 return;
701 }
692 }
@@ -1328,6 +1319,7 @@ AbstractStage {
1328 anchors.fill: parent
1319 anchors.fill: parent
1329 enabled: false
1320 enabled: false
1330 closeable: model.application.appId !== "unity8-dash"
1321 closeable: model.application.appId !== "unity8-dash"
1322+ closeIconOffset: spreadMaths.closeIconOffset
1331
1323
1332 onClicked: {
1324 onClicked: {
1333 spreadItem.highlightedIndex = index;
1325 spreadItem.highlightedIndex = index;
tests/qmltests/tst_Shell.qml+10−8
@@ -50,6 +50,8 @@ Rectangle {
50 shellLoader.active = true;
50 shellLoader.active = true;
51 }
51 }
52
52
53+ property var shell: shellLoader.item ? shellLoader.item : null
54+
53 Item {
55 Item {
54 id: shellContainer
56 id: shellContainer
55 anchors.left: root.left
57 anchors.left: root.left
@@ -302,7 +304,7 @@ Rectangle {
302 }
304 }
303
305
304 Repeater {
306 Repeater {
305− id: appRepeater
307+ id: appCheckBoxRepeater
306 model: ApplicationManager.availableApplications
308 model: ApplicationManager.availableApplications
307 ApplicationCheckBox {
309 ApplicationCheckBox {
308 appId: modelData
310 appId: modelData
@@ -1707,11 +1709,8 @@ Rectangle {
1707 function test_altBackTabNavigation() {
1709 function test_altBackTabNavigation() {
1708 loadDesktopShellWithApps();
1710 loadDesktopShellWithApps();
1709
1711
1710− print("findItem")
1711 var spreadItem = findChild(shell, "spreadItem");
1712 var spreadItem = findChild(shell, "spreadItem");
1712− print("starting verify")
1713 verify(spreadItem !== null);
1713 verify(spreadItem !== null);
1714− print("verify done")
1715
1714
1716 keyPress(Qt.Key_Alt)
1715 keyPress(Qt.Key_Alt)
1717 keyClick(Qt.Key_Tab);
1716 keyClick(Qt.Key_Tab);
@@ -1769,21 +1768,24 @@ Rectangle {
1769 function test_closeFromSpread() {
1768 function test_closeFromSpread() {
1770 loadDesktopShellWithApps()
1769 loadDesktopShellWithApps()
1771
1770
1772− var spreadRepeater = findInvisibleChild(shell, "spreadRepeater");
1771+ var appRepeater = findInvisibleChild(shell, "appRepeater");
1772+ verify(appRepeater !== null);
1773+
1774+ var spreadItem = findChild(shell, "spreadItem");
1773− verify(spreadRepeater !== null);
1775+ verify(spreadItem !== null);
1774
1776
1775 keyPress(Qt.Key_Alt)
1777 keyPress(Qt.Key_Alt)
1776 keyClick(Qt.Key_Tab);
1778 keyClick(Qt.Key_Tab);
1777
1779
1778 var surfaceId = topLevelSurfaceList.idAt(2);
1780 var surfaceId = topLevelSurfaceList.idAt(2);
1779− var spreadDelegate2 = spreadRepeater.itemAt(2);
1781+ var spreadDelegate2 = appRepeater.itemAt(2);
1780 var closeMouseArea = findChild(spreadDelegate2, "closeMouseArea");
1782 var closeMouseArea = findChild(spreadDelegate2, "closeMouseArea");
1781
1783
1782 // Move the mosue over tile 2 and verify the close button becomes visible
1784 // Move the mosue over tile 2 and verify the close button becomes visible
1783 var x = 0;
1785 var x = 0;
1784 var y = shell.height * .5;
1786 var y = shell.height * .5;
1785 mouseMove(shell, x, y)
1787 mouseMove(shell, x, y)
1786− while (spreadRepeater.highlightedIndex !== 2 && x <= 4000) {
1788+ while (spreadItem.highlightedIndex !== 2 && x <= 4000) {
1787 x+=10;
1789 x+=10;
1788 mouseMove(shell, x, y)
1790 mouseMove(shell, x, y)
1789 wait(0); // spin the loop so bindings get evaluated
1791 wait(0); // spin the loop so bindings get evaluated