on xenial help sign in
Make "Done" in "All" grow from the current scope position
commitd584d6afb807af6450dfa688f6e08cb37659ae6d authorAlbert Astals <albert.astals@canonical.com> dateTue 15 Jul 2014, 15:59 (12 years ago) parent8cc984d
7 files changed+45−3
qml/Dash/CardFilterGrid.qml+11 qml/Dash/Dash.qml+3−3 qml/Dash/DashContent.qml+1 qml/Dash/ScopesOverview.qml+10 qml/Dash/ScopesOverviewAll.qml+7 tests/mocks/Unity/fake_scopesoverview.cpp+10 tests/mocks/Unity/fake_scopesoverview.h+3
qml/Dash/CardFilterGrid.qml+11
@@ -31,6 +31,17 @@ DashRenderer {
3131 filterGrid.setFilter(filter, animate)
3232 }
3333
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+
3445 FilterGrid {
3546 id: filterGrid
3647 width: genericFilterGrid.width
qml/Dash/Dash.qml+3−3
@@ -100,10 +100,10 @@ Showable {
100100 onDone: {
101101 if (dashContent.parent == scopesOverviewXYScaler) {
102102 // 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);
104104 scopesOverviewXYScaler.scale = scopesOverview.allCardSize.width / scopesOverviewXYScaler.width;
105− scopesOverviewXYScaler.x = /*scopesOverview.allScopeClickedPos.x*/ -(scopesOverviewXYScaler.width - scopesOverviewXYScaler.width * scopesOverviewXYScaler.scale) / 2;
106− scopesOverviewXYScaler.y = /*scopesOverview.allScopeClickedPos.y*/ -(scopesOverviewXYScaler.height - scopesOverviewXYScaler.height * scopesOverviewXYScaler.scale) / 2;
105+ scopesOverviewXYScaler.x = currentScopePos.x -(scopesOverviewXYScaler.width - scopesOverviewXYScaler.width * scopesOverviewXYScaler.scale) / 2;
106+ scopesOverviewXYScaler.y = currentScopePos.y -(scopesOverviewXYScaler.height - scopesOverviewXYScaler.height * scopesOverviewXYScaler.scale) / 2;
107107 overviewController.growingDashFromAll = true;
108108 scopesOverviewXYScaler.scale = 1;
109109 scopesOverviewXYScaler.x = 0;
qml/Dash/DashContent.qml+1
@@ -26,6 +26,7 @@ Item {
2626 property var model: null
2727 property var scopes: null
2828 readonly property alias currentIndex: dashContentList.currentIndex
29+ readonly property string currentScopeId: dashContentList.currentItem ? dashContentList.currentItem.scopeId : ""
2930
3031 signal scopeLoaded(string scopeId)
3132 signal gotoScope(string scopeId)
qml/Dash/ScopesOverview.qml+10
@@ -53,6 +53,16 @@ Item {
5353 signal favoriteSelected(int index)
5454 signal allSelected(var scope)
5555
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+
5666 onProgressChanged: {
5767 if (progress == 0) {
5868 tabBarHolder.currentTab = 0;
qml/Dash/ScopesOverviewAll.qml+7
@@ -31,6 +31,13 @@ Flickable {
3131 contentHeight: cardFilterGrid.height + extraHeight
3232 contentWidth: cardFilterGrid.width
3333
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+
3441 CardFilterGrid {
3542 id: cardFilterGrid
3643 width: parent.width
tests/mocks/Unity/fake_scopesoverview.cpp+10
@@ -125,6 +125,16 @@ void ScopesOverviewResultsModel::setCategoryId(QString const& /*id*/)
125125 qFatal("Calling un-implemented ScopesOverviewResultsModel::setCategoryId");
126126}
127127
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+
128138int ScopesOverviewResultsModel::rowCount(const QModelIndex& parent) const
129139{
130140 Q_UNUSED(parent);
tests/mocks/Unity/fake_scopesoverview.h+3
@@ -68,6 +68,9 @@ public:
6868 /* setters */
6969 void setCategoryId(QString const& id) override;
7070
71+ /* Special API */
72+ Q_INVOKABLE int scopeIndex(QString const& id) const;
73+
7174private:
7275 Scopes *m_scopes;
7376 bool m_isFavoriteCategory;