on xenial help sign in
Merge lp:~aacid/unity8/new-scopes-dash-preview-fullscreen.
commit695490546d23ea63df6ddb737c37d46988b227be authorAlbert Astals <albert.astals@canonical.com> dateFri 21 Feb 2014, 18:00 (13 years ago) parentb4ba3ad9f81478
6 files changed+54−197
qml/Dash/Dash.qml+3−3 qml/Dash/DashContent.qml+12−17 qml/Dash/DashContentOpenEffect.qml−57 qml/Dash/GenericScopeView.qml+2−26 qml/Dash/PreviewListView.qml+26−77 qml/Dash/ScopeItem.qml+11−17
qml/Dash/Dash.qml+3−3
@@ -27,7 +27,7 @@ Showable {
2727 visible: shown
2828
2929 property ListModel searchHistory: SearchHistoryModel {}
30− property bool searchable: !dashContent.previewOnScreen && !scopeItem.previewOnScreen
30+ property bool searchable: !dashContent.previewOpen && !scopeItem.previewOpen
3131
3232 property alias contentProgress: dashContent.contentProgress
3333 property string showScopeOnLoaded: "clickscope"
@@ -88,8 +88,8 @@ Showable {
8888 clip: scale != 1.0 || scopeItem.visible
8989 Behavior on x {
9090 UbuntuNumberAnimation {
91− onStopped: {
92− if (dashContent.x == 0) {
91+ onRunningChanged: {
92+ if (!running && dashContent.x == 0) {
9393 dashContent.closeScope(scopeItem.scope);
9494 scopeItem.scope = null;
9595 }
qml/Dash/DashContent.qml+12−17
@@ -26,7 +26,7 @@ Item {
2626 property var scopes: null
2727 property real contentProgress: Math.max(0, Math.min(dashContentList.contentX / (dashContentList.contentWidth - dashContentList.width), units.dp(1)))
2828 property alias currentIndex: dashContentList.currentIndex
29− property alias previewOnScreen: previewListView.onScreen
29+ property alias previewOpen: previewListView.open
3030
3131 property ScopeDelegateMapper scopeMapper : ScopeDelegateMapper {}
3232 property ListModel searchHistory
@@ -93,13 +93,17 @@ Item {
9393
9494 Item {
9595 id: dashContentListHolder
96− anchors.fill: parent
96+
97+ x: previewListView.open ? -width : 0
98+ Behavior on x { UbuntuNumberAnimation { } }
99+ width: parent.width
100+ height: parent.height
97101
98102 ListView {
99103 id: dashContentList
100104 objectName: "dashContentList"
101105
102− interactive: dashContent.scopes.loaded && !previewListView.onScreen && !currentItem.moving
106+ interactive: dashContent.scopes.loaded && !previewListView.open && !currentItem.moving
103107
104108 anchors.fill: parent
105109 model: dashContent.model
@@ -114,6 +118,7 @@ Item {
114118 cacheBuffer: 1073741823
115119 onMovementStarted: dashContent.movementStarted()
116120 onMovementEnded: dashContent.movementEnded()
121+ clip: parent.x != 0
117122
118123 // If the number of items is less than the current index, then need to reset to another item.
119124 onCountChanged: {
@@ -149,7 +154,6 @@ Item {
149154 item.isCurrent = Qt.binding(function() { return visible && ListView.isCurrentItem })
150155 item.tabBarHeight = dashPageHeader.implicitHeight;
151156 item.pageHeader = dashPageHeader;
152− item.openEffect = openEffect;
153157 item.previewListView = previewListView;
154158 dashContentList.movementStarted.connect(item.movementStarted)
155159 dashContent.positionedAtBeginning.connect(item.positionedAtBeginning)
@@ -219,22 +223,13 @@ Item {
219223 }
220224 }
221225
222− DashContentOpenEffect {
223− id: openEffect
224− anchors {
225− fill: parent
226− bottomMargin: -bottomOverflow
227− }
228− sourceItem: dashContentListHolder
229− previewListView: previewListView
230− }
231−
232226 PreviewListView {
233227 id: previewListView
234− openEffect: openEffect
235− categoryView: dashContentList.currentItem ? dashContentList.currentItem.categoryView : null
228+ visible: x != width
236229 scope: dashContentList.currentItem ? dashContentList.currentItem.theScope : null
237230 pageHeader: dashPageHeader
238− anchors.fill: parent
231+ width: parent.width
232+ height: parent.height
233+ anchors.left: dashContentListHolder.right
239234 }
240235}
qml/Dash/DashContentOpenEffect.qmldeleted−57
@@ -1,57 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU General Public License as published by
6− * the Free Software Foundation; version 3.
7− *
8− * This program is distributed in the hope that it will be useful,
9− * but WITHOUT ANY WARRANTY; without even the implied warranty of
10− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11− * GNU General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.0
18−import Ubuntu.Components 0.1
19−import "../Components"
20−
21−OpenEffect {
22− property PreviewListView previewListView: null
23−
24− objectName: "openEffect"
25− anchors {
26− fill: parent
27− bottomMargin: -bottomOverflow
28− }
29−
30− enabled: gap > 0.0
31−
32− topGapPx: (1 - gap) * positionPx
33− topOpacity: (1 - gap * 1.2)
34− bottomGapPx: positionPx + gap * (targetBottomGapPx - positionPx)
35− bottomOverflow: units.gu(20)
36− live: !expansionAnimation.running
37−
38− property int targetBottomGapPx: height - units.gu(8) - bottomOverflow
39− property real gap: previewListView.open ? 1.0 : 0.0
40−
41− Behavior on gap {
42− NumberAnimation {
43− id: expansionAnimation
44− duration: 200
45− easing.type: Easing.InOutQuad
46− onRunningChanged: {
47− if (!previewListView.open && !running) {
48− previewListView.onScreen = false
49− }
50− }
51− }
52− }
53− Behavior on positionPx {
54− enabled: previewListView.open
55− UbuntuNumberAnimation {}
56− }
57−}
qml/Dash/GenericScopeView.qml+2−26
@@ -30,7 +30,6 @@ FocusScope {
3030 property alias moving: categoryView.moving
3131 property int tabBarHeight: 0
3232 property PageHeader pageHeader: null
33− property OpenEffect openEffect: null
3433 property Item previewListView: null
3534
3635 signal endReached
@@ -56,7 +55,7 @@ FocusScope {
5655 Binding {
5756 target: scope
5857 property: "isActive"
59− value: isCurrent && !previewListView.onScreen
58+ value: isCurrent && !previewListView.open
6059 }
6160
6261 Timer {
@@ -116,13 +115,12 @@ FocusScope {
116115 objectName: "categoryListView"
117116 anchors.fill: parent
118117 model: scopeView.categories
119− forceNoClip: previewListView.onScreen
118+ forceNoClip: previewListView.open
120119
121120 onAtYEndChanged: if (atYEnd) endReached()
122121 onMovingChanged: if (moving && atYEnd) endReached()
123122
124123 property string expandedCategoryId: ""
125− signal correctExpandedCategory();
126124
127125 onContentYChanged: pageHeader.positionRealHeader();
128126 onOriginYChanged: pageHeader.positionRealHeader();
@@ -191,9 +189,6 @@ FocusScope {
191189 target: rendererLoader.item
192190 onClicked: {
193191 // Prepare the preview in case activate() triggers a preview only
194− openEffect.positionPx = Math.max(mapToItem(categoryView, 0, itemY).y, pageHeader.height + categoryView.stickyHeaderHeight);
195− previewListView.categoryId = categoryId
196− previewListView.categoryDelegate = rendererLoader.item
197192 previewListView.model = target.model;
198193 previewListView.currentIndex = -1
199194 previewListView.currentIndex = index;
@@ -207,9 +202,6 @@ FocusScope {
207202 }
208203 }
209204 onPressAndHold: {
210− openEffect.positionPx = Math.max(mapToItem(categoryView, 0, itemY).y, pageHeader.height + categoryView.stickyHeaderHeight);
211− previewListView.categoryId = categoryId
212− previewListView.categoryDelegate = rendererLoader.item
213205 previewListView.model = target.model;
214206 previewListView.currentIndex = -1
215207 previewListView.currentIndex = index;
@@ -221,9 +213,6 @@ FocusScope {
221213 onExpandedCategoryIdChanged: {
222214 collapseAllButExpandedCategory();
223215 }
224− onCorrectExpandedCategory: {
225− collapseAllButExpandedCategory();
226− }
227216 function collapseAllButExpandedCategory() {
228217 var item = rendererLoader.item;
229218 if (item.expandable) {
@@ -333,17 +322,4 @@ FocusScope {
333322 default: return "CardFilterGrid.qml";
334323 }
335324 }
336−
337− // TODO: Move as InverseMouseArea to DashPreview
338− MouseArea {
339− objectName: "closePreviewMouseArea"
340− enabled: previewListView.onScreen
341− anchors {
342− fill: parent
343− topMargin: openEffect.bottomGapPx
344− }
345− onClicked: {
346− previewListView.open = false;
347− }
348− }
349325}
qml/Dash/PreviewListView.qml+26−77
@@ -23,49 +23,46 @@ import "Previews" as Previews
2323Item {
2424 id: root
2525
26− property OpenEffect openEffect: null
27− property ScopeListView categoryView: null
2826 property Scope scope: null
2927 property var pageHeader: null
3028
3129 property alias open: previewListView.open
32− property alias onScreen: previewListView.onScreen
33− property alias categoryId: previewListView.categoryId
34− property alias categoryDelegate: previewListView.categoryDelegate
3530 property alias model: previewListView.model
3631 property alias currentIndex: previewListView.currentIndex
3732 property alias currentItem: previewListView.currentItem
3833 property alias count: previewListView.count
3934
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− }
35+ PageHeader {
36+ id: header
37+ width: parent.width
38+ searchEntryEnabled: false
39+ scope: root.scope
40+ height: units.gu(8.5)
41+ showBackButton: true
42+ onBackClicked: root.open = false
43+
44+ childItem: Label {
45+ id: label
46+ anchors {
47+ left: parent.left
48+ right: parent.right
49+ verticalCenter: parent.verticalCenter
5250 }
51+ text: scope ? i18n.tr("%1 Preview").arg(scope.name) : ""
52+ color: "#888888"
53+ font.family: "Ubuntu"
54+ font.weight: Font.Light
55+ fontSize: "x-large"
56+ elide: Text.ElideRight
5357 }
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"
6058 }
6159
6260 ListView {
6361 id: previewListView
6462 objectName: "previewListView"
65− height: openEffect.bottomGapPx - openEffect.topGapPx
6663 anchors {
67− top: parent.top
68− topMargin: openEffect.topGapPx
64+ top: header.bottom
65+ bottom: parent.bottom
6966 left: parent.left
7067 right: parent.right
7168 }
@@ -80,65 +77,17 @@ Item {
8077
8178 // To be set before opening the preview
8279 property string categoryId: ""
83− property var categoryDelegate
8480
8581 // because the ListView is built asynchronous, setting the
8682 // currentIndex directly won't work. We need to refresh it
8783 // when the first preview is ready to be displayed.
8884 property bool init: true
8985
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−
13386 property bool open: false
134− property bool onScreen: false
13587
13688 onOpenChanged: {
13789 if (open) {
138− onScreen = true;
139− categoryDelegate.highlightIndex = currentIndex;
14090 pageHeader.unfocus();
141− positionListView();
14291 } else {
14392 // Cancel any pending preview requests or actions
14493 if (previewListView.currentItem.previewData !== undefined) {
@@ -146,8 +95,6 @@ Item {
14695 }
14796 scope.cancelActivation();
14897 model = undefined;
149− categoryView.correctExpandedCategory();
150− categoryDelegate.highlightIndex = -1;
15198 }
15299 }
153100
@@ -155,6 +102,8 @@ Item {
155102 height: previewListView.height
156103 width: previewListView.width
157104
105+ readonly property bool ready: preview.previewModel.loaded
106+
158107 Previews.Preview {
159108 id: preview
160109 objectName: "preview" + index
@@ -181,7 +130,7 @@ Item {
181130
182131 ActivityIndicator {
183132 anchors.centerIn: parent
184− visible: root.onScreen && parent.enabled
133+ visible: root.open && parent.enabled
185134 running: visible
186135 }
187136 }
qml/Dash/ScopeItem.qml+11−17
@@ -23,7 +23,7 @@ Item {
2323 id: root
2424
2525 property alias scope: scopeView.scope
26− property alias previewOnScreen: previewListView.onScreen
26+ property alias previewOpen: previewListView.open
2727
2828 property ListModel searchHistory
2929
@@ -33,7 +33,11 @@ Item {
3333
3434 Item {
3535 id: scopeViewHolder
36− anchors.fill: parent
36+
37+ x: previewListView.open ? -width : 0
38+ Behavior on x { UbuntuNumberAnimation { } }
39+ width: parent.width
40+ height: parent.height
3741
3842 GenericScopeView {
3943 id: scopeView
@@ -42,7 +46,6 @@ Item {
4246 isCurrent: scope != null
4347 tabBarHeight: scopeItemPageHeader.implicitHeight
4448 pageHeader: scopeItemPageHeader
45− openEffect: openEffect
4649 previewListView: previewListView
4750
4851 Connections {
@@ -58,7 +61,7 @@ Item {
5861 searchEntryEnabled: true
5962 searchHistory: root.searchHistory
6063 scope: root.scope
61− height: units.gu(7)
64+ height: units.gu(8.5)
6265 showBackButton: true
6366 onBackClicked: root.back();
6467
@@ -79,22 +82,13 @@ Item {
7982 }
8083 }
8184
82− DashContentOpenEffect {
83− id: openEffect
84− anchors {
85− fill: parent
86− bottomMargin: -bottomOverflow
87− }
88− sourceItem: scopeViewHolder
89− previewListView: previewListView
90− }
91−
9285 PreviewListView {
9386 id: previewListView
94− openEffect: openEffect
95− categoryView: scopeView.categoryView
87+ visible: x != width
9688 pageHeader: scopeItemPageHeader
9789 scope: root.scope
98− anchors.fill: parent
90+ width: parent.width
91+ height: parent.height
92+ anchors.left: scopeViewHolder.right
9993 }
10094}