on xenial help sign in
Disable Dash horizontal scroll while Navigation InverseMouseArea is pressed Fixes: #1403048

Approved by: Andrea Cimitan

commitfd7a329b3f64d26a536a7c686ff50616fe617a9b authorAlbert Astals <albert.astals@canonical.com> dateFri 9 Jan 2015, 10:40 (12 years ago) parent953086fa724cc3
5 files changed+30−3
qml/Dash/DashContent.qml+2−2 qml/Dash/DashNavigation.qml+4 qml/Dash/DashNavigationButton.qml+2 qml/Dash/GenericScopeView.qml+1−1 tests/qmltests/Dash/tst_DashContent.qml+21
qml/Dash/DashContent.qml+2−2
@@ -113,7 +113,7 @@ Item {
113113 objectName: "dashContentList"
114114
115115 interactive: !dashContent.forceNonInteractive && dashContent.scopes.loaded && currentItem
116− && !currentItem.moving && !currentItem.navigationShown && !currentItem.subPageShown
116+ && !currentItem.moving && !currentItem.navigationDisableParentInteractive && !currentItem.subPageShown
117117 anchors.fill: parent
118118 orientation: ListView.Horizontal
119119 boundsBehavior: Flickable.DragAndOvershootBounds
@@ -175,7 +175,7 @@ Item {
175175 objectName: "scopeLoader" + index
176176
177177 readonly property bool moving: item ? item.moving : false
178− readonly property bool navigationShown: item ? item.navigationShown : false
178+ readonly property bool navigationDisableParentInteractive: item ? item.navigationDisableParentInteractive : false
179179 readonly property bool subPageShown: item ? item.subPageShown : false
180180 readonly property var categoryView: item ? item.categoryView : null
181181 readonly property var theScope: scope
qml/Dash/DashNavigation.qml+4
@@ -33,6 +33,10 @@ Item {
3333 if (altNavigationButton.showList) return altNavigationButton.listView;
3434 return null;
3535 }
36+ readonly property bool disableParentInteractive: {
37+ return navigationButton.showList || altNavigationButton.showList ||
38+ navigationButton.inverseMousePressed || altNavigationButton.inverseMousePressed;
39+ }
3640
3741 // FIXME this is only here for highlight purposes (see Background.qml, too)
3842 readonly property var background: backgroundItem
qml/Dash/DashNavigationButton.qml+2
@@ -31,6 +31,7 @@ AbstractButton {
3131 // Used by parent
3232 readonly property var currentNavigation: scope && scope[hasNavigation] ? getNavigation(scope[currentNavigationId]) : null
3333 readonly property alias listView: navigationListView
34+ readonly property bool inverseMousePressed: inverseMouseArea.pressed
3435 property bool showList: false
3536
3637 // Internal
@@ -210,6 +211,7 @@ AbstractButton {
210211 onCurrentNavigationChanged: setNewNavigation();
211212
212213 InverseMouseArea {
214+ id: inverseMouseArea
213215 anchors.fill: navigationListView
214216 enabled: root.showList
215217 onPressed: root.showList = false
qml/Dash/GenericScopeView.qml+1−1
@@ -25,7 +25,7 @@ import "../Components/ListItems" as ListItems
2525FocusScope {
2626 id: scopeView
2727
28− readonly property bool navigationShown: pageHeaderLoader.item ? pageHeaderLoader.item.bottomItem[0].openList : false
28+ readonly property bool navigationDisableParentInteractive: pageHeaderLoader.item ? pageHeaderLoader.item.bottomItem[0].disableParentInteractive : false
2929 property bool forceNonInteractive: false
3030 property var scope: null
3131 property UnitySortFilterProxyModel categories: categoryFilter
tests/qmltests/Dash/tst_DashContent.qml+21
@@ -505,6 +505,27 @@ Item {
505505 compare(dashAltNavigationButton.showList, false);
506506 }
507507
508+ function test_navigationsSwipeToNextScope() {
509+ var dashContentList = findChild(dashContent, "dashContentList");
510+ tryCompareFunction(function() { return findChild(dashContentList.currentItem, "dashNavigation") != null; }, true);
511+ var dashNavigation = findChild(dashContentList.currentItem, "dashNavigation");
512+ tryCompare(dashNavigation, "visible", true);
513+ var dashNavigationButton = findChild(dashContentList.currentItem, "altNavigationButton");
514+ verify(dashNavigationButton, "Can't find navigation button");
515+
516+ compare(dashNavigationButton.showList, false);
517+ waitForRendering(dashNavigationButton);
518+ mouseClick(dashNavigationButton, 0, 0);
519+ compare(dashNavigationButton.showList, true);
520+
521+ mouseFlick(dashNavigationButton, dashNavigationButton.width - units.gu(1), units.gu(1), units.gu(1), units.gu(1));
522+ compare(dashNavigationButton.showList, false);
523+
524+ var dashContentList = findChild(dashContent, "dashContentList");
525+ expectFail("", "should not change the parent list.");
526+ tryCompare(dashContentList, "currentIndex", 1);
527+ }
528+
508529 function test_searchHint() {
509530 var dashContentList = findChild(dashContent, "dashContentList");
510531 verify(dashContentList !== null);