on xenial help sign in
Initial preview integration.
8eeaf75Michał Sawicz
qml/Dash/DashPreviewPlaceholder.qml+1−1
@@ -20,6 +20,6 @@ import Ubuntu.Components 0.1
20DashPreview {
20DashPreview {
21 ActivityIndicator {
21 ActivityIndicator {
22 anchors.centerIn: parent
22 anchors.centerIn: parent
23− running: true
23+ running: visible
24 }
24 }
25}
25}
qml/Dash/GenericScopeView.qml−26
@@ -193,7 +193,6 @@ FocusScope {
193 previewListView.categoryId = categoryId
193 previewListView.categoryId = categoryId
194 previewListView.categoryDelegate = rendererLoader.item
194 previewListView.categoryDelegate = rendererLoader.item
195 previewListView.model = target.model;
195 previewListView.model = target.model;
196− previewListView.init = true;
197 previewListView.currentIndex = index;
196 previewListView.currentIndex = index;
198
197
199 var item = target.model.get(index);
198 var item = target.model.get(index);
@@ -203,8 +202,6 @@ FocusScope {
203 scopeView.scope.activate(item.result)
202 scopeView.scope.activate(item.result)
204 } else {
203 } else {
205 previewListView.open = true
204 previewListView.open = true
206−
207− scopeView.scope.preview(item.result)
208 }
205 }
209 }
206 }
210 onPressAndHold: {
207 onPressAndHold: {
@@ -212,13 +209,8 @@ FocusScope {
212 previewListView.categoryId = categoryId
209 previewListView.categoryId = categoryId
213 previewListView.categoryDelegate = rendererLoader.item
210 previewListView.categoryDelegate = rendererLoader.item
214 previewListView.model = target.model;
211 previewListView.model = target.model;
215− previewListView.init = true;
216 previewListView.currentIndex = index;
212 previewListView.currentIndex = index;
217 previewListView.open = true
213 previewListView.open = true
218−
219− var item = target.model.get(index)
220− scopeView.scope.preview(item.uri, item.icon, item.category, 0, item.mimetype, item.title,
221− item.comment, item.dndUri, item.metadata)
222 }
214 }
223 }
215 }
224 Connections {
216 Connections {
@@ -335,24 +327,6 @@ FocusScope {
335 }
327 }
336 }
328 }
337
329
338− Connections {
339− target: scopeView.scope
340− onPreviewReady: {
341− if (previewListView.init) {
342− // Preview was triggered because of a click on the item. Need to expand now.
343− if (!previewListView.open) {
344− previewListView.open = true
345− }
346−
347− var index = previewListView.currentIndex
348− previewListView.currentIndex = -1
349− previewListView.currentIndex = index
350− previewListView.init = false
351− }
352− previewListView.currentItem.previewData = preview
353− }
354− }
355−
356 // TODO: Move as InverseMouseArea to DashPreview
330 // TODO: Move as InverseMouseArea to DashPreview
357 MouseArea {
331 MouseArea {
358 objectName: "closePreviewMouseArea"
332 objectName: "closePreviewMouseArea"
qml/Dash/PreviewListView.qml+17−46
@@ -18,6 +18,7 @@ import QtQuick 2.0
18import Ubuntu.Components 0.1
18import Ubuntu.Components 0.1
19import Unity 0.2
19import Unity 0.2
20import "../Components"
20import "../Components"
21+import "Previews" as Previews
21
22
22Item {
23Item {
23 property OpenEffect openEffect: null
24 property OpenEffect openEffect: null
@@ -28,7 +29,6 @@ Item {
28 property alias onScreen: previewListView.onScreen
29 property alias onScreen: previewListView.onScreen
29 property alias categoryId: previewListView.categoryId
30 property alias categoryId: previewListView.categoryId
30 property alias categoryDelegate: previewListView.categoryDelegate
31 property alias categoryDelegate: previewListView.categoryDelegate
31− property alias init: previewListView.init
32 property alias model: previewListView.model
32 property alias model: previewListView.model
33 property alias currentIndex: previewListView.currentIndex
33 property alias currentIndex: previewListView.currentIndex
34 property alias currentItem: previewListView.currentItem
34 property alias currentItem: previewListView.currentItem
@@ -83,11 +83,8 @@ Item {
83 // when the first preview is ready to be displayed.
83 // when the first preview is ready to be displayed.
84 property bool init: true
84 property bool init: true
85
85
86− PreviewDelegateMapper {
87− id: previewDelegateMapper
88− }
89−
90 onCurrentIndexChanged: {
86 onCurrentIndexChanged: {
87+ if (currentIndex < 0) return;
91 var row = Math.floor(currentIndex / categoryDelegate.columns);
88 var row = Math.floor(currentIndex / categoryDelegate.columns);
92 if (categoryDelegate.collapsedRowCount <= row) {
89 if (categoryDelegate.collapsedRowCount <= row) {
93 categoryView.expandedCategoryId = categoryId
90 categoryView.expandedCategoryId = categoryId
@@ -97,9 +94,9 @@ Item {
97 categoryDelegate.highlightIndex = currentIndex
94 categoryDelegate.highlightIndex = currentIndex
98 }
95 }
99
96
100− if (!init && model !== undefined) {
97+ if (model !== undefined) {
101 var item = model.get(currentIndex)
98 var item = model.get(currentIndex)
102− scope.preview(item.uri, item.icon, item.category, 0, item.mimetype, item.title, item.comment, item.dndUri, item.metadata)
99+ previewListView.currentItem.previewModel = scope.preview(item.result)
103 }
100 }
104
101
105 // Adjust contentY in case we need to change to it to show the next row
102 // Adjust contentY in case we need to change to it to show the next row
@@ -154,58 +151,32 @@ Item {
154 z: -1
151 z: -1
155 }
152 }
156
153
157− delegate: Loader {
154+ delegate: Previews.Preview {
158− id: previewLoader
155+ id: preview
159− objectName: "previewLoader" + index
156+ objectName: "preview" + index
160 height: previewListView.height
157 height: previewListView.height
161 width: previewListView.width
158 width: previewListView.width
162− asynchronous: true
163− source: previewListView.onScreen ?
164− (previewData !== undefined ? previewDelegateMapper.map(previewData.rendererName) : "DashPreviewPlaceholder.qml") : ""
165
159
166− onPreviewDataChanged: {
160+ isCurrent: ListView.isCurrentItem
167− if (previewData !== undefined && source.toString().indexOf("DashPreviewPlaceholder.qml") != -1) {
168− previewLoader.opacity = 0;
169− }
170− }
171
161
172− onSourceChanged: {
162+ onPreviewModelChanged: preview.opacity = 0;
173− if (previewData !== undefined) {
174− fadeIn.start()
163+ onReadyChanged: if (ready) fadeIn.start()
175− }
164+// onClose: {
165+// previewListView.open = false
176− }
166+// }
177
167
178 PropertyAnimation {
168 PropertyAnimation {
179 id: fadeIn
169 id: fadeIn
180− target: previewLoader
170+ target: preview
181 property: "opacity"
171 property: "opacity"
182 from: 0.0
172 from: 0.0
183 to: 1.0
173 to: 1.0
184 duration: UbuntuAnimation.BriskDuration
174 duration: UbuntuAnimation.BriskDuration
185 }
175 }
186
176
187− property var previewData
177+ DashPreviewPlaceholder {
188− property bool valid: item !== null
178+ anchors.fill: parent
189−
179+ visible: !parent.ready
190− onLoaded: {
191− if (previewListView.onScreen && previewData !== undefined) {
192− item.previewData = Qt.binding(function() { return previewData })
193− item.isCurrent = Qt.binding(function() { return ListView.isCurrentItem })
194− }
195− }
196−
197− Connections {
198− ignoreUnknownSignals: true
199− target: item
200− onClose: {
201− previewListView.open = false
202− }
203− }
204−
205− function closePreviewSpinner() {
206− if (item) {
207− item.showProcessingAction = false;
208− }
209 }
180 }
210 }
181 }
211 }
182 }
qml/Dash/Previews/Preview.qml+6−1
@@ -36,10 +36,14 @@ Item {
36 //! \brief Should be set to true if this preview is currently displayed.
36 //! \brief Should be set to true if this preview is currently displayed.
37 property bool isCurrent: false
37 property bool isCurrent: false
38
38
39+ //! \brief Will be changed to true when the initial preview widgets are in.
40+ property bool ready: false
41+
39 clip: true
42 clip: true
40
43
41 Connections {
44 Connections {
42− target: shell.applicationManager
45+ target: shell.applicationManager || null
46+ ignoreUnknownSignals: true
43 onMainStageFocusedApplicationChanged: {
47 onMainStageFocusedApplicationChanged: {
44 root.close();
48 root.close();
45 }
49 }
@@ -71,6 +75,7 @@ Item {
71 bottomMargin: Qt.inputMethod.visible ? Qt.inputMethod.keyboardRectangle.height : 0
75 bottomMargin: Qt.inputMethod.visible ? Qt.inputMethod.keyboardRectangle.height : 0
72
76
73 model: previewModel
77 model: previewModel
78+ onCountChanged: if (count > 0) root.ready = true
74
79
75 Behavior on contentY { UbuntuNumberAnimation { } }
80 Behavior on contentY { UbuntuNumberAnimation { } }
76
81