on xenial help sign in
Make Dash Preview Fullscreen
7790024Albert Astals
qml/Dash/DashContent.qml−1
@@ -228,7 +228,6 @@ Item {
228 PreviewListView {
228 PreviewListView {
229 id: previewListView
229 id: previewListView
230 openEffect: openEffect
230 openEffect: openEffect
231− categoryView: dashContentList.currentItem ? dashContentList.currentItem.categoryView : null
232 scope: dashContentList.currentItem ? dashContentList.currentItem.theScope : null
231 scope: dashContentList.currentItem ? dashContentList.currentItem.theScope : null
233 pageHeader: dashPageHeader
232 pageHeader: dashPageHeader
234 anchors.fill: parent
233 anchors.fill: parent
qml/Dash/DashContentOpenEffect.qml+1−3
@@ -24,7 +24,6 @@ OpenEffect {
24 objectName: "openEffect"
24 objectName: "openEffect"
25 anchors {
25 anchors {
26 fill: parent
26 fill: parent
27− bottomMargin: -bottomOverflow
28 }
27 }
29
28
30 enabled: gap > 0.0
29 enabled: gap > 0.0
@@ -32,10 +31,9 @@ OpenEffect {
32 topGapPx: (1 - gap) * positionPx
31 topGapPx: (1 - gap) * positionPx
33 topOpacity: (1 - gap * 1.2)
32 topOpacity: (1 - gap * 1.2)
34 bottomGapPx: positionPx + gap * (targetBottomGapPx - positionPx)
33 bottomGapPx: positionPx + gap * (targetBottomGapPx - positionPx)
35− bottomOverflow: units.gu(20)
36 live: !expansionAnimation.running
34 live: !expansionAnimation.running
37
35
38− property int targetBottomGapPx: height - units.gu(8) - bottomOverflow
36+ property int targetBottomGapPx: height
39 property real gap: previewListView.open ? 1.0 : 0.0
37 property real gap: previewListView.open ? 1.0 : 0.0
40
38
41 Behavior on gap {
39 Behavior on gap {
qml/Dash/GenericScopeView.qml−8
@@ -122,7 +122,6 @@ FocusScope {
122 onMovingChanged: if (moving && atYEnd) endReached()
122 onMovingChanged: if (moving && atYEnd) endReached()
123
123
124 property string expandedCategoryId: ""
124 property string expandedCategoryId: ""
125− signal correctExpandedCategory();
126
125
127 onContentYChanged: pageHeader.positionRealHeader();
126 onContentYChanged: pageHeader.positionRealHeader();
128 onOriginYChanged: pageHeader.positionRealHeader();
127 onOriginYChanged: pageHeader.positionRealHeader();
@@ -191,8 +190,6 @@ FocusScope {
191 onClicked: {
190 onClicked: {
192 // Prepare the preview in case activate() triggers a preview only
191 // Prepare the preview in case activate() triggers a preview only
193 openEffect.positionPx = Math.max(mapToItem(categoryView, 0, itemY).y, pageHeader.height + categoryView.stickyHeaderHeight);
192 openEffect.positionPx = Math.max(mapToItem(categoryView, 0, itemY).y, pageHeader.height + categoryView.stickyHeaderHeight);
194− previewListView.categoryId = categoryId
195− previewListView.categoryDelegate = rendererLoader.item
196 previewListView.model = target.model;
193 previewListView.model = target.model;
197 previewListView.currentIndex = -1
194 previewListView.currentIndex = -1
198 previewListView.currentIndex = index;
195 previewListView.currentIndex = index;
@@ -207,8 +204,6 @@ FocusScope {
207 }
204 }
208 onPressAndHold: {
205 onPressAndHold: {
209 openEffect.positionPx = Math.max(mapToItem(categoryView, 0, itemY).y, pageHeader.height + categoryView.stickyHeaderHeight);
206 openEffect.positionPx = Math.max(mapToItem(categoryView, 0, itemY).y, pageHeader.height + categoryView.stickyHeaderHeight);
210− previewListView.categoryId = categoryId
211− previewListView.categoryDelegate = rendererLoader.item
212 previewListView.model = target.model;
207 previewListView.model = target.model;
213 previewListView.currentIndex = -1
208 previewListView.currentIndex = -1
214 previewListView.currentIndex = index;
209 previewListView.currentIndex = index;
@@ -220,9 +215,6 @@ FocusScope {
220 onExpandedCategoryIdChanged: {
215 onExpandedCategoryIdChanged: {
221 collapseAllButExpandedCategory();
216 collapseAllButExpandedCategory();
222 }
217 }
223− onCorrectExpandedCategory: {
224− collapseAllButExpandedCategory();
225− }
226 function collapseAllButExpandedCategory() {
218 function collapseAllButExpandedCategory() {
227 var item = rendererLoader.item;
219 var item = rendererLoader.item;
228 if (item.expandable) {
220 if (item.expandable) {
qml/Dash/PreviewListView.qml+29−71
@@ -24,39 +24,46 @@ Item {
24 id: root
24 id: root
25
25
26 property OpenEffect openEffect: null
26 property OpenEffect openEffect: null
27− property ScopeListView categoryView: null
28 property Scope scope: null
27 property Scope scope: null
29 property var pageHeader: null
28 property var pageHeader: null
30
29
31 property alias open: previewListView.open
30 property alias open: previewListView.open
32 property alias onScreen: previewListView.onScreen
31 property alias onScreen: previewListView.onScreen
33− property alias categoryId: previewListView.categoryId
34− property alias categoryDelegate: previewListView.categoryDelegate
35 property alias model: previewListView.model
32 property alias model: previewListView.model
36 property alias currentIndex: previewListView.currentIndex
33 property alias currentIndex: previewListView.currentIndex
37 property alias currentItem: previewListView.currentItem
34 property alias currentItem: previewListView.currentItem
38 property alias count: previewListView.count
35 property alias count: previewListView.count
39
36
40− Image {
37+ PageHeader {
41− objectName: "pointerArrow"
38+ id: header
42− anchors {
39+ anchors.topMargin: openEffect.topGapPx
43− top: previewListView.bottom
44− left: parent.left
40+ width: parent.width
45− leftMargin: previewListView.categoryDelegate !== undefined && previewListView.categoryDelegate.currentItem ?
41+ searchEntryEnabled: false
46− previewListView.categoryDelegate.currentItem.x + previewListView.categoryDelegate.currentItem.width / 2 + (-width + margins) / 2 : 0
42+ scope: root.scope
47−
43+ height: units.gu(8.5)
48− Behavior on leftMargin {
44+ showBackButton: true
49− SmoothedAnimation {
45+ onBackClicked: {
50− duration: UbuntuAnimation.FastDuration
46+ visibleOnce = false;
47+ root.open = false;
51− }
48+ }
49+ visible: previewListView.open && previewListView.currentItem && previewListView.currentItem.ready || visibleOnce
50+ onVisibleChanged: visibleOnce = visible
51+ property bool visibleOnce: false
52+
53+ childItem: Label {
54+ id: label
55+ anchors {
56+ left: parent.left
57+ right: parent.right
58+ verticalCenter: parent.verticalCenter
52 }
59 }
60+ text: scope ? i18n.tr("%1 Preview").arg(scope.name) : ""
61+ color: "#888888"
62+ font.family: "Ubuntu"
63+ font.weight: Font.Light
64+ fontSize: "x-large"
65+ elide: Text.ElideRight
53 }
66 }
54− height: units.gu(1)
55− width: units.gu(2)
56− property int margins: previewListView.categoryDelegate ? previewListView.categoryDelegate.margins : 0
57− opacity: previewListView.open ? .5 : 0
58−
59− source: "graphics/tooltip_arrow.png"
60 }
67 }
61
68
62 ListView {
69 ListView {
@@ -64,8 +71,7 @@ Item {
64 objectName: "previewListView"
71 objectName: "previewListView"
65 height: openEffect.bottomGapPx - openEffect.topGapPx
72 height: openEffect.bottomGapPx - openEffect.topGapPx
66 anchors {
73 anchors {
67− top: parent.top
74+ top: header.bottom
68− topMargin: openEffect.topGapPx
69 left: parent.left
75 left: parent.left
70 right: parent.right
76 right: parent.right
71 }
77 }
@@ -80,65 +86,19 @@ Item {
80
86
81 // To be set before opening the preview
87 // To be set before opening the preview
82 property string categoryId: ""
88 property string categoryId: ""
83− property var categoryDelegate
84
89
85 // because the ListView is built asynchronous, setting the
90 // because the ListView is built asynchronous, setting the
86 // currentIndex directly won't work. We need to refresh it
91 // currentIndex directly won't work. We need to refresh it
87 // when the first preview is ready to be displayed.
92 // when the first preview is ready to be displayed.
88 property bool init: true
93 property bool init: true
89
94
90− onCurrentIndexChanged: positionListView();
91−
92− function positionListView() {
93− if (!open || currentIndex < 0) {
94− return;
95− }
96−
97− var row = Math.floor(currentIndex / categoryDelegate.columns);
98− if (categoryDelegate.collapsedRowCount <= row) {
99− categoryView.expandedCategoryId = categoryId
100− }
101−
102− categoryDelegate.highlightIndex = currentIndex
103−
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;
107−
108− // Find new contentY and effect.postionPx
109− var newContentY = itemY - openEffect.positionPx - categoryDelegate.verticalSpacing;
110−
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);
114−
115− // Make sure we don't overscroll the listview. If yes, adjust effect position
116− if (newContentY < 0) {
117− effectAdjust += newContentY;
118− newContentY = 0;
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;
122− newContentY = 0;
123− } else if (newContentY > categoryView.contentHeight - categoryView.height) {
124− effectAdjust += -(categoryView.contentHeight - categoryView.height) + newContentY
125− newContentY = categoryView.contentHeight - categoryView.height;
126− }
127−
128− openEffect.positionPx = effectAdjust;
129− categoryView.contentY = newContentY;
130− }
131− }
132−
133 property bool open: false
95 property bool open: false
134 property bool onScreen: false
96 property bool onScreen: false
135
97
136 onOpenChanged: {
98 onOpenChanged: {
137 if (open) {
99 if (open) {
138 onScreen = true;
100 onScreen = true;
139− categoryDelegate.highlightIndex = currentIndex;
140 pageHeader.unfocus();
101 pageHeader.unfocus();
141− positionListView();
142 } else {
102 } else {
143 // Cancel any pending preview requests or actions
103 // Cancel any pending preview requests or actions
144 if (previewListView.currentItem.previewData !== undefined) {
104 if (previewListView.currentItem.previewData !== undefined) {
@@ -146,8 +106,6 @@ Item {
146 }
106 }
147 scope.cancelActivation();
107 scope.cancelActivation();
148 model = undefined;
108 model = undefined;
149− categoryView.correctExpandedCategory();
150− categoryDelegate.highlightIndex = -1;
151 }
109 }
152 }
110 }
153
111
qml/Dash/ScopeItem.qml−1
@@ -92,7 +92,6 @@ Item {
92 PreviewListView {
92 PreviewListView {
93 id: previewListView
93 id: previewListView
94 openEffect: openEffect
94 openEffect: openEffect
95− categoryView: scopeView.categoryView
96 pageHeader: scopeItemPageHeader
95 pageHeader: scopeItemPageHeader
97 scope: root.scope
96 scope: root.scope
98 anchors.fill: parent
97 anchors.fill: parent