on xenial help sign in
better handling of indicator current item.
a869d33Nick Dedekind
Panel/IndicatorRow.qml+7−8
@@ -31,16 +31,15 @@ Item {
31 width: units.gu(40)
31 width: units.gu(40)
32 height: units.gu(3)
32 height: units.gu(3)
33
33
34− Component.onCompleted: setDefaultItem()
35−
36 function setDefaultItem() {
34 function setDefaultItem() {
37 // The leftmost indicator
35 // The leftmost indicator
38− var defaultItemIndex = 0
36+ setCurrentItem(0);
39− setItem(defaultItemIndex)
40 }
37 }
41
38
42− function setItem(index) {
39+ function setCurrentItem(index) {
40+ if (currentItemIndex !== index) {
43− currentItem = rowRepeater.itemAt(index)
41+ currentItem = rowRepeater.itemAt(index);
42+ }
44 }
43 }
45
44
46 Row {
45 Row {
@@ -68,9 +67,9 @@ Item {
68 height: indicatorRow.height
67 height: indicatorRow.height
69 y: {
68 y: {
70 if (!highlighted && (indicatorRow.state == "locked" || indicatorRow.state == "commit")) {
69 if (!highlighted && (indicatorRow.state == "locked" || indicatorRow.state == "commit")) {
71− return -indicatorRow.height
70+ return -indicatorRow.height;
72 } else {
71 } else {
73− return 0
72+ return 0;
74 }
73 }
75 }
74 }
76 Behavior on y {
75 Behavior on y {
Panel/Indicators.qml+44−17
@@ -41,6 +41,13 @@ Showable {
41 duration: 350
41 duration: 350
42 to: openedHeight
42 to: openedHeight
43 easing.type: Easing.OutCubic
43 easing.type: Easing.OutCubic
44+
45+ // Re-size if we've changed the openHeight while shown.
46+ onToChanged: {
47+ if (indicators.shown) {
48+ indicators.show();
49+ }
50+ }
44 }
51 }
45
52
46 hideAnimation: StandardAnimation {
53 hideAnimation: StandardAnimation {
@@ -73,11 +80,11 @@ Showable {
73 }
80 }
74
81
75 function calculateCurrentItem(xValue, useBuffer) {
82 function calculateCurrentItem(xValue, useBuffer) {
76− var rowCoordinates
83+ var rowCoordinates;
77− var itemCoordinates
84+ var itemCoordinates;
78− var currentItem
85+ var currentItem;
79− var distanceFromRightEdge
86+ var distanceFromRightEdge;
80− var bufferExceeded = false
87+ var bufferExceeded = false;
81
88
82 if (indicators.state == "commit" || indicators.state == "locked" || showAnimation.running || hideAnimation.running) return;
89 if (indicators.state == "commit" || indicators.state == "locked" || showAnimation.running || hideAnimation.running) return;
83
90
@@ -162,8 +169,15 @@ Showable {
162 indicatorsModel: indicatorsModel
169 indicatorsModel: indicatorsModel
163 clip: !indicators.fullyOpened
170 clip: !indicators.fullyOpened
164
171
165− onMenuSelected: {
172+ Connections {
166− indicatorRow.setItem(index)
173+ target: indicatorRow
174+ onCurrentItemIndexChanged: menuContent.updateCurrentMenu();
175+ }
176+
177+ function updateCurrentMenu() {
178+ if (currentMenuIndex != indicatorRow.currentItemIndex) {
179+ currentMenuIndex = indicatorRow.currentItemIndex;
180+ }
167 }
181 }
168
182
169 //small shadow gradient at bottom of menu
183 //small shadow gradient at bottom of menu
@@ -233,28 +247,35 @@ Showable {
233 indicatorsModel: indicatorsModel
247 indicatorsModel: indicatorsModel
234 state: indicators.state
248 state: indicators.state
235
249
236− onCurrentItemIndexChanged: menuContent.currentIndex = currentItemIndex
250+ Connections {
251+ target: menuContent
252+ onCurrentMenuIndexChanged: {
253+ indicatorRow.setCurrentItem(menuContent.currentMenuIndex);
254+ }
255+ }
237 }
256 }
238
257
239 Connections {
258 Connections {
240− target: hideAnimation
259+ target: showAnimation
241 onRunningChanged: {
260 onRunningChanged: {
242− if (hideAnimation.running) {
261+ if (showAnimation.running) {
243− indicators.state = "initial"
262+ indicators.state = "commit";
244− indicatorRow.currentItem = null;
245 }
263 }
246 }
264 }
247 }
265 }
266+
248 Connections {
267 Connections {
249− target: showAnimation
268+ target: hideAnimation
250 onRunningChanged: {
269 onRunningChanged: {
251− if (showAnimation.running) {
270+ if (hideAnimation.running) {
252− indicators.calculateCurrentItem(dragHandle.touchX, false);
271+ indicators.state = "initial";
253− indicators.state = "commit";
272+ indicatorRow.currentItem = null;
254 }
273 }
255 }
274 }
256 }
275 }
257
276
277+ property var dragHandle: null
278+ // connections to the active drag handle
258 Connections {
279 Connections {
259 target: dragHandle
280 target: dragHandle
260 onTouchXChanged: {
281 onTouchXChanged: {
@@ -263,7 +284,6 @@ Showable {
263 }
284 }
264 }
285 }
265
286
266− property var dragHandle: showDragHandle.dragging ? showDragHandle : hideDragHandle
267 DragHandle {
287 DragHandle {
268 id: showDragHandle
288 id: showDragHandle
269 anchors.bottom: parent.bottom
289 anchors.bottom: parent.bottom
@@ -285,6 +305,9 @@ Showable {
285 menuContent.activateContent();
305 menuContent.activateContent();
286 }
306 }
287 }
307 }
308+ onDraggingChanged: {
309+ dragHandle = dragging ? showDragHandle : null;
310+ }
288 }
311 }
289 DragHandle {
312 DragHandle {
290 id: hideDragHandle
313 id: hideDragHandle
@@ -296,6 +319,10 @@ Showable {
296 stretch: true
319 stretch: true
297 maxTotalDragDistance: openedHeight - panelHeight
320 maxTotalDragDistance: openedHeight - panelHeight
298 distanceThreshold: 0
321 distanceThreshold: 0
322+
323+ onDraggingChanged: {
324+ dragHandle = dragging ? hideDragHandle : null;
325+ }
299 }
326 }
300
327
301 states: [
328 states: [
Panel/MenuContent.qml+1−1
@@ -24,7 +24,7 @@ Rectangle {
24
24
25 property QtObject indicatorsModel: null
25 property QtObject indicatorsModel: null
26 property bool __contentActive: false
26 property bool __contentActive: false
27− property alias currentIndex : menus.currentIndex
27+ property alias currentMenuIndex : menus.currentIndex
28 property color backgroundColor: "#221e1c"
28 property color backgroundColor: "#221e1c"
29 property int contentReleaseInterval: 20000
29 property int contentReleaseInterval: 20000
30
30