@@ -24,39 +24,46 @@ Item {
2424 id: root
2525
2626 property OpenEffect openEffect: null
27− property ScopeListView categoryView: null
2827 property Scope scope: null
2928 property var pageHeader: null
3029
3130 property alias open: previewListView.open
3231 property alias onScreen: previewListView.onScreen
33− property alias categoryId: previewListView.categoryId
34− property alias categoryDelegate: previewListView.categoryDelegate
3532 property alias model: previewListView.model
3633 property alias currentIndex: previewListView.currentIndex
3734 property alias currentItem: previewListView.currentItem
3835 property alias count: previewListView.count
3936
40− Image {
41− objectName: "pointerArrow"
42− anchors {
43− top: previewListView.bottom
44− left: parent.left
45− leftMargin: previewListView.categoryDelegate !== undefined && previewListView.categoryDelegate.currentItem ?
46− previewListView.categoryDelegate.currentItem.x + previewListView.categoryDelegate.currentItem.width / 2 + (-width + margins) / 2 : 0
47−
48− Behavior on leftMargin {
49− SmoothedAnimation {
50− duration: UbuntuAnimation.FastDuration
51− }
37+ PageHeader {
38+ id: header
39+ anchors.topMargin: openEffect.topGapPx
40+ width: parent.width
41+ searchEntryEnabled: false
42+ scope: root.scope
43+ height: units.gu(8.5)
44+ showBackButton: true
45+ onBackClicked: {
46+ visibleOnce = false;
47+ root.open = false;
48+ }
49+ visible: previewListView.open && previewListView.currentItem && previewListView.currentItem.ready || visibleOnce
50+ onVisibleChanged: visibleOnce = visible
51+ property bool visibleOnce: false
52+
53+ childItem: Label {
54+ id: label
55+ anchors {
56+ left: parent.left
57+ right: parent.right
58+ verticalCenter: parent.verticalCenter
5259 }
60+ text: scope ? i18n.tr("%1 Preview").arg(scope.name) : ""
61+ color: "#888888"
62+ font.family: "Ubuntu"
63+ font.weight: Font.Light
64+ fontSize: "x-large"
65+ elide: Text.ElideRight
5366 }
54− height: units.gu(1)
55− width: units.gu(2)
56− property int margins: previewListView.categoryDelegate ? previewListView.categoryDelegate.margins : 0
57− opacity: previewListView.open ? .5 : 0
58−
59− source: "graphics/tooltip_arrow.png"
6067 }
6168
6269 ListView {
@@ -64,8 +71,7 @@ Item {
6471 objectName: "previewListView"
6572 height: openEffect.bottomGapPx - openEffect.topGapPx
6673 anchors {
67− top: parent.top
68− topMargin: openEffect.topGapPx
74+ top: header.bottom
6975 left: parent.left
7076 right: parent.right
7177 }
@@ -80,65 +86,19 @@ Item {
8086
8187 // To be set before opening the preview
8288 property string categoryId: ""
83− property var categoryDelegate
8489
8590 // because the ListView is built asynchronous, setting the
8691 // currentIndex directly won't work. We need to refresh it
8792 // when the first preview is ready to be displayed.
8893 property bool init: true
8994
90− onCurrentIndexChanged: positionListView();
91−
92− function positionListView() {
93− if (!open || currentIndex < 0) {
94− return;
95− }
96−
97− var row = Math.floor(currentIndex / categoryDelegate.columns);
98− if (categoryDelegate.collapsedRowCount <= row) {
99− categoryView.expandedCategoryId = categoryId
100− }
101−
102− categoryDelegate.highlightIndex = currentIndex
103−
104− // Adjust contentY in case we need to change to it to show the next row
105− if (categoryDelegate.rows > 1) {
106− var itemY = categoryView.contentItem.mapFromItem(categoryDelegate.currentItem).y;
107−
108− // Find new contentY and effect.postionPx
109− var newContentY = itemY - openEffect.positionPx - categoryDelegate.verticalSpacing;
110−
111− // Make sure the item is not covered by a header. Move the effect split down if necessary
112− var headerHeight = pageHeader.height + categoryView.stickyHeaderHeight;
113− var effectAdjust = Math.max(openEffect.positionPx, headerHeight);
114−
115− // Make sure we don't overscroll the listview. If yes, adjust effect position
116− if (newContentY < 0) {
117− effectAdjust += newContentY;
118− newContentY = 0;
119− } else if (categoryView.contentHeight < categoryView.height) {
120− // We can't change contentY if the content is smaller than the view, so adjust effect position
121− effectAdjust += newContentY;
122− newContentY = 0;
123− } else if (newContentY > categoryView.contentHeight - categoryView.height) {
124− effectAdjust += -(categoryView.contentHeight - categoryView.height) + newContentY
125− newContentY = categoryView.contentHeight - categoryView.height;
126− }
127−
128− openEffect.positionPx = effectAdjust;
129− categoryView.contentY = newContentY;
130− }
131− }
132−
13395 property bool open: false
13496 property bool onScreen: false
13597
13698 onOpenChanged: {
13799 if (open) {
138100 onScreen = true;
139− categoryDelegate.highlightIndex = currentIndex;
140101 pageHeader.unfocus();
141− positionListView();
142102 } else {
143103 // Cancel any pending preview requests or actions
144104 if (previewListView.currentItem.previewData !== undefined) {
@@ -146,8 +106,6 @@ Item {
146106 }
147107 scope.cancelActivation();
148108 model = undefined;
149− categoryView.correctExpandedCategory();
150− categoryDelegate.highlightIndex = -1;
151109 }
152110 }
153111