@@ -23,49 +23,46 @@ import "Previews" as Previews
26− property OpenEffect openEffect: null
27− property ScopeListView categoryView: null
28 property Scope scope: null
26 property Scope scope: null
29 property var pageHeader: null
27 property var pageHeader: null
31 property alias open: previewListView.open
29 property alias open: previewListView.open
32− property alias onScreen: previewListView.onScreen
33− property alias categoryId: previewListView.categoryId
34− property alias categoryDelegate: previewListView.categoryDelegate
35 property alias model: previewListView.model
30 property alias model: previewListView.model
36 property alias currentIndex: previewListView.currentIndex
31 property alias currentIndex: previewListView.currentIndex
37 property alias currentItem: previewListView.currentItem
32 property alias currentItem: previewListView.currentItem
38 property alias count: previewListView.count
33 property alias count: previewListView.count
40− Image {
35+ PageHeader {
41− objectName: "pointerArrow"
36+ id: header
42− anchors {
37+ width: parent.width
43− top: previewListView.bottom
38+ searchEntryEnabled: false
44− left: parent.left
39+ scope: root.scope
45− leftMargin: previewListView.categoryDelegate !== undefined && previewListView.categoryDelegate.currentItem ?
40+ height: units.gu(8.5)
46− previewListView.categoryDelegate.currentItem.x + previewListView.categoryDelegate.currentItem.width / 2 + (-width + margins) / 2 : 0
41+ showBackButton: true
47−
42+ onBackClicked: root.open = false
48− Behavior on leftMargin {
43+
49− SmoothedAnimation {
44+ childItem: Label {
50− duration: UbuntuAnimation.FastDuration
45+ id: label
49+ verticalCenter: parent.verticalCenter
51+ text: scope ? i18n.tr("%1 Preview").arg(scope.name) : ""
53+ font.family: "Ubuntu"
54+ font.weight: Font.Light
56+ elide: Text.ElideRight
56− property int margins: previewListView.categoryDelegate ? previewListView.categoryDelegate.margins : 0
57− opacity: previewListView.open ? .5 : 0
59− source: "graphics/tooltip_arrow.png"
62 ListView {
60 ListView {
63 id: previewListView
61 id: previewListView
64 objectName: "previewListView"
62 objectName: "previewListView"
65− height: openEffect.bottomGapPx - openEffect.topGapPx
67− top: parent.top
64+ top: header.bottom
68− topMargin: openEffect.topGapPx
65+ bottom: parent.bottom
69 left: parent.left
66 left: parent.left
70 right: parent.right
67 right: parent.right
@@ -80,65 +77,17 @@ Item {
81 // To be set before opening the preview
78 // To be set before opening the preview
82 property string categoryId: ""
79 property string categoryId: ""
83− property var categoryDelegate
85 // because the ListView is built asynchronous, setting the
81 // because the ListView is built asynchronous, setting the
86 // currentIndex directly won't work. We need to refresh it
82 // currentIndex directly won't work. We need to refresh it
87 // when the first preview is ready to be displayed.
83 // when the first preview is ready to be displayed.
88 property bool init: true
84 property bool init: true
90− onCurrentIndexChanged: positionListView();
92− function positionListView() {
93− if (!open || currentIndex < 0) {
97− var row = Math.floor(currentIndex / categoryDelegate.columns);
98− if (categoryDelegate.collapsedRowCount <= row) {
99− categoryView.expandedCategoryId = categoryId
102− categoryDelegate.highlightIndex = currentIndex
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;
108− // Find new contentY and effect.postionPx
109− var newContentY = itemY - openEffect.positionPx - categoryDelegate.verticalSpacing;
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);
115− // Make sure we don't overscroll the listview. If yes, adjust effect position
116− if (newContentY < 0) {
117− effectAdjust += newContentY;
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;
123− } else if (newContentY > categoryView.contentHeight - categoryView.height) {
124− effectAdjust += -(categoryView.contentHeight - categoryView.height) + newContentY
125− newContentY = categoryView.contentHeight - categoryView.height;
128− openEffect.positionPx = effectAdjust;
129− categoryView.contentY = newContentY;
133 property bool open: false
86 property bool open: false
134− property bool onScreen: false
136 onOpenChanged: {
88 onOpenChanged: {
137 if (open) {
89 if (open) {
139− categoryDelegate.highlightIndex = currentIndex;
140 pageHeader.unfocus();
90 pageHeader.unfocus();
143 // Cancel any pending preview requests or actions
92 // Cancel any pending preview requests or actions
144 if (previewListView.currentItem.previewData !== undefined) {
93 if (previewListView.currentItem.previewData !== undefined) {
@@ -146,8 +95,6 @@ Item {
147 scope.cancelActivation();
96 scope.cancelActivation();
148 model = undefined;
97 model = undefined;
149− categoryView.correctExpandedCategory();
150− categoryDelegate.highlightIndex = -1;
@@ -155,6 +102,8 @@ Item {
155 height: previewListView.height
102 height: previewListView.height
156 width: previewListView.width
103 width: previewListView.width
105+ readonly property bool ready: preview.previewModel.loaded
158 Previews.Preview {
107 Previews.Preview {
159 id: preview
108 id: preview
160 objectName: "preview" + index
109 objectName: "preview" + index
@@ -181,7 +130,7 @@ Item {
182 ActivityIndicator {
131 ActivityIndicator {
183 anchors.centerIn: parent
132 anchors.centerIn: parent
184− visible: root.onScreen && parent.enabled
133+ visible: root.open && parent.enabled
185 running: visible
134 running: visible