on xenial help sign in
Make "Done" in "All" grow from the current scope position
d584d6aAlbert Astals
qml/Dash/CardFilterGrid.qml+11
@@ -31,6 +31,17 @@ DashRenderer {
31 filterGrid.setFilter(filter, animate)
31 filterGrid.setFilter(filter, animate)
32 }
32 }
33
33
34+ function cardPosition(index) {
35+ var pos = {};
36+ var row = Math.floor(index / filterGrid.columns);
37+ var column = index % filterGrid.columns;
38+ // Bit sad this is not symmetrical
39+ pos.x = column * filterGrid.cellWidth + filterGrid.margins;
40+ pos.y = row * filterGrid.cellHeight;
41+ return pos;
42+ }
43+
44+
34 FilterGrid {
45 FilterGrid {
35 id: filterGrid
46 id: filterGrid
36 width: genericFilterGrid.width
47 width: genericFilterGrid.width
qml/Dash/Dash.qml+3−3
@@ -100,10 +100,10 @@ Showable {
100 onDone: {
100 onDone: {
101 if (dashContent.parent == scopesOverviewXYScaler) {
101 if (dashContent.parent == scopesOverviewXYScaler) {
102 // Animate Dash growing from the All screen
102 // Animate Dash growing from the All screen
103− // TODO find where the thing comes from for that x, y
103+ var currentScopePos = scopesOverview.allScopeCardPosition(dashContent.currentScopeId);
104 scopesOverviewXYScaler.scale = scopesOverview.allCardSize.width / scopesOverviewXYScaler.width;
104 scopesOverviewXYScaler.scale = scopesOverview.allCardSize.width / scopesOverviewXYScaler.width;
105− scopesOverviewXYScaler.x = /*scopesOverview.allScopeClickedPos.x*/ -(scopesOverviewXYScaler.width - scopesOverviewXYScaler.width * scopesOverviewXYScaler.scale) / 2;
105+ scopesOverviewXYScaler.x = currentScopePos.x -(scopesOverviewXYScaler.width - scopesOverviewXYScaler.width * scopesOverviewXYScaler.scale) / 2;
106− scopesOverviewXYScaler.y = /*scopesOverview.allScopeClickedPos.y*/ -(scopesOverviewXYScaler.height - scopesOverviewXYScaler.height * scopesOverviewXYScaler.scale) / 2;
106+ scopesOverviewXYScaler.y = currentScopePos.y -(scopesOverviewXYScaler.height - scopesOverviewXYScaler.height * scopesOverviewXYScaler.scale) / 2;
107 overviewController.growingDashFromAll = true;
107 overviewController.growingDashFromAll = true;
108 scopesOverviewXYScaler.scale = 1;
108 scopesOverviewXYScaler.scale = 1;
109 scopesOverviewXYScaler.x = 0;
109 scopesOverviewXYScaler.x = 0;
qml/Dash/DashContent.qml+1
@@ -26,6 +26,7 @@ Item {
26 property var model: null
26 property var model: null
27 property var scopes: null
27 property var scopes: null
28 readonly property alias currentIndex: dashContentList.currentIndex
28 readonly property alias currentIndex: dashContentList.currentIndex
29+ readonly property string currentScopeId: dashContentList.currentItem ? dashContentList.currentItem.scopeId : ""
29
30
30 signal scopeLoaded(string scopeId)
31 signal scopeLoaded(string scopeId)
31 signal gotoScope(string scopeId)
32 signal gotoScope(string scopeId)
qml/Dash/ScopesOverview.qml+10
@@ -53,6 +53,16 @@ Item {
53 signal favoriteSelected(int index)
53 signal favoriteSelected(int index)
54 signal allSelected(var scope)
54 signal allSelected(var scope)
55
55
56+ function allScopeCardPosition(scopeId) {
57+ if (middleItems.count > 1) {
58+ var loaderItem = middleItems.itemAt(1).item;
59+ if (loaderItem) {
60+ var pos = loaderItem.scopeCardPosition(scopeId);
61+ return loaderItem.mapToItem(null, pos.x, pos.y);
62+ }
63+ }
64+ }
65+
56 onProgressChanged: {
66 onProgressChanged: {
57 if (progress == 0) {
67 if (progress == 0) {
58 tabBarHolder.currentTab = 0;
68 tabBarHolder.currentTab = 0;
qml/Dash/ScopesOverviewAll.qml+7
@@ -31,6 +31,13 @@ Flickable {
31 contentHeight: cardFilterGrid.height + extraHeight
31 contentHeight: cardFilterGrid.height + extraHeight
32 contentWidth: cardFilterGrid.width
32 contentWidth: cardFilterGrid.width
33
33
34+ function scopeCardPosition(scopeId) {
35+ var index = model.scopeIndex(scopeId);
36+ var pos = cardFilterGrid.cardPosition(index);
37+ pos.y = pos.y - root.contentY;
38+ return pos;
39+ }
40+
34 CardFilterGrid {
41 CardFilterGrid {
35 id: cardFilterGrid
42 id: cardFilterGrid
36 width: parent.width
43 width: parent.width
tests/mocks/Unity/fake_scopesoverview.cpp+10
@@ -125,6 +125,16 @@ void ScopesOverviewResultsModel::setCategoryId(QString const& /*id*/)
125 qFatal("Calling un-implemented ScopesOverviewResultsModel::setCategoryId");
125 qFatal("Calling un-implemented ScopesOverviewResultsModel::setCategoryId");
126}
126}
127
127
128+int ScopesOverviewResultsModel::scopeIndex(QString const& id) const
129+{
130+ const int scopeCount = count();
131+ for (int i = 0; i < scopeCount; ++i) {
132+ if (m_scopes->scopeAt(i, m_isFavoriteCategory)->id() == id)
133+ return i;
134+ }
135+ return -1;
136+}
137+
128int ScopesOverviewResultsModel::rowCount(const QModelIndex& parent) const
138int ScopesOverviewResultsModel::rowCount(const QModelIndex& parent) const
129{
139{
130 Q_UNUSED(parent);
140 Q_UNUSED(parent);
tests/mocks/Unity/fake_scopesoverview.h+3
@@ -68,6 +68,9 @@ public:
68 /* setters */
68 /* setters */
69 void setCategoryId(QString const& id) override;
69 void setCategoryId(QString const& id) override;
70
70
71+ /* Special API */
72+ Q_INVOKABLE int scopeIndex(QString const& id) const;
73+
71private:
74private:
72 Scopes *m_scopes;
75 Scopes *m_scopes;
73 bool m_isFavoriteCategory;
76 bool m_isFavoriteCategory;