on xenial help sign in
Make Dash Preview Fullscreen
commit7790024bf5098a1e559c3921889d7c0a04f37f4d authorAlbert Astals <albert.astals@canonical.com> dateFri 21 Feb 2014, 15:41 (13 years ago) parente2245de
5 files changed+30−84
qml/Dash/DashContent.qml−1 qml/Dash/DashContentOpenEffect.qml+1−3 qml/Dash/GenericScopeView.qml−8 qml/Dash/PreviewListView.qml+29−71 qml/Dash/ScopeItem.qml−1
qml/Dash/DashContent.qml−1
@@ -228,7 +228,6 @@ Item {
228228 PreviewListView {
229229 id: previewListView
230230 openEffect: openEffect
231− categoryView: dashContentList.currentItem ? dashContentList.currentItem.categoryView : null
232231 scope: dashContentList.currentItem ? dashContentList.currentItem.theScope : null
233232 pageHeader: dashPageHeader
234233 anchors.fill: parent
qml/Dash/DashContentOpenEffect.qml+1−3
@@ -24,7 +24,6 @@ OpenEffect {
2424 objectName: "openEffect"
2525 anchors {
2626 fill: parent
27− bottomMargin: -bottomOverflow
2827 }
2928
3029 enabled: gap > 0.0
@@ -32,10 +31,9 @@ OpenEffect {
3231 topGapPx: (1 - gap) * positionPx
3332 topOpacity: (1 - gap * 1.2)
3433 bottomGapPx: positionPx + gap * (targetBottomGapPx - positionPx)
35− bottomOverflow: units.gu(20)
3634 live: !expansionAnimation.running
3735
38− property int targetBottomGapPx: height - units.gu(8) - bottomOverflow
36+ property int targetBottomGapPx: height
3937 property real gap: previewListView.open ? 1.0 : 0.0
4038
4139 Behavior on gap {
qml/Dash/GenericScopeView.qml−8
@@ -122,7 +122,6 @@ FocusScope {
122122 onMovingChanged: if (moving && atYEnd) endReached()
123123
124124 property string expandedCategoryId: ""
125− signal correctExpandedCategory();
126125
127126 onContentYChanged: pageHeader.positionRealHeader();
128127 onOriginYChanged: pageHeader.positionRealHeader();
@@ -191,8 +190,6 @@ FocusScope {
191190 onClicked: {
192191 // Prepare the preview in case activate() triggers a preview only
193192 openEffect.positionPx = Math.max(mapToItem(categoryView, 0, itemY).y, pageHeader.height + categoryView.stickyHeaderHeight);
194− previewListView.categoryId = categoryId
195− previewListView.categoryDelegate = rendererLoader.item
196193 previewListView.model = target.model;
197194 previewListView.currentIndex = -1
198195 previewListView.currentIndex = index;
@@ -207,8 +204,6 @@ FocusScope {
207204 }
208205 onPressAndHold: {
209206 openEffect.positionPx = Math.max(mapToItem(categoryView, 0, itemY).y, pageHeader.height + categoryView.stickyHeaderHeight);
210− previewListView.categoryId = categoryId
211− previewListView.categoryDelegate = rendererLoader.item
212207 previewListView.model = target.model;
213208 previewListView.currentIndex = -1
214209 previewListView.currentIndex = index;
@@ -220,9 +215,6 @@ FocusScope {
220215 onExpandedCategoryIdChanged: {
221216 collapseAllButExpandedCategory();
222217 }
223− onCorrectExpandedCategory: {
224− collapseAllButExpandedCategory();
225− }
226218 function collapseAllButExpandedCategory() {
227219 var item = rendererLoader.item;
228220 if (item.expandable) {
qml/Dash/PreviewListView.qml+29−71
@@ -24,39 +24,46 @@ Item {
2424 id: root
2525
2626 property OpenEffect openEffect: null
27− property ScopeListView categoryView: null
2827 property Scope scope: null
2928 property var pageHeader: null
3029
3130 property alias open: previewListView.open
3231 property alias onScreen: previewListView.onScreen
33− property alias categoryId: previewListView.categoryId
34− property alias categoryDelegate: previewListView.categoryDelegate
3532 property alias model: previewListView.model
3633 property alias currentIndex: previewListView.currentIndex
3734 property alias currentItem: previewListView.currentItem
3835 property alias count: previewListView.count
3936
40− Image {
41− objectName: "pointerArrow"
42− anchors {
43− top: previewListView.bottom
44− left: parent.left
45− leftMargin: previewListView.categoryDelegate !== undefined && previewListView.categoryDelegate.currentItem ?
46− previewListView.categoryDelegate.currentItem.x + previewListView.categoryDelegate.currentItem.width / 2 + (-width + margins) / 2 : 0
47−
48− Behavior on leftMargin {
49− SmoothedAnimation {
50− duration: UbuntuAnimation.FastDuration
51− }
37+ PageHeader {
38+ id: header
39+ anchors.topMargin: openEffect.topGapPx
40+ width: parent.width
41+ searchEntryEnabled: false
42+ scope: root.scope
43+ height: units.gu(8.5)
44+ showBackButton: true
45+ onBackClicked: {
46+ visibleOnce = false;
47+ root.open = false;
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
5259 }
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
5366 }
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"
6067 }
6168
6269 ListView {
@@ -64,8 +71,7 @@ Item {
6471 objectName: "previewListView"
6572 height: openEffect.bottomGapPx - openEffect.topGapPx
6673 anchors {
67− top: parent.top
68− topMargin: openEffect.topGapPx
74+ top: header.bottom
6975 left: parent.left
7076 right: parent.right
7177 }
@@ -80,65 +86,19 @@ Item {
8086
8187 // To be set before opening the preview
8288 property string categoryId: ""
83− property var categoryDelegate
8489
8590 // because the ListView is built asynchronous, setting the
8691 // currentIndex directly won't work. We need to refresh it
8792 // when the first preview is ready to be displayed.
8893 property bool init: true
8994
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−
13395 property bool open: false
13496 property bool onScreen: false
13597
13698 onOpenChanged: {
13799 if (open) {
138100 onScreen = true;
139− categoryDelegate.highlightIndex = currentIndex;
140101 pageHeader.unfocus();
141− positionListView();
142102 } else {
143103 // Cancel any pending preview requests or actions
144104 if (previewListView.currentItem.previewData !== undefined) {
@@ -146,8 +106,6 @@ Item {
146106 }
147107 scope.cancelActivation();
148108 model = undefined;
149− categoryView.correctExpandedCategory();
150− categoryDelegate.highlightIndex = -1;
151109 }
152110 }
153111
qml/Dash/ScopeItem.qml−1
@@ -92,7 +92,6 @@ Item {
9292 PreviewListView {
9393 id: previewListView
9494 openEffect: openEffect
95− categoryView: scopeView.categoryView
9695 pageHeader: scopeItemPageHeader
9796 scope: root.scope
9897 anchors.fill: parent