54
54
target: scopeView.scope
55
onShowDash: previewLoader.open = false;
56
onHideDash: previewLoader.open = false;
55
onShowDash: previewListView.open = false;
56
onHideDash: previewListView.open = false;
61
61
anchors.fill: parent
62
62
model: scopeView.categories
63
forceNoClip: previewLoader.onScreen
63
forceNoClip: previewListView.onScreen
65
65
onAtYEndChanged: if (atYEnd) endReached()
66
66
onMovingChanged: if (moving && atYEnd) endReached()
68
68
property string expandedCategoryId: ""
69
signal correctExpandedCategory();
71
Behavior on contentY {
72
enabled: previewListView.open
73
UbuntuNumberAnimation {}
70
76
delegate: ListItems.Base {
71
78
highlightWhenPressed: false
73
80
readonly property bool expandable: rendererLoader.item ? rendererLoader.item.expandable : false
105
112
target: rendererLoader.item
114
// Prepare the preview in case activate() triggers a preview only
107
115
effect.positionPx = mapToItem(categoryView, 0, itemY).y
108
scopeView.scope.activate(delegateItem.model.uri,
109
delegateItem.model.icon,
110
delegateItem.model.category,
112
delegateItem.model.mimetype,
113
delegateItem.model.title,
114
delegateItem.model.comment,
115
delegateItem.model.dndUri,
116
delegateItem.model.metadata)
116
previewListView.categoryId = categoryId
117
previewListView.categoryDelegate = rendererLoader.item
118
previewListView.model = model;
119
previewListView.init = true;
120
previewListView.currentIndex = index;
122
var item = model.get(index);
124
if ((scopeView.scope.id == "applications.scope" && categoryId == "installed")
125
|| (scopeView.scope.id == "home.scope" && categoryId == "applications.scope")) {
126
scopeView.scope.activate(item.uri, item.icon, item.category, 0, item.mimetype, item.title,
127
item.comment, item.dndUri, item.metadata)
129
previewListView.open = true
131
scopeView.scope.preview( item.uri, item.icon, item.category, 0, item.mimetype, item.title,
132
item.comment, item.dndUri, item.metadata)
118
135
onPressAndHold: {
119
136
effect.positionPx = mapToItem(categoryView, 0, itemY).y
120
scopeView.scope.preview( delegateItem.model.uri,
121
delegateItem.model.icon,
122
delegateItem.model.category,
124
delegateItem.model.mimetype,
125
delegateItem.model.title,
126
delegateItem.model.comment,
127
delegateItem.model.dndUri,
128
delegateItem.model.metadata)
137
previewListView.categoryId = categoryId
138
previewListView.categoryDelegate = rendererLoader.item
139
previewListView.model = model;
140
previewListView.init = true;
141
previewListView.currentIndex = index;
142
previewListView.open = true
144
var item = model.get(index)
145
scopeView.scope.preview( item.uri, item.icon, item.category, 0, item.mimetype, item.title,
146
item.comment, item.dndUri, item.metadata)
132
150
target: categoryView
133
151
onExpandedCategoryIdChanged: {
152
collapseAllButExpandedCategory();
154
onCorrectExpandedCategory: {
155
collapseAllButExpandedCategory();
157
function collapseAllButExpandedCategory() {
134
158
var item = rendererLoader.item;
135
159
if (item.expandable) {
136
160
var shouldFilter = categoryId != categoryView.expandedCategoryId;
138
162
// If the filter animation will be seen start it, otherwise, just flip the switch
139
163
var shrinkingVisible = shouldFilter && y + item.collapsedHeight < categoryView.height;
140
164
var growingVisible = !shouldFilter && y + height < categoryView.height;
141
if (shrinkingVisible || growingVisible) {
142
item.startFilterAnimation(shouldFilter)
144
item.filter = shouldFilter;
147
categoryView.maximizeVisibleArea(index, item.uncollapsedHeight);
165
if (!previewListView.open || !shouldFilter) {
166
if (shrinkingVisible || growingVisible) {
167
item.startFilterAnimation(shouldFilter)
169
item.filter = shouldFilter;
171
if (!shouldFilter && !previewListView.open) {
172
categoryView.maximizeVisibleArea(index, item.uncollapsedHeight);
222
248
topOpacity: (1 - gap * 1.2)
223
249
bottomGapPx: positionPx + gap * (targetBottomGapPx - positionPx)
224
250
bottomOverflow: units.gu(20)
225
bottomOpacity: 1 - (gap * 0.8)
227
253
property int targetBottomGapPx: height - units.gu(8) - bottomOverflow
228
property real gap: previewLoader.open ? 1.0 : 0.0
254
property real gap: previewListView.open ? 1.0 : 0.0
230
256
Behavior on gap {
231
257
NumberAnimation {
233
259
easing.type: Easing.InOutQuad
234
260
onRunningChanged: {
235
if (!previewLoader.open && !running) {
236
previewLoader.onScreen = false
261
if (!previewListView.open && !running) {
262
previewListView.onScreen = false
244
270
target: scopeView.scope
245
271
onPreviewReady: {
246
previewLoader.previewData = preview
247
previewLoader.open = true
272
if (previewListView.init) {
273
// Preview was triggered because of a click on the item. Need to expand now.
274
if (!previewListView.open) {
275
previewListView.open = true
278
var index = previewListView.currentIndex
279
previewListView.currentIndex = -1
280
previewListView.currentIndex = index
281
previewListView.init = false
283
previewListView.currentItem.previewData = preview
271
298
left: parent.left
272
299
right: parent.right
274
source: onScreen ? previewDelegateMapper.map(previewLoader.previewData.rendererName) : ""
301
orientation: ListView.Horizontal
302
highlightRangeMode: ListView.StrictlyEnforceRange
303
snapMode: ListView.SnapOneItem
304
boundsBehavior: Flickable.DragAndOvershootBounds
305
highlightMoveDuration: 250
306
flickDeceleration: units.gu(625)
307
maximumFlickVelocity: width * 5
310
// To be set before opening the preview
311
property string categoryId: ""
312
property var categoryDelegate
314
// because the ListView is built asynchronous, setting the
315
// currentIndex directly won't work. We need to refresh it
316
// when the first preview is ready to be displayed.
317
property bool init: true
320
property int oldRow: -1
321
property bool categoryWasFiltered: false
322
property int initialContenY: 0
324
onCurrentIndexChanged: {
325
var row = Math.floor(currentIndex / categoryDelegate.columns);
326
if (!init && model !== undefined) {
327
var item = model.get(currentIndex)
328
scopeView.scope.preview( item.uri, item.icon, item.category, 0, item.mimetype, item.title, item.comment, item.dndUri, item.metadata)
331
categoryView.contentY -= categoryDelegate.cellHeight
332
} else if (row > oldRow){
333
categoryView.contentY += categoryDelegate.cellHeight
338
if (categoryDelegate.collapsedRowCount <= row) {
339
categoryView.expandedCategoryId = categoryId
343
categoryDelegate.highlightIndex = currentIndex
276
347
property bool open: false
277
348
property bool onScreen: false
278
property bool valid: item !== null
287
item.previewData = Qt.binding(function() { return previewLoader.previewData })
353
categoryDelegate.highlightIndex = currentIndex
356
categoryView.correctExpandedCategory();
357
categoryDelegate.highlightIndex = -1
363
color: Qt.rgba(0, 0, 0, .3)
368
objectName: "previewLoader"
369
height: previewListView.height
370
width: previewListView.width
372
source: previewListView.onScreen ?
373
(previewData !== undefined ? previewDelegateMapper.map(previewData.rendererName) : "DashPreviewPlaceholder.qml") : ""
375
onPreviewDataChanged: {
376
if (previewData !== undefined && source.toString().indexOf("DashPreviewPlaceholder.qml") != -1) {
377
previewLoader.opacity = 0;
382
if (previewData !== undefined) {
389
target: previewLoader
393
duration: UbuntuAnimation.BriskDuration
396
property var previewData
397
property bool valid: item !== null
400
if (previewListView.onScreen && previewData !== undefined) {
401
item.previewData = Qt.binding(function() { return previewData })
406
ignoreUnknownSignals: true
409
previewListView.open = false
417
top: previewListView.bottom
419
leftMargin: previewListView.categoryDelegate.highlightCentered ?
420
(parent.width - width) / 2 :
421
(highlightColumn * cellWidth) + (-width + cellWidth + margins) / 2
422
Behavior on leftMargin {
423
UbuntuNumberAnimation {}
428
property int columns: previewListView.categoryDelegate ? previewListView.categoryDelegate.columns : 1
429
property int highlightColumn: previewListView.currentIndex % columns
430
property int cellWidth: previewListView.categoryDelegate ? previewListView.categoryDelegate.cellWidth : 0
431
property int margins: previewListView.categoryDelegate ? previewListView.categoryDelegate.margins : 0
432
opacity: previewListView.open ? .5 : 0
434
source: "graphics/tooltip_arrow.png"
291
437
// TODO: Move as InverseMouseArea to DashPreview
293
enabled: previewLoader.onScreen
439
enabled: previewListView.onScreen
296
442
topMargin: effect.bottomGapPx
299
previewLoader.open = false;
445
previewListView.open = false;