on xenial help sign in
Merge lp:~unity-team/unity8/seeLessStuckBottom
commit75f4736b656e0acb5b3d6578a105548242e21a94 authorMichał Sawicz <michal.sawicz@canonical.com> dateSat 16 Aug 2014, 17:19 (12 years ago) parentef4681807ea17d
3 files changed+24−29
qml/Dash/GenericScopeView.qml+16−25 qml/Dash/PageHeader.qml+1 tests/qmltests/Dash/tst_GenericScopeView.qml+7−4
qml/Dash/GenericScopeView.qml+16−25
@@ -47,11 +47,6 @@ FocusScope {
4747
4848 signal backClicked()
4949
50− onScopeChanged: {
51− floatingSeeLess.companionTo = null;
52− floatingSeeLess.companionBase = null;
53− }
54−
5550 function positionAtBeginning() {
5651 categoryView.positionAtBeginning()
5752 }
@@ -149,7 +144,8 @@ FocusScope {
149144 x: previewListView.open ? -width : 0
150145 Behavior on x { UbuntuNumberAnimation { } }
151146 width: parent.width
152− height: floatingSeeLess.visible ? parent.height - floatingSeeLess.height + floatingSeeLess.yOffset : parent.height
147+ height: floatingSeeLess.visible ? parent.height - floatingSeeLess.height + floatingSeeLess.yOffset
148+ : parent.height
153149 clip: height != parent.height
154150
155151 model: scopeView.categories
@@ -157,7 +153,7 @@ FocusScope {
157153 pixelAligned: true
158154 interactive: !navigationShown
159155
160− property string expandedCategoryId: ""
156+ property Item expandedCategoryItem: null
161157
162158 readonly property bool pageHeaderTotallyVisible: scopeView.showPageHeader &&
163159 ((headerItemShownHeight == 0 && categoryView.contentY <= categoryView.originY) || (headerItemShownHeight == pageHeaderLoader.item.height))
@@ -168,6 +164,8 @@ FocusScope {
168164 highlightWhenPressed: false
169165 showDivider: false
170166
167+ property Item seeAllButton: seeAll
168+
171169 readonly property bool expandable: {
172170 if (categoryView.model.count === 1) return false;
173171 if (cardTool.template && cardTool.template["collapsed-rows"] === 0) return false;
@@ -197,7 +195,7 @@ FocusScope {
197195 // This can happen with the VJ that doesn't know how height it will be on creation
198196 // so doesn't set expandable until a bit too late for onLoaded
199197 if (expandable) {
200− var shouldExpand = baseItem.category === categoryView.expandedCategoryId;
198+ var shouldExpand = baseItem === categoryView.expandedCategoryItem;
201199 baseItem.expand(shouldExpand, false /*animate*/);
202200 }
203201 }
@@ -248,7 +246,7 @@ FocusScope {
248246 item.objectName = Qt.binding(function() { return categoryId })
249247 item.scopeStyle = scopeView.scopeStyle;
250248 if (baseItem.expandable) {
251− var shouldExpand = categoryId === categoryView.expandedCategoryId;
249+ var shouldExpand = baseItem === categoryView.expandedCategoryItem;
252250 baseItem.expand(shouldExpand, false /*animate*/);
253251 }
254252 updateDelegateCreationRange();
@@ -285,13 +283,13 @@ FocusScope {
285283 }
286284 Connections {
287285 target: categoryView
288− onExpandedCategoryIdChanged: {
286+ onExpandedCategoryItemChanged: {
289287 collapseAllButExpandedCategory();
290288 }
291289 function collapseAllButExpandedCategory() {
292290 var item = rendererLoader.item;
293291 if (baseItem.expandable) {
294− var shouldExpand = categoryId === categoryView.expandedCategoryId;
292+ var shouldExpand = baseItem === categoryView.expandedCategoryItem;
295293 if (shouldExpand != baseItem.expanded) {
296294 // If the filter animation will be seen start it, otherwise, just flip the switch
297295 var shrinkingVisible = !shouldExpand && y + item.collapsedHeight + seeAll.height < categoryView.height;
@@ -355,12 +353,10 @@ FocusScope {
355353 height: seeAllLabel.visible ? seeAllLabel.font.pixelSize + units.gu(4) : 0
356354
357355 onClicked: {
358− if (categoryView.expandedCategoryId != baseItem.category) {
359− categoryView.expandedCategoryId = baseItem.category;
360− floatingSeeLess.companionTo = seeAll;
361− floatingSeeLess.companionBase = baseItem;
356+ if (categoryView.expandedCategoryItem !== baseItem) {
357+ categoryView.expandedCategoryItem = baseItem;
362358 } else {
363− categoryView.expandedCategoryId = "";
359+ categoryView.expandedCategoryItem = null;
364360 }
365361 }
366362
@@ -454,8 +450,8 @@ FocusScope {
454450 id: floatingSeeLess
455451 objectName: "floatingSeeLess"
456452
457− property var companionTo: null
458− property var companionBase: null
453+ property Item companionTo: companionBase ? companionBase.seeAllButton : null
454+ property Item companionBase: categoryView.expandedCategoryItem
459455 property bool showBecausePosition: false
460456 property real yOffset: 0
461457
@@ -467,7 +463,7 @@ FocusScope {
467463 height: seeLessLabel.font.pixelSize + units.gu(4)
468464 visible: companionTo && showBecausePosition
469465
470− onClicked: categoryView.expandedCategoryId = "";
466+ onClicked: categoryView.expandedCategoryItem = null;
471467
472468 function updateVisibility() {
473469 var companionPos = companionTo.mapToItem(floatingSeeLess, 0, 0);
@@ -476,11 +472,6 @@ FocusScope {
476472 var posToBase = floatingSeeLess.mapToItem(companionBase, 0, -yOffset).y;
477473 yOffset = Math.max(0, companionBase.item.collapsedHeight - posToBase);
478474 yOffset = Math.min(yOffset, height);
479−
480− if (!showBecausePosition && categoryView.expandedCategoryId === "") {
481− companionTo = null;
482− companionBase = null;
483− }
484475 }
485476
486477 Label {
@@ -501,7 +492,7 @@ FocusScope {
501492 }
502493
503494 Connections {
504− target: floatingSeeLess.companionTo ? floatingSeeLess.companionTo : null
495+ target: floatingSeeLess.companionTo
505496 onYChanged: floatingSeeLess.updateVisibility();
506497 }
507498 }
qml/Dash/PageHeader.qml+1
@@ -368,6 +368,7 @@ Item {
368368
369369 // FIXME this doesn't work with solid scope backgrounds due to z-ordering
370370 Rectangle {
371+ visible: bottomBorder.visible
371372 anchors {
372373 top: bottomContainer.top
373374 left: parent.left
tests/qmltests/Dash/tst_GenericScopeView.qml+7−4
@@ -20,7 +20,7 @@ import Unity 0.2
2020import ".."
2121import "../../../qml/Dash"
2222import "../../../qml/Components"
23−import Ubuntu.Components 0.1
23+import Ubuntu.Components 1.1
2424import Unity.Test 0.1 as UT
2525
2626Item {
@@ -217,7 +217,10 @@ Item {
217217 var floatingSeeLess = findChild(genericScopeView, "floatingSeeLess");
218218 mouseClick(seeAll, seeAll.width / 2, seeAll.height / 2);
219219 tryCompare(category, "expanded", true);
220− tryCompareFunction(function() { return category.item.height + floatingSeeLess.height == genericScopeView.height - category.item.displayMarginBeginning - category.item.displayMarginEnd; }, true);
220+ tryCompareFunction(function() {
221+ return category.item.height + floatingSeeLess.height ==
222+ genericScopeView.height - category.item.displayMarginBeginning - category.item.displayMarginEnd;
223+ }, true);
221224 mouseClick(floatingSeeLess, floatingSeeLess.width / 2, floatingSeeLess.height / 2);
222225 tryCompare(category, "expanded", false);
223226 }
@@ -334,9 +337,9 @@ Item {
334337
335338 function test_header_style_data() {
336339 return [
337− { tag: "Default", index: 0, foreground: Theme.palette.normal.baseText, background: "color:///#f5f5f5", logo: "" },
340+ { tag: "Default", index: 0, foreground: UbuntuColors.darkGrey, background: "color:///#f5f5f5", logo: "" },
338341 { tag: "Foreground", index: 1, foreground: "yellow", background: "color:///#f5f5f5", logo: "" },
339− { tag: "Logo+Background", index: 2, foreground: Theme.palette.normal.baseText, background: "gradient:///lightgrey/grey",
342+ { tag: "Logo+Background", index: 2, foreground: UbuntuColors.darkGrey, background: "gradient:///lightgrey/grey",
340343 logo: Qt.resolvedUrl("../Dash/tst_PageHeader/logo-ubuntu-orange.svg") },
341344 ];
342345 }