Merge lp:~unity-team/unity8/newscopes-preview into lp:~unity-team/unity8/new-scopes

Proposed by Michał Sawicz
Status: Merged
Merged at revision: 604
Proposed branch: lp:~unity-team/unity8/newscopes-preview
Merge into: lp:~unity-team/unity8/new-scopes
Prerequisite: lp:~saviq/unity8/new-preview
Diff against target: 231 lines (+27/-77)
5 files modified
qml/Dash/DashPreviewPlaceholder.qml (+1/-1)
qml/Dash/GenericScopeView.qml (+0/-26)
qml/Dash/PreviewListView.qml (+19/-48)
qml/Dash/Previews/Preview.qml (+6/-1)
tests/qmltests/Dash/Previews/tst_Preview.qml (+1/-1)
To merge this branch: bzr merge lp:~unity-team/unity8/newscopes-preview
Reviewer Review Type Date Requested Status
Unity Team Pending
Review via email: mp+205029@code.launchpad.net

Commit message

Integrate new preview.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'qml/Dash/DashPreviewPlaceholder.qml'
2--- qml/Dash/DashPreviewPlaceholder.qml 2013-09-30 12:17:20 +0000
3+++ qml/Dash/DashPreviewPlaceholder.qml 2014-02-07 16:30:34 +0000
4@@ -20,6 +20,6 @@
5 DashPreview {
6 ActivityIndicator {
7 anchors.centerIn: parent
8- running: true
9+ running: visible
10 }
11 }
12
13=== modified file 'qml/Dash/GenericScopeView.qml'
14--- qml/Dash/GenericScopeView.qml 2014-02-04 17:44:56 +0000
15+++ qml/Dash/GenericScopeView.qml 2014-02-07 16:30:34 +0000
16@@ -193,7 +193,6 @@
17 previewListView.categoryId = categoryId
18 previewListView.categoryDelegate = rendererLoader.item
19 previewListView.model = target.model;
20- previewListView.init = true;
21 previewListView.currentIndex = index;
22
23 var item = target.model.get(index);
24@@ -203,8 +202,6 @@
25 scopeView.scope.activate(item.result)
26 } else {
27 previewListView.open = true
28-
29- scopeView.scope.preview(item.result)
30 }
31 }
32 onPressAndHold: {
33@@ -212,13 +209,8 @@
34 previewListView.categoryId = categoryId
35 previewListView.categoryDelegate = rendererLoader.item
36 previewListView.model = target.model;
37- previewListView.init = true;
38 previewListView.currentIndex = index;
39 previewListView.open = true
40-
41- var item = target.model.get(index)
42- scopeView.scope.preview(item.uri, item.icon, item.category, 0, item.mimetype, item.title,
43- item.comment, item.dndUri, item.metadata)
44 }
45 }
46 Connections {
47@@ -335,24 +327,6 @@
48 }
49 }
50
51- Connections {
52- target: scopeView.scope
53- onPreviewReady: {
54- if (previewListView.init) {
55- // Preview was triggered because of a click on the item. Need to expand now.
56- if (!previewListView.open) {
57- previewListView.open = true
58- }
59-
60- var index = previewListView.currentIndex
61- previewListView.currentIndex = -1
62- previewListView.currentIndex = index
63- previewListView.init = false
64- }
65- previewListView.currentItem.previewData = preview
66- }
67- }
68-
69 // TODO: Move as InverseMouseArea to DashPreview
70 MouseArea {
71 objectName: "closePreviewMouseArea"
72
73=== modified file 'qml/Dash/PreviewListView.qml'
74--- qml/Dash/PreviewListView.qml 2014-01-20 16:29:58 +0000
75+++ qml/Dash/PreviewListView.qml 2014-02-07 16:30:34 +0000
76@@ -18,6 +18,7 @@
77 import Ubuntu.Components 0.1
78 import Unity 0.2
79 import "../Components"
80+import "Previews" as Previews
81
82 Item {
83 property OpenEffect openEffect: null
84@@ -28,7 +29,6 @@
85 property alias onScreen: previewListView.onScreen
86 property alias categoryId: previewListView.categoryId
87 property alias categoryDelegate: previewListView.categoryDelegate
88- property alias init: previewListView.init
89 property alias model: previewListView.model
90 property alias currentIndex: previewListView.currentIndex
91 property alias currentItem: previewListView.currentItem
92@@ -83,11 +83,8 @@
93 // when the first preview is ready to be displayed.
94 property bool init: true
95
96- PreviewDelegateMapper {
97- id: previewDelegateMapper
98- }
99-
100 onCurrentIndexChanged: {
101+ if (currentIndex < 0) return;
102 var row = Math.floor(currentIndex / categoryDelegate.columns);
103 if (categoryDelegate.collapsedRowCount <= row) {
104 categoryView.expandedCategoryId = categoryId
105@@ -97,9 +94,9 @@
106 categoryDelegate.highlightIndex = currentIndex
107 }
108
109- if (!init && model !== undefined) {
110+ if (model !== undefined) {
111 var item = model.get(currentIndex)
112- scope.preview(item.uri, item.icon, item.category, 0, item.mimetype, item.title, item.comment, item.dndUri, item.metadata)
113+ previewListView.currentItem.previewModel = scope.preview(item.result)
114 }
115
116 // Adjust contentY in case we need to change to it to show the next row
117@@ -154,58 +151,32 @@
118 z: -1
119 }
120
121- delegate: Loader {
122- id: previewLoader
123- objectName: "previewLoader" + index
124+ delegate: Previews.Preview {
125+ id: preview
126+ objectName: "preview" + index
127 height: previewListView.height
128 width: previewListView.width
129- asynchronous: true
130- source: previewListView.onScreen ?
131- (previewData !== undefined ? previewDelegateMapper.map(previewData.rendererName) : "DashPreviewPlaceholder.qml") : ""
132-
133- onPreviewDataChanged: {
134- if (previewData !== undefined && source.toString().indexOf("DashPreviewPlaceholder.qml") != -1) {
135- previewLoader.opacity = 0;
136- }
137- }
138-
139- onSourceChanged: {
140- if (previewData !== undefined) {
141- fadeIn.start()
142- }
143- }
144+
145+ isCurrent: ListView.isCurrentItem
146+
147+ onPreviewModelChanged: preview.opacity = 0;
148+ onReadyChanged: if (ready) fadeIn.start()
149+// onClose: {
150+// previewListView.open = false
151+// }
152
153 PropertyAnimation {
154 id: fadeIn
155- target: previewLoader
156+ target: preview
157 property: "opacity"
158 from: 0.0
159 to: 1.0
160 duration: UbuntuAnimation.BriskDuration
161 }
162
163- property var previewData
164- property bool valid: item !== null
165-
166- onLoaded: {
167- if (previewListView.onScreen && previewData !== undefined) {
168- item.previewData = Qt.binding(function() { return previewData })
169- item.isCurrent = Qt.binding(function() { return ListView.isCurrentItem })
170- }
171- }
172-
173- Connections {
174- ignoreUnknownSignals: true
175- target: item
176- onClose: {
177- previewListView.open = false
178- }
179- }
180-
181- function closePreviewSpinner() {
182- if (item) {
183- item.showProcessingAction = false;
184- }
185+ ActivityIndicator {
186+ anchors.centerIn: parent
187+ running: visible
188 }
189 }
190 }
191
192=== modified file 'qml/Dash/Previews/Preview.qml'
193--- qml/Dash/Previews/Preview.qml 2014-02-07 09:57:30 +0000
194+++ qml/Dash/Previews/Preview.qml 2014-02-07 16:30:34 +0000
195@@ -36,10 +36,14 @@
196 //! \brief Should be set to true if this preview is currently displayed.
197 property bool isCurrent: false
198
199+ //! \brief Will be changed to true when the initial preview widgets are in.
200+ property bool ready: false
201+
202 clip: true
203
204 Connections {
205- target: shell.applicationManager
206+ target: shell.applicationManager || null
207+ ignoreUnknownSignals: true
208 onMainStageFocusedApplicationChanged: {
209 root.close();
210 }
211@@ -71,6 +75,7 @@
212 bottomMargin: Qt.inputMethod.visible ? Qt.inputMethod.keyboardRectangle.height : 0
213
214 model: previewModel
215+ onCountChanged: if (count > 0) root.ready = true
216
217 Behavior on contentY { UbuntuNumberAnimation { } }
218
219
220=== modified file 'tests/qmltests/Dash/Previews/tst_Preview.qml'
221--- tests/qmltests/Dash/Previews/tst_Preview.qml 2014-02-07 09:57:46 +0000
222+++ tests/qmltests/Dash/Previews/tst_Preview.qml 2014-02-07 16:30:34 +0000
223@@ -18,7 +18,7 @@
224 import QtTest 1.0
225 import "../../../../qml/Dash/Previews"
226 import Unity.Test 0.1 as UT
227-import Unity 0.1 as Unity
228+import Unity 0.2 as Unity
229
230 Rectangle {
231 id: root

Subscribers

People subscribed via source and target branches

to all changes: