on xenial help sign in
Make Navigation work when "jumping" to the non root
4f28aa7Albert Astals
qml/Dash/DashNavigationButton.qml+26−11
@@ -139,6 +139,17 @@ AbstractButton {
139 }
139 }
140 }
140 }
141 onGoBackToParentClicked: {
141 onGoBackToParentClicked: {
142+ if (navigationListView.currentIndex == 0) {
143+ // This can happen if we jumped to the non root of a deep tree and the user
144+ // is now going back, create space in the list for the list to move "left"
145+ var aux = navigationListView.highlightMoveDuration;
146+ navigationListView.highlightMoveDuration = 0;
147+ navigationModel.insert(0, {"navigationId": navigation.parentNavigationId, "nullifyNavigation": false});
148+ navigationListView.currentIndex = navigationListView.currentIndex + 1;
149+ navigationListView.contentX = width * navigationListView.currentIndex;
150+ navigationListView.highlightMoveDuration = aux;
151+ }
152+
142 scope.setNavigationState(navigation.parentNavigationId, isAltNavigation);
153 scope.setNavigationState(navigation.parentNavigationId, isAltNavigation);
143 isGoingBack = true;
154 isGoingBack = true;
144 navigationModel.setProperty(navigationListView.currentIndex - 1, "nullifyNavigation", false);
155 navigationModel.setProperty(navigationListView.currentIndex - 1, "nullifyNavigation", false);
@@ -153,6 +164,9 @@ AbstractButton {
153 }
164 }
154 }
165 }
155 onContentXChanged: {
166 onContentXChanged: {
167+ if (navigationListView.highlightMoveDuration == 0)
168+ return;
169+
156 if (contentX == width * navigationListView.currentIndex) {
170 if (contentX == width * navigationListView.currentIndex) {
157 if (isGoingBack) {
171 if (isGoingBack) {
158 navigationModel.remove(navigationListView.currentIndex + 1);
172 navigationModel.remove(navigationListView.currentIndex + 1);
@@ -175,9 +189,18 @@ AbstractButton {
175 }
189 }
176
190
177 onScopeChanged: {
191 onScopeChanged: {
192+ setNewNavigation();
193+ }
194+
195+ function setNewNavigation() {
178 navigationModel.clear();
196 navigationModel.clear();
179 if (scope && scope[hasNavigation]) {
197 if (scope && scope[hasNavigation]) {
198+ var navigation = getNavigation(scope[currentNavigationId]);
199+ if (navigation.count > 0) {
180− navigationModel.append({"navigationId": scope[currentNavigationId], "nullifyNavigation": false});
200+ navigationModel.append({"navigationId": scope[currentNavigationId], "nullifyNavigation": false});
201+ } else {
202+ navigationModel.append({"navigationId": navigation.parentNavigationId, "nullifyNavigation": false});
203+ }
181 }
204 }
182 }
205 }
183
206
@@ -186,20 +209,12 @@ AbstractButton {
186 // This is duplicated since we can't have something based on the dynamic hasNavigation string property
209 // This is duplicated since we can't have something based on the dynamic hasNavigation string property
187 onHasNavigationChanged: {
210 onHasNavigationChanged: {
188 if (!root.isAltNavigation) {
211 if (!root.isAltNavigation) {
189− if (scope.hasNavigation) {
212+ setNewNavigation();
190− navigationModel.append({"navigationId": scope.currentNavigationId, "nullifyNavigation": false});
191− } else {
192− navigationModel.clear();
193− }
194 }
213 }
195 }
214 }
196 onHasAltNavigationChanged: {
215 onHasAltNavigationChanged: {
197 if (root.isAltNavigation) {
216 if (root.isAltNavigation) {
198− if (scope.hasAltNavigation) {
217+ setNewNavigation();
199− navigationModel.append({"navigationId": scope.currentAltNavigationId, "nullifyNavigation": false});
200− } else {
201− navigationModel.clear();
202− }
203 }
218 }
204 }
219 }
205 }
220 }