on xenial help sign in
Refactor
33d72b2Albert Astals
qml/Dash/DashNavigationButton.qml+12−22
@@ -175,42 +175,32 @@ AbstractButton {
175 }
175 }
176
176
177 onScopeChanged: {
177 onScopeChanged: {
178+ setNewNavigation();
179+ }
180+
181+ function setNewNavigation() {
178 navigationModel.clear();
182 navigationModel.clear();
179 if (scope && scope[hasNavigation]) {
183 if (scope && scope[hasNavigation]) {
184+ var navigation = getNavigation(scope[currentNavigationId]);
185+ if (navigation.count > 0) {
180− navigationModel.append({"navigationId": scope[currentNavigationId], "nullifyNavigation": false});
186+ navigationModel.append({"navigationId": scope[currentNavigationId], "nullifyNavigation": false});
187+ } else {
188+ navigationModel.append({"navigationId": navigation.parentNavigationId, "nullifyNavigation": false});
189+ }
181 }
190 }
182 }
191 }
183
192
184 Connections {
193 Connections {
185 target: scope
194 target: scope
186 // This is duplicated since we can't have something based on the dynamic hasNavigation string property
195 // This is duplicated since we can't have something based on the dynamic hasNavigation string property
187− // TODO Try to merge these two together a bit more
188 onHasNavigationChanged: {
196 onHasNavigationChanged: {
189 if (!root.isAltNavigation) {
197 if (!root.isAltNavigation) {
190− if (scope.hasNavigation) {
198+ setNewNavigation();
191− var navigation = scope.getNavigation(scope.currentNavigationId);
192− if (navigation.count > 0) {
193− navigationModel.append({"navigationId": scope.currentNavigationId, "nullifyNavigation": false});
194− } else {
195− navigationModel.append({"navigationId": navigation.parentNavigationId, "nullifyNavigation": false});
196− }
197− } else {
198− navigationModel.clear();
199− }
200 }
199 }
201 }
200 }
202 onHasAltNavigationChanged: {
201 onHasAltNavigationChanged: {
203 if (root.isAltNavigation) {
202 if (root.isAltNavigation) {
204− if (scope.hasAltNavigation) {
203+ setNewNavigation();
205− var navigation = scope.getAltNavigation(scope.currentAltNavigationId);
206− if (navigation.count > 0) {
207− navigationModel.append({"navigationId": scope.currentAltNavigationId, "nullifyNavigation": false});
208− } else {
209− navigationModel.append({"navigationId": navigation.parentNavigationId, "nullifyNavigation": false});
210− }
211− } else {
212− navigationModel.clear();
213− }
214 }
204 }
215 }
205 }
216 }
206 }