on xenial help sign in
Make "See Less" get stuck at the bottom of the view
f4183c1Albert Astals
qml/Dash/GenericScopeView.qml+51−1
@@ -114,7 +114,8 @@ FocusScope {
114 x: previewListView.open ? -width : 0
114 x: previewListView.open ? -width : 0
115 Behavior on x { UbuntuNumberAnimation { } }
115 Behavior on x { UbuntuNumberAnimation { } }
116 width: parent.width
116 width: parent.width
117+ height: floatingSeeLess.visible ? parent.height - floatingSeeLess.height : parent.height
117− height: parent.height
118+ clip: height != parent.height
118
119
119 model: scopeView.categories
120 model: scopeView.categories
120 forceNoClip: previewListView.open
121 forceNoClip: previewListView.open
@@ -321,6 +322,7 @@ FocusScope {
321 onClicked: {
322 onClicked: {
322 if (categoryView.expandedCategoryId != baseItem.category) {
323 if (categoryView.expandedCategoryId != baseItem.category) {
323 categoryView.expandedCategoryId = baseItem.category;
324 categoryView.expandedCategoryId = baseItem.category;
325+ floatingSeeLess.companionTo = seeAll;
324 } else {
326 } else {
325 categoryView.expandedCategoryId = "";
327 categoryView.expandedCategoryId = "";
326 }
328 }
@@ -403,6 +405,54 @@ FocusScope {
403 }
405 }
404 }
406 }
405
407
408+ AbstractButton {
409+ id: floatingSeeLess
410+
411+ property var companionTo: null
412+ property bool companionLowerThanSelf: false
413+
414+ objectName: "floatingSeeLess"
415+ anchors {
416+ bottom: parent.bottom
417+ left: categoryView.left
418+ right: categoryView.right
419+ }
420+ height: seeLessLabel.font.pixelSize + units.gu(4)
421+ visible: companionTo && companionLowerThanSelf
422+
423+ onClicked: categoryView.expandedCategoryId = "";
424+
425+ function updateLowerThan() {
426+ var pos = companionTo.mapToItem(floatingSeeLess, 0, 0);
427+ companionLowerThanSelf = pos.y >= 0;
428+ if (!companionLowerThanSelf && categoryView.expandedCategoryId === "") {
429+ companionTo = null;
430+ }
431+ }
432+
433+ Label {
434+ id: seeLessLabel
435+ text: i18n.tr("See less")
436+ anchors {
437+ centerIn: parent
438+ verticalCenterOffset: units.gu(-0.5)
439+ }
440+ fontSize: "small"
441+ font.weight: Font.Bold
442+ color: scopeStyle ? scopeStyle.foreground : "grey"
443+ }
444+
445+ Connections {
446+ target: floatingSeeLess.companionTo ? categoryView : null
447+ onContentYChanged: floatingSeeLess.updateLowerThan();
448+ }
449+
450+ Connections {
451+ target: floatingSeeLess.companionTo ? floatingSeeLess.companionTo : null
452+ onYChanged: floatingSeeLess.updateLowerThan();
453+ }
454+ }
455+
406 LimitProxyModel {
456 LimitProxyModel {
407 id: previewLimitModel
457 id: previewLimitModel
408 }
458 }