on xenial help sign in
Remove the altnavigation qml code
commit90c5f00561cbc6adf2c1016f8ac11bdbfb5b958d authorAlbert Astals Cid <albert.astals@canonical.com> dateThu 3 Sep 2015, 15:15 (11 years ago) parentdf4309c
3 files changed+10−157
qml/Dash/DashNavigation.qml+3−33 qml/Dash/DashNavigationButton.qml+6−16 tests/qmltests/Dash/tst_DashContent.qml+1−108
qml/Dash/DashNavigation.qml+3−33
@@ -30,28 +30,24 @@ Item {
3030 property alias windowHeight: blackRect.height
3131 readonly property var openList: {
3232 if (navigationButton.showList) return navigationButton.listView;
33− if (altNavigationButton.showList) return altNavigationButton.listView;
3433 return null;
3534 }
3635 readonly property bool disableParentInteractive: {
37− return navigationButton.showList || altNavigationButton.showList ||
38− navigationButton.inverseMousePressed || altNavigationButton.inverseMousePressed;
36+ return navigationButton.showList || navigationButton.inverseMousePressed;
3937 }
4038
4139 // FIXME this is only here for highlight purposes (see Background.qml, too)
4240 readonly property var background: backgroundItem
4341
4442 visible: height != 0
45− height: navigationButton.currentNavigation || altNavigationButton.currentNavigation ? units.gu(5) : 0
43+ height: navigationButton.currentNavigation ? units.gu(5) : 0
4644
4745 QtObject {
4846 id: d
4947 readonly property color foregroundColor: root.scopeStyle
5048 ? root.scopeStyle.getTextColor(backgroundItem.luminance)
5149 : Theme.palette.normal.baseText
52− readonly property bool bothVisible: altNavigationButton.visible && navigationButton.visible
5350 readonly property real navigationWidth: root.width >= units.gu(60) ? units.gu(40) : root.width
54− readonly property real buttonWidth: navigationWidth / (bothVisible ? 2 : 1)
5551 }
5652
5753 Rectangle {
@@ -76,27 +72,11 @@ Item {
7672 anchors { top: parent.bottom; left: parent.left; right: parent.right }
7773 }
7874
79− DashNavigationButton {
80− id: altNavigationButton
81− objectName: "altNavigationButton"
82− height: root.height
83− width: d.buttonWidth
84− scope: root.scope
85− scopeStyle: root.scopeStyle
86− foregroundColor: d.foregroundColor
87− listView.width: d.navigationWidth
88− isAltNavigation: true
89− showDivider: navigationButton.visible || root.width > d.navigationWidth
90− // needed so that InverseMouseArea is above navigationButton
91− z: listView.height > 0 ? 1 : 0
92− }
93−
9475 DashNavigationButton {
9576 id: navigationButton
9677 objectName: "navigationButton"
9778 height: root.height
98− width: altNavigationButton.visible ? d.buttonWidth : d.navigationWidth
99− x: altNavigationButton.visible ? d.buttonWidth : 0
79+ width: d.navigationWidth
10080 scope: root.scope
10181 scopeStyle: root.scopeStyle
10282 foregroundColor: d.foregroundColor
@@ -104,14 +84,4 @@ Item {
10484 listView.x: -x
10585 showDivider: root.width > d.navigationWidth
10686 }
107−
108− Image {
109− fillMode: Image.Stretch
110− source: backgroundItem.luminance > 0.7 ? "graphics/navigation_shadow.png" : "graphics/navigation_shadow_light.png"
111− x: navigationButton.listView.height > 0 ? altNavigationButton.x : navigationButton.x
112− width: d.buttonWidth
113− rotation: 180
114− anchors.bottom: parent.bottom
115− visible: d.bothVisible && (navigationButton.listView.height > 0 || altNavigationButton.listView.height > 0)
116− }
11787}
qml/Dash/DashNavigationButton.qml+6−16
@@ -25,11 +25,10 @@ AbstractButton {
2525 property var scope: null
2626 property var scopeStyle: null
2727 property color foregroundColor: Theme.palette.normal.baseText
28− property bool isAltNavigation: false
2928 property bool showDivider: false
3029
3130 // Used by parent
32− readonly property var currentNavigation: scope && scope[hasNavigation] ? getNavigation(scope[currentNavigationId]) : null
31+ readonly property var currentNavigation: scope && scope.hasNavigation ? scope.getNavigation(scope.currentNavigationId) : null
3332 readonly property alias listView: navigationListView
3433 readonly property bool inverseMousePressed: inverseMouseArea.pressed
3534 property bool showList: false
@@ -37,15 +36,6 @@ AbstractButton {
3736 // Internal
3837 // Are we drilling down the tree or up?
3938 property bool isGoingBack: false
40− readonly property string hasNavigation: isAltNavigation ? "hasAltNavigation" : "hasNavigation"
41− readonly property string currentNavigationId: isAltNavigation ? "currentAltNavigationId" : "currentNavigationId"
42− function getNavigation(navId) {
43− if (isAltNavigation) {
44− return scope.getAltNavigation(navId);
45− } else {
46− return scope.getNavigation(navId);
47− }
48− }
4939
5040 visible: root.currentNavigation != null
5141
@@ -125,10 +115,10 @@ AbstractButton {
125115 }
126116 }
127117 height: desiredHeight
128− navigation: (nullifyNavigation || !scope) ? null : getNavigation(navigationId)
118+ navigation: (nullifyNavigation || !scope) ? null : scope.getNavigation(navigationId)
129119 currentNavigation: root.currentNavigation
130120 onEnterNavigation: {
131− scope.setNavigationState(newNavigationId, isAltNavigation);
121+ scope.setNavigationState(newNavigationId);
132122 // We only need to add a new item to the model
133123 // if we have children, otherwise just load it
134124 if (hasChildren) {
@@ -151,7 +141,7 @@ AbstractButton {
151141 navigationListView.highlightMoveDuration = aux;
152142 }
153143
154− scope.setNavigationState(navigation.parentNavigationId, isAltNavigation);
144+ scope.setNavigationState(navigation.parentNavigationId);
155145 isGoingBack = true;
156146 navigationModel.setProperty(navigationListView.currentIndex - 1, "nullifyNavigation", false);
157147 navigationListView.currentIndex--;
@@ -160,7 +150,7 @@ AbstractButton {
160150 showList = false;
161151 if (root.currentNavigation.parentNavigationId == navigation.navigationId) {
162152 // For leaves we have to go to the parent too
163− scope.setNavigationState(root.currentNavigation.parentNavigationId, isAltNavigation);
153+ scope.setNavigationState(root.currentNavigation.parentNavigationId);
164154 }
165155 }
166156 }
@@ -198,7 +188,7 @@ AbstractButton {
198188 if (isFirstLoad && currentNavigation && currentNavigation.loaded) {
199189 isFirstLoad = false;
200190 if (currentNavigation.count > 0) {
201− navigationModel.append({"navigationId": scope[currentNavigationId], "nullifyNavigation": false});
191+ navigationModel.append({"navigationId": scope.currentNavigationId, "nullifyNavigation": false});
202192 } else {
203193 navigationModel.append({"navigationId": currentNavigation.parentNavigationId, "nullifyNavigation": false});
204194 }
tests/qmltests/Dash/tst_DashContent.qml+1−108
@@ -403,119 +403,12 @@ Item {
403403 tryCompare(dashNavigationButton.currentNavigation, "navigationId", "middle2");
404404 }
405405
406− function test_altNavigation() {
407− var dashContentList = findChild(dashContent, "dashContentList");
408− tryCompareFunction(function() { return findChild(dashContentList.currentItem, "dashNavigation") != null; }, true);
409− var dashNavigation = findChild(dashContentList.currentItem, "dashNavigation");
410− tryCompare(dashNavigation, "visible", true);
411− var dashNavigationButton = findChild(dashContentList.currentItem, "altNavigationButton");
412− verify(dashNavigationButton, "Can't find navigation button");
413−
414− compare(dashNavigationButton.showList, false);
415− waitForRendering(dashNavigationButton);
416− mouseClick(dashNavigationButton);
417− compare(dashNavigationButton.showList, true);
418−
419− var navigationListView = findChild(dashNavigationButton, "navigationListView");
420− tryCompareFunction(function() {
421− return navigationListView.currentItem &&
422− navigationListView.currentItem.navigation &&
423− navigationListView.currentItem.navigation.loaded; }, true);
424−
425− waitForRendering(navigationListView);
426− waitForRendering(navigationListView.currentItem);
427−
428− tryCompare(dashNavigationButton.currentNavigation, "navigationId", "altrootChild1");
429− tryCompare(navigationListView.currentItem.navigation, "navigationId", "altroot");
430−
431− var allButton = findChild(dashNavigationButton, "allButton");
432− compare(allButton.visible, false);
433− var backButton = findChild(navigationListView, "backButton");
434− compare(backButton.visible, false);
435−
436− var navigation = findChild(dashNavigationButton, "navigation0child3");
437− mouseClick(navigation);
438− compare(dashNavigationButton.showList, false);
439− tryCompare(dashNavigationButton.currentNavigation, "navigationId", "altrootChild3");
440− tryCompare(navigationListView.currentItem.navigation, "navigationId", "altroot");
441−
442− mouseClick(dashNavigationButton);
443− compare(dashNavigationButton.showList, true);
444− waitForRendering(navigationListView);
445− waitForRendering(navigationListView.currentItem);
446− compare(allButton.visible, false);
447−
448− navigation = findChild(dashNavigationButton, "navigation0child2");
449− mouseClick(navigation);
450− compare(dashNavigationButton.showList, false);
451− tryCompare(dashNavigationButton.currentNavigation, "navigationId", "altrootChild2");
452− tryCompare(navigationListView.currentItem.navigation, "navigationId", "altroot");
453−
454− mouseClick(dashNavigationButton);
455− compare(dashNavigationButton.showList, true);
456− waitForRendering(navigationListView);
457− waitForRendering(navigationListView.currentItem);
458− verify(!backButton.visible, "Back button should not be visible");
459−
460− compare(navigationListView.count, 1, "There should be no second-level navigation");
461−
462− mouseClick(dashNavigationButton);
463− compare(dashNavigationButton.showList, false);
464− }
465−
466− function test_navigationsClosing() {
467− var dashContentList = findChild(dashContent, "dashContentList");
468− tryCompareFunction(function() { return findChild(dashContentList.currentItem, "dashNavigation") != null; }, true);
469− var dashNavigation = findChild(dashContentList.currentItem, "dashNavigation");
470− tryCompare(dashNavigation, "visible", true);
471− var dashNavigationButton = findChild(dashContentList.currentItem, "navigationButton");
472− verify(dashNavigationButton, "Can't find navigation button");
473− var dashAltNavigationButton = findChild(dashContentList.currentItem, "altNavigationButton");
474− verify(dashAltNavigationButton, "Can't find alternative navigation button");
475−
476− waitForRendering(dashNavigationButton);
477− waitForRendering(dashAltNavigationButton);
478−
479− compare(dashNavigationButton.showList, false);
480− compare(dashAltNavigationButton.showList, false);
481−
482− mouseClick(dashAltNavigationButton);
483− compare(dashNavigationButton.showList, false);
484− compare(dashAltNavigationButton.showList, true);
485−
486− var navigationListView = findChild(dashAltNavigationButton, "navigationListView");
487− tryCompareFunction(function() {
488− return navigationListView.currentItem &&
489− navigationListView.currentItem.navigation &&
490− navigationListView.currentItem.navigation.loaded; }, true);
491−
492− var blackRect = findChild(dashNavigation, "blackRect");
493− tryCompare(blackRect, "opacity", 0.5);
494−
495− mouseClick(dashNavigationButton);
496− compare(dashNavigationButton.showList, false);
497− compare(dashAltNavigationButton.showList, false);
498−
499− tryCompare(navigationListView, "visible", false);
500−
501− mouseClick(dashNavigationButton);
502− compare(dashNavigationButton.showList, true);
503− compare(dashAltNavigationButton.showList, false);
504−
505− navigationListView = findChild(dashNavigationButton, "navigationListView");
506− tryCompare(navigationListView.currentItem.navigation, "loaded", true);
507−
508− mouseClick(dashAltNavigationButton);
509− compare(dashNavigationButton.showList, false);
510− compare(dashAltNavigationButton.showList, false);
511− }
512−
513406 function test_navigationsSwipeToNextScope() {
514407 var dashContentList = findChild(dashContent, "dashContentList");
515408 tryCompareFunction(function() { return findChild(dashContentList.currentItem, "dashNavigation") != null; }, true);
516409 var dashNavigation = findChild(dashContentList.currentItem, "dashNavigation");
517410 tryCompare(dashNavigation, "visible", true);
518− var dashNavigationButton = findChild(dashContentList.currentItem, "altNavigationButton");
411+ var dashNavigationButton = findChild(dashContentList.currentItem, "navigationButton");
519412 verify(dashNavigationButton, "Can't find navigation button");
520413
521414 compare(dashNavigationButton.showList, false);