on xenial help sign in
fix keyboard spread navigation; add mouse wheel support
1d4dbefLukáš Tinkl
qml/Stage/Spread/Spread.qml+9−8
@@ -9,6 +9,7 @@ Item {
9 property int highlightedIndex: -1
9 property int highlightedIndex: -1
10 property var model: null
10 property var model: null
11 property int leftMargin: 0
11 property int leftMargin: 0
12+ property var spreadFlickable
12
13
13 // some config options
14 // some config options
14 property real contentMargin: 0.16 * root.height
15 property real contentMargin: 0.16 * root.height
@@ -133,10 +134,10 @@ Item {
133 }
134 }
134
135
135 highlightedIndex = (highlightedIndex + 1) % totalItemCount;
136 highlightedIndex = (highlightedIndex + 1) % totalItemCount;
136− var newContentX = ((spreadTotalWidth) / (totalItemCount + 1)) * Math.max(0, Math.min(totalItemCount - 5, highlightedIndex - 3));
137+ var newContentX = (spreadTotalWidth / (totalItemCount + 1)) * Math.max(0, Math.min(totalItemCount - 1, highlightedIndex - 1));
137−// if (spreadFlickable.contentX < newContentX || spreadRepeater.highlightedIndex == 0) {
138+ if (spreadFlickable.contentX < newContentX || highlightedIndex == 0) {
138−// spreadFlickable.snapTo(newContentX)
139+ spreadFlickable.contentX = newContentX;
139−// }
140+ }
140 }
141 }
141
142
142 function selectPrevious(isAutoRepeat) {
143 function selectPrevious(isAutoRepeat) {
@@ -146,10 +147,10 @@ Item {
146
147
147 var newIndex = highlightedIndex - 1 >= 0 ? highlightedIndex - 1 : totalItemCount - 1;
148 var newIndex = highlightedIndex - 1 >= 0 ? highlightedIndex - 1 : totalItemCount - 1;
148 highlightedIndex = newIndex;
149 highlightedIndex = newIndex;
149−// var newContentX = ((spreadFlickable.contentWidth) / (topLevelSurfaceList.count + 1)) * Math.max(0, Math.min(topLevelSurfaceList.count - 5, spreadRepeater.highlightedIndex - 1));
150+ var newContentX = (spreadFlickable.contentWidth / (totalItemCount + 1)) * Math.max(0, Math.min(totalItemCount - 1, highlightedIndex - 1));
150−// if (spreadFlickable.contentX > newContentX || newIndex == topLevelSurfaceList.count -1) {
151+ if (spreadFlickable.contentX > newContentX || newIndex == totalItemCount - 1) {
151−// spreadFlickable.snapTo(newContentX)
152+ spreadFlickable.contentX = newContentX
152−// }
153+ }
153 }
154 }
154
155
155}
156}
qml/Stage/Stage.qml+10−1
@@ -455,6 +455,7 @@ AbstractStage {
455 anchors.fill: appContainer
455 anchors.fill: appContainer
456 leftMargin: root.leftMargin
456 leftMargin: root.leftMargin
457 model: root.topLevelSurfaceList
457 model: root.topLevelSurfaceList
458+ spreadFlickable: floatingFlickable
458 z: 10
459 z: 10
459
460
460 onLeaveSpread: {
461 onLeaveSpread: {
@@ -1617,6 +1618,14 @@ AbstractStage {
1617 }
1618 }
1618 }
1619 }
1619 }
1620 }
1621+ onWheel: {
1622+ if (wheel.angleDelta.y >= 120) {
1623+ spreadItem.selectNext(false);
1624+ } else if (wheel.angleDelta.y < 120 ){
1625+ spreadItem.selectPrevious(false);
1626+ }
1627+ }
1628+
1620 onPressed: mouse.accepted = false
1629 onPressed: mouse.accepted = false
1621 }
1630 }
1622
1631
@@ -1642,7 +1651,7 @@ AbstractStage {
1642 anchors { top: parent.top; right: parent.right; bottom: parent.bottom }
1651 anchors { top: parent.top; right: parent.right; bottom: parent.bottom }
1643 width: root.dragAreaWidth
1652 width: root.dragAreaWidth
1644
1653
1645− property var gesturePoints: new Array()
1654+ property var gesturePoints: []
1646 property bool cancelled: false
1655 property bool cancelled: false
1647
1656
1648 property real progress: dragging ? -touchPosition.x / root.width : 0
1657 property real progress: dragging ? -touchPosition.x / root.width : 0