@@ -21,8 +21,8 @@ import "../Components/ListItems" as ListItems
2121
2222ScopeView {
2323 id: scopeView
24− readonly property alias previewShown: previewListView.onScreen
2524 property bool enableHeightBehaviorOnNextCreation: false
25+ property var categoryView: categoryView
2626
2727 moving: categoryView.moving
2828
@@ -39,12 +39,14 @@ ScopeView {
3939 target: scopeView.scope
4040 property: "searchQuery"
4141 value: pageHeader.searchQuery
42+ when: isCurrent
4243 }
4344
4445 Binding {
4546 target: pageHeader
4647 property: "searchQuery"
4748 value: scopeView.scope.searchQuery
49+ when: isCurrent
4850 }
4951
5052 Connections {
@@ -74,6 +76,9 @@ ScopeView {
7476 property string expandedCategoryId: ""
7577 signal correctExpandedCategory();
7678
79+ onContentYChanged: pageHeader.positionRealHeader();
80+ onOriginYChanged: pageHeader.positionRealHeader();
81+
7782 Behavior on contentY {
7883 enabled: previewListView.open
7984 UbuntuNumberAnimation {}
@@ -130,7 +135,7 @@ ScopeView {
130135 target: rendererLoader.item
131136 onClicked: {
132137 // Prepare the preview in case activate() triggers a preview only
133− effect.positionPx = mapToItem(categoryView, 0, itemY).y
138+ openEffect.positionPx = mapToItem(categoryView, 0, itemY).y
134139 previewListView.categoryId = categoryId
135140 previewListView.categoryDelegate = rendererLoader.item
136141 previewListView.model = model;
@@ -151,7 +156,7 @@ ScopeView {
151156 }
152157 }
153158 onPressAndHold: {
154− effect.positionPx = mapToItem(categoryView, 0, itemY).y
159+ openEffect.positionPx = mapToItem(categoryView, 0, itemY).y
155160 previewListView.categoryId = categoryId
156161 previewListView.categoryDelegate = rendererLoader.item
157162 previewListView.model = model;
@@ -241,13 +246,14 @@ ScopeView {
241246 categoryView.expandedCategoryId = "";
242247 }
243248 }
244− pageHeader: PageHeader {
245− id: pageHeader
246− objectName: "pageHeader"
247− width: categoryView.width
248− text: scopeView.scope.name
249− searchEntryEnabled: true
250− scope: scopeView.scope
249+ pageHeader: Item {
250+ implicitHeight: scopeView.tabBarHeight
251+ onHeightChanged: scopeView.headerHeightChanged(height)
252+ onYChanged: positionRealHeader();
253+
254+ function positionRealHeader() {
255+ scopeView.headerPositionChanged(y + parent.y)
256+ }
251257 }
252258 }
253259
@@ -292,44 +298,6 @@ ScopeView {
292298 }
293299 }
294300
295− OpenEffect {
296− id: effect
297− objectName: "openEffect"
298− anchors {
299− fill: parent
300− bottomMargin: -bottomOverflow
301− }
302− sourceItem: categoryView
303−
304− enabled: gap > 0.0
305−
306− topGapPx: (1 - gap) * positionPx
307− topOpacity: (1 - gap * 1.2)
308− bottomGapPx: positionPx + gap * (targetBottomGapPx - positionPx)
309− bottomOverflow: units.gu(20)
310− live: !expansionAnimation.running
311−
312− property int targetBottomGapPx: height - units.gu(8) - bottomOverflow
313− property real gap: previewListView.open ? 1.0 : 0.0
314−
315− Behavior on gap {
316− NumberAnimation {
317− id: expansionAnimation
318− duration: 200
319− easing.type: Easing.InOutQuad
320− onRunningChanged: {
321− if (!previewListView.open && !running) {
322− previewListView.onScreen = false
323− }
324− }
325− }
326− }
327− Behavior on positionPx {
328− enabled: previewListView.open
329− UbuntuNumberAnimation {}
330− }
331− }
332−
333301 Connections {
334302 target: scopeView.scope
335303 onPreviewReady: {
@@ -348,179 +316,13 @@ ScopeView {
348316 }
349317 }
350318
351− PreviewDelegateMapper {
352− id: previewDelegateMapper
353− }
354−
355− ListView {
356− id: previewListView
357− objectName: "previewListView"
358− height: effect.bottomGapPx - effect.topGapPx
359− anchors {
360− top: parent.top
361− topMargin: effect.topGapPx
362− left: parent.left
363− right: parent.right
364− }
365− orientation: ListView.Horizontal
366− highlightRangeMode: ListView.StrictlyEnforceRange
367− snapMode: ListView.SnapOneItem
368− boundsBehavior: Flickable.DragAndOvershootBounds
369− highlightMoveDuration: 250
370− flickDeceleration: units.gu(625)
371− maximumFlickVelocity: width * 5
372− cacheBuffer: 0
373−
374− // To be set before opening the preview
375− property string categoryId: ""
376− property var categoryDelegate
377−
378− // because the ListView is built asynchronous, setting the
379− // currentIndex directly won't work. We need to refresh it
380− // when the first preview is ready to be displayed.
381− property bool init: true
382−
383− onCurrentIndexChanged: {
384− var row = Math.floor(currentIndex / categoryDelegate.columns);
385− if (categoryDelegate.collapsedRowCount <= row) {
386− categoryView.expandedCategoryId = categoryId
387− }
388−
389− if (open) {
390− categoryDelegate.highlightIndex = currentIndex
391− }
392−
393− if (!init && model !== undefined) {
394− var item = model.get(currentIndex)
395− scopeView.scope.preview( item.uri, item.icon, item.category, 0, item.mimetype, item.title, item.comment, item.dndUri, item.metadata)
396− }
397−
398− var itemY = categoryView.contentItem.mapFromItem(categoryDelegate.currentItem).y;
399− var newContentY = itemY - effect.positionPx - categoryDelegate.verticalSpacing;
400− var effectAdjust = effect.positionPx;
401− if (newContentY < 0) {
402− effectAdjust += newContentY;
403− newContentY = 0;
404− }
405− if (newContentY > Math.max(0, categoryView.contentHeight - categoryView.height)) {
406− effectAdjust += -(categoryView.contentHeight - categoryView.height) + newContentY
407− newContentY = categoryView.contentHeight - categoryView.height;
408− }
409−
410− effect.positionPx = effectAdjust;
411− categoryView.contentY = newContentY - categoryView.originY;
412− }
413−
414− property bool open: false
415− property bool onScreen: false
416−
417− onOpenChanged: {
418− if (open) {
419− onScreen = true;
420− categoryDelegate.highlightIndex = currentIndex;
421− pageHeader.unfocus();
422− } else {
423− // Cancel any pending preview requests or actions
424− if (previewListView.currentItem.previewData !== undefined) {
425− previewListView.currentItem.previewData.cancelAction();
426− }
427− scopeView.scope.cancelActivation();
428− model = undefined;
429− categoryView.correctExpandedCategory();
430− categoryDelegate.highlightIndex = -1;
431− }
432− }
433−
434− Rectangle {
435− anchors.fill: parent
436− color: Qt.rgba(0, 0, 0, .3)
437− z: -1
438− }
439−
440− delegate: Loader {
441− id: previewLoader
442− objectName: "previewLoader" + index
443− height: previewListView.height
444− width: previewListView.width
445− asynchronous: true
446− source: previewListView.onScreen ?
447− (previewData !== undefined ? previewDelegateMapper.map(previewData.rendererName) : "DashPreviewPlaceholder.qml") : ""
448−
449− onPreviewDataChanged: {
450− if (previewData !== undefined && source.toString().indexOf("DashPreviewPlaceholder.qml") != -1) {
451− previewLoader.opacity = 0;
452− }
453− }
454−
455− onSourceChanged: {
456− if (previewData !== undefined) {
457− fadeIn.start()
458− }
459− }
460−
461− PropertyAnimation {
462− id: fadeIn
463− target: previewLoader
464− property: "opacity"
465− from: 0.0
466− to: 1.0
467− duration: UbuntuAnimation.BriskDuration
468− }
469−
470− property var previewData
471− property bool valid: item !== null
472−
473− onLoaded: {
474− if (previewListView.onScreen && previewData !== undefined) {
475− item.previewData = Qt.binding(function() { return previewData })
476− }
477− }
478−
479− Connections {
480− ignoreUnknownSignals: true
481− target: item
482− onClose: {
483− previewListView.open = false
484− }
485− }
486−
487− function closePreviewSpinner() {
488− if(item) {
489− item.showProcessingAction = false;
490− }
491− }
492− }
493− }
494−
495− Image {
496− objectName: "pointerArrow"
497− anchors {
498− top: previewListView.bottom
499− left: parent.left
500− leftMargin: previewListView.categoryDelegate !== undefined && previewListView.categoryDelegate.currentItem ?
501− previewListView.categoryDelegate.currentItem.center + (-width + margins) / 2 : 0
502−
503− Behavior on leftMargin {
504− SmoothedAnimation {
505− duration: UbuntuAnimation.FastDuration
506− }
507− }
508− }
509− height: units.gu(1)
510− width: units.gu(2)
511− property int margins: previewListView.categoryDelegate ? previewListView.categoryDelegate.margins : 0
512− opacity: previewListView.open ? .5 : 0
513−
514− source: "graphics/tooltip_arrow.png"
515− }
516−
517319 // TODO: Move as InverseMouseArea to DashPreview
518320 MouseArea {
519321 objectName: "closePreviewMouseArea"
520322 enabled: previewListView.onScreen
521323 anchors {
522324 fill: parent
523− topMargin: effect.bottomGapPx
325+ topMargin: openEffect.bottomGapPx
524326 }
525327 onClicked: {
526328 previewListView.open = false;