on xenial help sign in
fix tests, some smaller fixes all around
commit91e49031b1d77120d0c4363aa51d73120cfdc2ad authorMichael Zanetti <michael.zanetti@canonical.com> dateThu 10 Dec 2015, 14:09 (11 years ago) parent673a125
6 files changed+54−42
data/com.canonical.Unity8.gschema.xml+5 qml/Launcher/Launcher.qml−3 qml/Launcher/LauncherDelegate.qml+1−1 qml/Launcher/LauncherPanel.qml+20−24 qml/Shell.qml+7−1 tests/qmltests/Launcher/tst_Launcher.qml+21−13
data/com.canonical.Unity8.gschema.xml+5
@@ -27,6 +27,11 @@
2727 <summary>Maximum push needed to overcome edge barrier</summary>
2828 <description>How much you have to push (in grid units) the mouse against an edge barrier when sensibility is 1.</description>
2929 </key>
30+ <key type="b" name="autohide-launcher">
31+ <default>false</default>
32+ <summary>Autohide the launcher</summary>
33+ <description>This will only be applied in windowed mode. In staged mode, the launcher will always hide.</description>
34+ </key>
3035 </schema>
3136
3237 <schema path="/com/canonical/unity8/greeter/" id="com.canonical.Unity8.Greeter" gettext-domain="unity8">
qml/Launcher/Launcher.qml−3
@@ -55,7 +55,6 @@ FocusScope {
5555 signal showDashHome()
5656
5757 onStateChanged: {
58− print("state changed", state)
5958 if (state == "") {
6059 dismissTimer.stop()
6160 } else {
@@ -96,7 +95,6 @@ FocusScope {
9695
9796 onLockedVisibleChanged: {
9897 if (lockedVisible && state == "") {
99− print("have to show")
10098 dismissTimer.stop();
10199 fadeOutAnimation.stop();
102100 switchToNextState("visible")
@@ -284,7 +282,6 @@ FocusScope {
284282 script: {
285283 panel.layer.enabled = false
286284 panel.animate = false;
287− print("setting state to \"\"")
288285 root.state = "";
289286 panel.x = -panel.width
290287 panel.opacity = 1;
qml/Launcher/LauncherDelegate.qml+1−1
@@ -158,7 +158,7 @@ Item {
158158 right: parent.right
159159 bottom: parent.bottom
160160 rightMargin: (iconItem.width - root.itemWidth) / 2 - units.dp(2)
161− margins: units.dp(3)
161+ margins: units.dp(5)
162162 }
163163 width: Math.min(root.itemWidth, Math.max(units.gu(2), countLabel.implicitWidth + units.gu(1)))
164164 height: units.gu(2)
qml/Launcher/LauncherPanel.qml+20−24
@@ -52,14 +52,14 @@ Rectangle {
5252 if (highlightIndex >= launcherListView.count) {
5353 highlightIndex = -1;
5454 }
55− moveAnimation.moveToIndex(Math.max(highlightIndex, 0));
55+ launcherListView.moveToIndex(Math.max(highlightIndex, 0));
5656 }
5757 function highlightPrevious() {
5858 highlightIndex--;
5959 if (highlightIndex <= -2) {
6060 highlightIndex = launcherListView.count - 1;
6161 }
62− moveAnimation.moveToIndex(Math.max(highlightIndex, 0));
62+ launcherListView.moveToIndex(Math.max(highlightIndex, 0));
6363 }
6464 function openQuicklist(index) {
6565 quickList.open(index);
@@ -136,7 +136,6 @@ Rectangle {
136136 highlightRangeMode: ListView.ApplyRange
137137 preferredHighlightBegin: (height - itemHeight) / 2
138138 preferredHighlightEnd: (height + itemHeight) / 2
139− spacing: units.gu(1)
140139
141140 // for the single peeking icon, when alert-state is set on delegate
142141 property int peekingIndex: -1
@@ -165,7 +164,7 @@ Rectangle {
165164 // The height of the area where the items reach the final folding angle
166165 property int foldingStopHeight: foldingStartHeight - itemHeight - spacing
167166 property int itemWidth: width * .75
168− property int itemHeight: itemWidth * 15 / 16
167+ property int itemHeight: itemWidth * 15 / 16 + units.gu(1)
169168 property int clickFlickSpeed: units.gu(60)
170169 property int draggedIndex: dndArea.draggedIndex
171170 property real realContentY: contentY - originY + topMargin
@@ -193,23 +192,24 @@ Rectangle {
193192
194193 UbuntuNumberAnimation {
195194 id: moveAnimation
195+ objectName: "moveAnimation"
196196 target: launcherListView
197197 property: "contentY"
198198 function moveTo(contentY) {
199199 from = launcherListView.contentY;
200200 to = contentY;
201− start();
201+ restart();
202202 }
203− function moveToIndex(index) {
204− var totalItemHeight = launcherListView.itemHeight + launcherListView.spacing
205− var itemPosition = index * totalItemHeight;
206− var height = launcherListView.height - launcherListView.topMargin - launcherListView.bottomMargin
207− var distanceToEnd = index == 0 || index == launcherListView.count - 1 ? 0 : totalItemHeight
208− if (itemPosition + totalItemHeight + distanceToEnd > launcherListView.contentY + launcherListView.originY + launcherListView.topMargin + height) {
209− moveAnimation.moveTo(itemPosition + launcherListView.itemHeight - launcherListView.topMargin - height + distanceToEnd - launcherListView.originY);
210− } else if (itemPosition - distanceToEnd < launcherListView.contentY - launcherListView.originY + launcherListView.topMargin) {
211− moveAnimation.moveTo(itemPosition - distanceToEnd - launcherListView.topMargin + launcherListView.originY);
212− }
203+ }
204+ function moveToIndex(index) {
205+ var totalItemHeight = launcherListView.itemHeight + launcherListView.spacing
206+ var itemPosition = index * totalItemHeight;
207+ var height = launcherListView.height - launcherListView.topMargin - launcherListView.bottomMargin
208+ var distanceToEnd = index == 0 || index == launcherListView.count - 1 ? 0 : totalItemHeight
209+ if (itemPosition + totalItemHeight + distanceToEnd > launcherListView.contentY + launcherListView.originY + launcherListView.topMargin + height) {
210+ moveAnimation.moveTo(itemPosition + launcherListView.itemHeight - launcherListView.topMargin - height + distanceToEnd - launcherListView.originY);
211+ } else if (itemPosition - distanceToEnd < launcherListView.contentY - launcherListView.originY + launcherListView.topMargin) {
212+ moveAnimation.moveTo(itemPosition - distanceToEnd - launcherListView.topMargin + launcherListView.originY);
213213 }
214214 }
215215
@@ -276,7 +276,7 @@ Rectangle {
276276 onAlertingChanged: {
277277 if(alerting) {
278278 if (!dragging && (launcherListView.peekingIndex === -1 || launcher.visibleWidth > 0)) {
279− moveAnimation.moveToIndex(index)
279+ launcherListView.moveToIndex(index)
280280 if (!dragging && launcher.state !== "visible") {
281281 peekingAnimation.start()
282282 }
@@ -433,10 +433,8 @@ Rectangle {
433433
434434 // First/last item do the scrolling at more than 12 degrees
435435 if (index == 0 || index == launcherListView.count - 1) {
436− if (clickedItem.angle > 12) {
437− launcherListView.flick(0, -launcherListView.clickFlickSpeed);
438− } else if (clickedItem.angle < -12) {
439− launcherListView.flick(0, launcherListView.clickFlickSpeed);
436+ if (clickedItem.angle > 12 || clickedItem.angle < -12) {
437+ launcherListView.moveToIndex(index);
440438 } else {
441439 root.applicationSelected(LauncherModel.get(index).appId);
442440 }
@@ -444,10 +442,8 @@ Rectangle {
444442 }
445443
446444 // the rest launches apps up to an angle of 30 degrees
447− if (clickedItem.angle > 30) {
448− launcherListView.flick(0, -launcherListView.clickFlickSpeed);
449− } else if (clickedItem.angle < -30) {
450− launcherListView.flick(0, launcherListView.clickFlickSpeed);
445+ if (clickedItem.angle > 30 || clickedItem.angle < -30) {
446+ launcherListView.moveToIndex(index);
451447 } else {
452448 root.applicationSelected(LauncherModel.get(index).appId);
453449 }
qml/Shell.qml+7−1
@@ -25,6 +25,7 @@ import Ubuntu.Telephony 0.1 as Telephony
2525import Unity.Connectivity 0.1
2626import Unity.Launcher 0.1
2727import GlobalShortcut 1.0 // has to be before Utils, because of WindowKeysFilter
28+import GSettings 1.0
2829import Utils 0.1
2930import Powerd 0.1
3031import SessionBroadcast 0.1
@@ -558,7 +559,12 @@ Item {
558559 superPressed: physicalKeysMapper.superPressed
559560 superTabPressed: physicalKeysMapper.superTabPressed
560561 panelWidth: shell.usageScenario == "desktop" ? units.gu(10) : units.gu(8)
561− lockedVisible: shell.usageScenario == "desktop"
562+ lockedVisible: shell.usageScenario == "desktop" && !launcherSettings.autohideLauncher
563+
564+ GSettings {
565+ id: launcherSettings
566+ schema.id: "com.canonical.Unity8"
567+ }
562568
563569 onShowDashHome: showHome()
564570 onDash: showDash()
tests/qmltests/Launcher/tst_Launcher.qml+21−13
@@ -29,7 +29,7 @@ import Utils 0.1 // For EdgeBarrierSettings
2929Item {
3030 id: root
3131 width: units.gu(70)
32− height: units.gu(55)
32+ height: units.gu(70)
3333
3434 Loader {
3535 id: launcherLoader
@@ -227,10 +227,6 @@ Item {
227227 // growing while populating it with icons etc.
228228 tryCompare(listView, "flicking", false);
229229
230− // Make sure noone changed the height of the window. The issue this test case
231− // is verifying only happens on certain heights of the Launcher
232− compare(root.height, units.gu(55));
233−
234230 compare(listView.contentY, -listView.topMargin, "Launcher did not start up with first item unfolded");
235231
236232 // Now do check that snapping is in fact enabled
@@ -285,14 +281,21 @@ Item {
285281
286282 function positionLauncherListAtBeginning() {
287283 var listView = testCase.findChild(launcherLoader.item, "launcherListView");
288− listView.contentY = -listView.topMargin;
284+ var moveAnimation = findInvisibleChild(listView, "moveAnimation")
285+
286+ listView.moveToIndex(0);
287+
288+ waitForRendering(listView);
289+ tryCompare(moveAnimation, "running", false);
289290 }
290291 function positionLauncherListAtEnd() {
291292 var listView = testCase.findChild(launcherLoader.item, "launcherListView");
292− if ((listView.contentHeight + listView.topMargin + listView.bottomMargin) > listView.height) {
293− listView.contentY = listView.topMargin + listView.contentHeight
294− - listView.height;
295− }
293+ var moveAnimation = findInvisibleChild(listView, "moveAnimation")
294+
295+ listView.moveToIndex(listView.count -1);
296+
297+ waitForRendering(listView);
298+ tryCompare(moveAnimation, "running", false);
296299 }
297300
298301 function assertFocusOnIndex(index) {
@@ -431,6 +434,8 @@ Item {
431434 dragLauncherIntoView();
432435 var launcherListView = findChild(launcher, "launcherListView");
433436 for (var i = 0; i < launcherListView.count; ++i) {
437+ launcherListView.moveToIndex(i);
438+ waitForRendering(launcherListView);
434439 var delegate = findChild(launcherListView, "launcherDelegate" + i)
435440 compare(findChild(delegate, "countEmblem").visible, LauncherModel.get(i).countVisible)
436441 // Intentionally allow type coercion (string/number)
@@ -491,6 +496,7 @@ Item {
491496 launcher.lastSelectedApplication = "";
492497 dragLauncherIntoView();
493498 var listView = findChild(launcher, "launcherListView");
499+ var moveAnimation = findInvisibleChild(listView, "moveAnimation")
494500
495501 // flicking is unreliable. sometimes it works, sometimes the
496502 // list view moves just a tiny bit or not at all, making tests fail.
@@ -501,12 +507,14 @@ Item {
501507 } else {
502508 positionLauncherListAtEnd();
503509 }
504− tryCompare(listView, "flicking", false);
505−
506510 var oldY = listView.contentY;
507511
508512 mouseClick(listView, listView.width / 2, data.clickY);
509− tryCompare(listView, "flicking", false);
513+
514+ if (data.expectFlick) {
515+ tryCompare(moveAnimation, "running", true);
516+ }
517+ tryCompare(moveAnimation, "running", false);
510518
511519 if (data.expectFlick) {
512520 verify(listView.contentY != oldY);