@@ -23,49 +23,46 @@ import "Previews" as Previews
2323Item {
2424 id: root
2525
26− property OpenEffect openEffect: null
27− property ScopeListView categoryView: null
2826 property Scope scope: null
2927 property var pageHeader: null
3028
3129 property alias open: previewListView.open
32− property alias onScreen: previewListView.onScreen
33− property alias categoryId: previewListView.categoryId
34− property alias categoryDelegate: previewListView.categoryDelegate
3530 property alias model: previewListView.model
3631 property alias currentIndex: previewListView.currentIndex
3732 property alias currentItem: previewListView.currentItem
3833 property alias count: previewListView.count
3934
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− }
35+ PageHeader {
36+ id: header
37+ width: parent.width
38+ searchEntryEnabled: false
39+ scope: root.scope
40+ height: units.gu(8.5)
41+ showBackButton: true
42+ onBackClicked: root.open = false
43+
44+ childItem: Label {
45+ id: label
46+ anchors {
47+ left: parent.left
48+ right: parent.right
49+ verticalCenter: parent.verticalCenter
5250 }
51+ text: scope ? i18n.tr("%1 Preview").arg(scope.name) : ""
52+ color: "#888888"
53+ font.family: "Ubuntu"
54+ font.weight: Font.Light
55+ fontSize: "x-large"
56+ elide: Text.ElideRight
5357 }
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"
6058 }
6159
6260 ListView {
6361 id: previewListView
6462 objectName: "previewListView"
65− height: openEffect.bottomGapPx - openEffect.topGapPx
6663 anchors {
67− top: parent.top
68− topMargin: openEffect.topGapPx
64+ top: header.bottom
65+ bottom: parent.bottom
6966 left: parent.left
7067 right: parent.right
7168 }
@@ -80,65 +77,17 @@ Item {
8077
8178 // To be set before opening the preview
8279 property string categoryId: ""
83− property var categoryDelegate
8480
8581 // because the ListView is built asynchronous, setting the
8682 // currentIndex directly won't work. We need to refresh it
8783 // when the first preview is ready to be displayed.
8884 property bool init: true
8985
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−
13386 property bool open: false
134− property bool onScreen: false
13587
13688 onOpenChanged: {
13789 if (open) {
138− onScreen = true;
139− categoryDelegate.highlightIndex = currentIndex;
14090 pageHeader.unfocus();
141− positionListView();
14291 } else {
14392 // Cancel any pending preview requests or actions
14493 if (previewListView.currentItem.previewData !== undefined) {
@@ -146,8 +95,6 @@ Item {
14695 }
14796 scope.cancelActivation();
14897 model = undefined;
149− categoryView.correctExpandedCategory();
150− categoryDelegate.highlightIndex = -1;
15198 }
15299 }
153100
@@ -155,6 +102,8 @@ Item {
155102 height: previewListView.height
156103 width: previewListView.width
157104
105+ readonly property bool ready: preview.previewModel.loaded
106+
158107 Previews.Preview {
159108 id: preview
160109 objectName: "preview" + index
@@ -181,7 +130,7 @@ Item {
181130
182131 ActivityIndicator {
183132 anchors.centerIn: parent
184− visible: root.onScreen && parent.enabled
133+ visible: root.open && parent.enabled
185134 running: visible
186135 }
187136 }