on xenial help sign in
Grow the temporary scope from its pos in the grid
commitdd0f9ca95430cf2337b4eae0ec9cc9c6d1f375be authorAlbert Astals <albert.astals@canonical.com> dateMon 14 Jul 2014, 15:44 (12 years ago) parented657ae
7 files changed+45−13
qml/Dash/CardCarousel.qml+1−1 qml/Dash/CardFilterGrid.qml+1−1 qml/Dash/CardVerticalJournal.qml+1−1 qml/Dash/Dash.qml+22−3 qml/Dash/DashRenderer.qml+2−1 qml/Dash/ScopesOverview.qml+16−4 qml/Dash/ScopesOverviewAll.qml+2−2
qml/Dash/CardCarousel.qml+1−1
@@ -53,7 +53,7 @@ DashRenderer {
5353
5454 objectName: "carouselDelegate" + index
5555
56− function clicked() { cardCarousel.clicked(index, model.result) }
56+ function clicked() { cardCarousel.clicked(index, model.result, loader.item) }
5757 function pressAndHold() { cardCarousel.pressAndHold(index, model.result) }
5858
5959 sourceComponent: cardTool.cardComponent
qml/Dash/CardFilterGrid.qml+1−1
@@ -63,7 +63,7 @@ DashRenderer {
6363 }
6464 Connections {
6565 target: loader.item
66− onClicked: genericFilterGrid.clicked(index, result)
66+ onClicked: genericFilterGrid.clicked(index, result, loader.item)
6767 onPressAndHold: genericFilterGrid.pressAndHold(index)
6868 }
6969 }
qml/Dash/CardVerticalJournal.qml+1−1
@@ -79,7 +79,7 @@ DashRenderer {
7979 }
8080 Connections {
8181 target: loader.item
82− onClicked: root.clicked(index, result)
82+ onClicked: root.clicked(index, result, loader.item)
8383 onPressAndHold: root.pressAndHold(index)
8484 }
8585 }
qml/Dash/Dash.qml+22−3
@@ -111,9 +111,13 @@ Showable {
111111 target: scopesOverview.scope
112112 onOpenScope: {
113113 scopeItem.scope = scope;
114− scopeItem.overviewScale = 0.4;
114+ scopeItem.overviewScale = scopesOverview.allCardSize.width / scopeItem.width;
115+ scopeItem.x = scopesOverview.allScopeClickedPos.x -(scopeItem.width - scopeItem.width * scopeItem.overviewScale) / 2;
116+ scopeItem.y = scopesOverview.allScopeClickedPos.y -(scopeItem.height - scopeItem.height * scopeItem.overviewScale) / 2;
115117 overviewController.showingNonFavoriteScope = true;
116118 scopeItem.overviewScale = 1;
119+ scopeItem.x = 0;
120+ scopeItem.y = 0;
117121 }
118122 }
119123 }
@@ -161,6 +165,7 @@ Showable {
161165 {
162166 anchors.fill: scopeItem
163167 scale: scopeItem.scale
168+ visible: scopeItem.visible
164169 }
165170
166171 GenericScopeView {
@@ -168,15 +173,25 @@ Showable {
168173
169174 property real overviewScale: 1
170175
176+ // TODO test this width + dashContent.x still works
171177 x: overviewController.showingNonFavoriteScope ? 0 : width + dashContent.x
178+ Behavior on x {
179+ enabled: overviewController.showingNonFavoriteScope
180+ UbuntuNumberAnimation { }
181+ }
182+ Behavior on y {
183+ enabled: overviewController.showingNonFavoriteScope
184+ UbuntuNumberAnimation { }
185+ }
172186 width: parent.width
173187 height: parent.height
174188 scale: dash.contentScale * overviewScale
189+ enabled: scale == 1
175190 Behavior on overviewScale {
176191 enabled: overviewController.showingNonFavoriteScope
177192 UbuntuNumberAnimation {
178193 onRunningChanged: {
179− if (!running && scopeItem.overviewScale == 0.4) {
194+ if (!running && scopeItem.overviewScale != 1) {
180195 scopesOverview.scope.closeScope(scopeItem.scope);
181196 overviewController.showingNonFavoriteScope = false;
182197 scopeItem.scope = null;
@@ -190,7 +205,10 @@ Showable {
190205 isCurrent: visible
191206 onBackClicked: {
192207 if (overviewController.showingNonFavoriteScope) {
193− scopeItem.overviewScale = 0.4;
208+ var v = scopesOverview.allCardSize.width / scopeItem.width;
209+ scopeItem.overviewScale = v;
210+ scopeItem.x = scopesOverview.allScopeClickedPos.x -(scopeItem.width - scopeItem.width * v) / 2;
211+ scopeItem.y = scopesOverview.allScopeClickedPos.y -(scopeItem.height - scopeItem.height * v) / 2;
194212 } else {
195213 closeOverlayScope();
196214 closePreview();
@@ -213,6 +231,7 @@ Showable {
213231 z: 1
214232 direction: Direction.Upwards
215233 distanceThreshold: units.gu(20)
234+ // TODO this needs to be disabled in a few more cases
216235 enabled: !overviewController.accepted || dragging
217236
218237 anchors { left: parent.left; right: parent.right; bottom: parent.bottom }
qml/Dash/DashRenderer.qml+2−1
@@ -45,7 +45,8 @@ Item {
4545 /// Emitted when the user clicked on an item
4646 /// @param index is the index of the clicked item
4747 /// @param result result model of the cliked item, used for activation
48− signal clicked(int index, var result)
48+ /// @param item item that has been clicked
49+ signal clicked(int index, var result, var item)
4950
5051 /// Emitted when the user pressed and held on an item
5152 /// @param index is the index of the held item
qml/Dash/ScopesOverview.qml+16−4
@@ -24,9 +24,9 @@ Item {
2424 property real progress: 0
2525 property var scope: null
2626 property var dashItemEater: {
27− if (middleItems.count > 1) {
28− var loader = middleItems.itemAt(0).item;
29− return loader && loader.currentItem ? loader.currentItem : null;
27+ if (middleItems.count > 0) {
28+ var loaderItem = middleItems.itemAt(0).item;
29+ return loaderItem && loaderItem.currentItem ? loaderItem.currentItem : null;
3030 }
3131 return null;
3232 }
@@ -37,6 +37,17 @@ Item {
3737 property string headerLogo: ""
3838 property color foreground: "white"
3939 }
40+ property size allCardSize: {
41+ if (middleItems.count > 1) {
42+ var loaderItem = middleItems.itemAt(1).item;
43+ if (loaderItem) {
44+ var cardTool = loaderItem.cardTool;
45+ return Qt.size(cardTool.cardWidth, cardTool.cardHeight);
46+ }
47+ }
48+ return Qt.size(0, 0);
49+ }
50+ property var allScopeClickedPos
4051
4152 signal done()
4253 signal favoriteSelected(int index)
@@ -232,7 +243,8 @@ Item {
232243 } else {
233244 // This will result in an openScope
234245 // that we handle in Dash.qml
235− scope.activate(result)
246+ root.allScopeClickedPos = item.mapToItem(null, 0, 0);
247+ scope.activate(result);
236248 }
237249 }
238250 onPressAndHold: {
qml/Dash/ScopesOverviewAll.qml+2−2
@@ -25,7 +25,7 @@ Flickable {
2525
2626 property real extraHeight: 0
2727
28− signal clicked(int index, var result)
28+ signal clicked(int index, var result, var item)
2929 signal pressAndHold(int index)
3030
3131 contentHeight: cardFilterGrid.height + extraHeight
@@ -40,7 +40,7 @@ Flickable {
4040 }
4141
4242 onClicked: {
43− root.clicked(index, result);
43+ root.clicked(index, result, item);
4444 }
4545 onPressAndHold: {
4646 root.pressAndHold(index);