on xenial help sign in
adhere to the project's coding style
648e4f2Daniel d'Andrada
Components/DragHandle.qml+30−27
@@ -72,16 +72,16 @@ DirectionalDragArea {
72 onDistanceChanged: {
72 onDistanceChanged: {
73 if (status === DirectionalDragArea.Recognized) {
73 if (status === DirectionalDragArea.Recognized) {
74 // don't go the whole distance in order to smooth out the movement
74 // don't go the whole distance in order to smooth out the movement
75− var step = distance * 0.3
75+ var step = distance * 0.3;
76
76
77− step = __limitMovement(step)
77+ step = __limitMovement(step);
78
78
79− __totalDragDistance += step
79+ __totalDragDistance += step;
80
80
81 if (Direction.isHorizontal(direction)) {
81 if (Direction.isHorizontal(direction)) {
82− parent.x += step
82+ parent.x += step;
83 } else {
83 } else {
84− parent.y += step
84+ parent.y += step;
85 }
85 }
86 }
86 }
87 }
87 }
@@ -90,56 +90,59 @@ DirectionalDragArea {
90 function __limitMovement(step) {
90 function __limitMovement(step) {
91 if (Direction.isPositive(direction)) {
91 if (Direction.isPositive(direction)) {
92 if (__totalDragDistance + step > maxTotalDragDistance) {
92 if (__totalDragDistance + step > maxTotalDragDistance) {
93− step = maxTotalDragDistance - __totalDragDistance
93+ step = maxTotalDragDistance - __totalDragDistance;
94 } else if (__totalDragDistance + step < 0) {
94 } else if (__totalDragDistance + step < 0) {
95− step = 0 - __totalDragDistance
95+ step = 0 - __totalDragDistance;
96 }
96 }
97 } else {
97 } else {
98 if (__totalDragDistance + step < -maxTotalDragDistance) {
98 if (__totalDragDistance + step < -maxTotalDragDistance) {
99− step = -maxTotalDragDistance - __totalDragDistance
99+ step = -maxTotalDragDistance - __totalDragDistance;
100 } else if (__totalDragDistance + step > 0) {
100 } else if (__totalDragDistance + step > 0) {
101− step = 0 - __totalDragDistance
101+ step = 0 - __totalDragDistance;
102 }
102 }
103 }
103 }
104
104
105− return step
105+ return step;
106 }
106 }
107
107
108 onStatusChanged: {
108 onStatusChanged: {
109 if (status === DirectionalDragArea.WaitingForTouch) {
109 if (status === DirectionalDragArea.WaitingForTouch) {
110 if (__previousStatus === DirectionalDragArea.Recognized) {
110 if (__previousStatus === DirectionalDragArea.Recognized) {
111− __onFinishedRecognizedGesture()
111+ __onFinishedRecognizedGesture();
112 }
112 }
113− __totalDragDistance = 0
113+ __totalDragDistance = 0;
114 }
114 }
115 else if (status === DirectionalDragArea.Undecided) {
115 else if (status === DirectionalDragArea.Undecided) {
116− dragEvaluator.reset()
116+ dragEvaluator.reset();
117 }
117 }
118 else if (status === DirectionalDragArea.Recognized) {
118 else if (status === DirectionalDragArea.Recognized) {
119 if (__previousStatus === DirectionalDragArea.WaitingForTouch)
119 if (__previousStatus === DirectionalDragArea.WaitingForTouch)
120− dragEvaluator.reset()
120+ dragEvaluator.reset();
121 }
121 }
122− __previousStatus = status
122+ __previousStatus = status;
123 }
123 }
124
124
125 function __onFinishedRecognizedGesture() {
125 function __onFinishedRecognizedGesture() {
126− if (dragEvaluator.shouldAutoComplete())
126+ if (dragEvaluator.shouldAutoComplete()) {
127− __completeDrag()
127+ __completeDrag();
128− else
128+ } else {
129− __rollbackDrag()
129+ __rollbackDrag();
130+ }
130 }
131 }
131
132
132 function __completeDrag() {
133 function __completeDrag() {
133− if (parent.shown)
134+ if (parent.shown) {
134− parent.hide()
135+ parent.hide();
135− else
136+ } else {
136− parent.show()
137+ parent.show();
138+ }
137 }
139 }
138
140
139 function __rollbackDrag() {
141 function __rollbackDrag() {
140− if (parent.shown)
142+ if (parent.shown) {
141− parent.show()
143+ parent.show();
142− else
144+ } else {
143− parent.hide()
145+ parent.hide();
146+ }
144 }
147 }
145}
148}
Components/EdgeDragEvaluator.qml+13−12
@@ -52,21 +52,22 @@ AxisVelocityCalculator {
52
52
53 // Returns whether the drag should continue by itself until completed.
53 // Returns whether the drag should continue by itself until completed.
54 function shouldAutoComplete() {
54 function shouldAutoComplete() {
55− var deltaPos = trackedPosition - __startPosition
55+ var deltaPos = trackedPosition - __startPosition;
56 if (Math.abs(deltaPos) < minDragDistance) {
56 if (Math.abs(deltaPos) < minDragDistance) {
57− velocity = 0
57+ velocity = 0;
58− minVelocity = 0
58+ minVelocity = 0;
59− return false
59+ return false;
60 }
60 }
61
61
62− minVelocity = __calculateMinimumVelocityForAutoCompletion(deltaPos)
62+ minVelocity = __calculateMinimumVelocityForAutoCompletion(deltaPos);
63− velocity = calculate()
63+ velocity = calculate();
64
64
65 if (Direction.isPositive(direction) && (velocity >= minVelocity)
65 if (Direction.isPositive(direction) && (velocity >= minVelocity)
66− || !Direction.isPositive(direction) && (velocity <= minVelocity))
66+ || !Direction.isPositive(direction) && (velocity <= minVelocity)) {
67− return true
67+ return true;
68− else
68+ } else {
69− return false
69+ return false;
70+ }
70 }
71 }
71
72
72 property real __startPosition
73 property real __startPosition
@@ -78,10 +79,10 @@ AxisVelocityCalculator {
78 property real __v0: Direction.isPositive(direction) ? __speedThresholdMs : - __speedThresholdMs
79 property real __v0: Direction.isPositive(direction) ? __speedThresholdMs : - __speedThresholdMs
79
80
80 function __calculateMinimumVelocityForAutoCompletion(distance) {
81 function __calculateMinimumVelocityForAutoCompletion(distance) {
81− return __v0 - ((__speedThresholdMs / dragThreshold) * distance)
82+ return __v0 - ((__speedThresholdMs / dragThreshold) * distance);
82 }
83 }
83
84
84 function reset() {
85 function reset() {
85− __startPosition = trackedPosition
86+ __startPosition = trackedPosition;
86 }
87 }
87}
88}
Components/Stage.qml+1−1
@@ -480,7 +480,7 @@ Showable {
480 }
480 }
481
481
482 function onUndecided() {
482 function onUndecided() {
483− dragEvaluator.reset()
483+ dragEvaluator.reset();
484
484
485 var nextApplication = null;
485 var nextApplication = null;
486 if (stage.applications.count > 1) {
486 if (stage.applications.count > 1) {
Shell.qml+2−3
@@ -170,9 +170,9 @@ FocusScope {
170 opacity: 1.0 - disappearingAnimationProgress
170 opacity: 1.0 - disappearingAnimationProgress
171 property real disappearingAnimationProgress: {
171 property real disappearingAnimationProgress: {
172 if (greeter.shown) {
172 if (greeter.shown) {
173− return greeter.showProgress
173+ return greeter.showProgress;
174 } else {
174 } else {
175− return stagesOuterContainer.showProgress
175+ return stagesOuterContainer.showProgress;
176 }
176 }
177 }
177 }
178
178
@@ -439,7 +439,6 @@ FocusScope {
439 var bgPath = greeter.model.data(uid, LightDM.UserRoles.BackgroundPathRole)
439 var bgPath = greeter.model.data(uid, LightDM.UserRoles.BackgroundPathRole)
440 shell.background = bgPath ? bgPath : default_background
440 shell.background = bgPath ? bgPath : default_background
441 }
441 }
442−
443 }
442 }
444
443
445 InputFilterArea {
444 InputFilterArea {
tests/qmltests/Components/tst_DragHandle.qml+15−12
@@ -70,10 +70,11 @@ Item {
70
70
71 y: {
71 y: {
72 if (dragHandle) {
72 if (dragHandle) {
73− if (dragHandle.direction === Direction.Downwards)
73+ if (dragHandle.direction === Direction.Downwards) {
74− dragHandle.edgeDragEvaluator.dragThreshold
74+ dragHandle.edgeDragEvaluator.dragThreshold;
75− else
75+ } else {
76− parent.height - dragHandle.edgeDragEvaluator.dragThreshold
76+ parent.height - dragHandle.edgeDragEvaluator.dragThreshold;
77+ }
77 } else {
78 } else {
78 0
79 0
79 }
80 }
@@ -90,20 +91,22 @@ Item {
90 id: velocityText
91 id: velocityText
91 font.pixelSize: units.gu(2)
92 font.pixelSize: units.gu(2)
92 text: {
93 text: {
93− if (dragHandle !== undefined)
94+ if (dragHandle !== undefined) {
94− "Velocity: " + (dragHandle.edgeDragEvaluator.velocity * 1000)
95+ "Velocity: " + (dragHandle.edgeDragEvaluator.velocity * 1000);
95− else
96+ } else {
96− "Velocity: -"
97+ "Velocity: -";
98+ }
97 }
99 }
98 }
100 }
99 Text {
101 Text {
100 anchors.top: velocityText.bottom
102 anchors.top: velocityText.bottom
101 font.pixelSize: units.gu(2)
103 font.pixelSize: units.gu(2)
102 text: {
104 text: {
103− if (dragHandle !== undefined)
105+ if (dragHandle !== undefined) {
104− "Minimum velocity: " + (dragHandle.edgeDragEvaluator.minVelocity * 1000)
106+ "Minimum velocity: " + (dragHandle.edgeDragEvaluator.minVelocity * 1000);
105− else
107+ } else {
106− "Minimum velocity: -"
108+ "Minimum velocity: -";
109+ }
107 }
110 }
108 }
111 }
109 }
112 }
tests/qmltests/Components/tst_DragHandle/HorizontalShowable.qml+2−2
@@ -47,7 +47,7 @@ Showable {
47
47
48 onStatusChanged: {
48 onStatusChanged: {
49 if (status === DirectionalDragArea.Recognized)
49 if (status === DirectionalDragArea.Recognized)
50− dragHandleRecognizedGesture(leftwardsDragHandle)
50+ dragHandleRecognizedGesture(leftwardsDragHandle);
51 }
51 }
52
52
53 Rectangle { color: "red"; anchors.fill: parent }
53 Rectangle { color: "red"; anchors.fill: parent }
@@ -66,7 +66,7 @@ Showable {
66
66
67 onStatusChanged: {
67 onStatusChanged: {
68 if (status === DirectionalDragArea.Recognized)
68 if (status === DirectionalDragArea.Recognized)
69− dragHandleRecognizedGesture(rightwardsDragHandle)
69+ dragHandleRecognizedGesture(rightwardsDragHandle);
70 }
70 }
71
71
72 Rectangle { color: "green"; anchors.fill: parent }
72 Rectangle { color: "green"; anchors.fill: parent }
tests/qmltests/Components/tst_DragHandle/VerticalShowable.qml+2−2
@@ -47,7 +47,7 @@ Showable {
47
47
48 onStatusChanged: {
48 onStatusChanged: {
49 if (status === DirectionalDragArea.Recognized)
49 if (status === DirectionalDragArea.Recognized)
50− dragHandleRecognizedGesture(upwardsDragHandle)
50+ dragHandleRecognizedGesture(upwardsDragHandle);
51 }
51 }
52
52
53 Rectangle { color: "red"; anchors.fill: parent }
53 Rectangle { color: "red"; anchors.fill: parent }
@@ -66,7 +66,7 @@ Showable {
66
66
67 onStatusChanged: {
67 onStatusChanged: {
68 if (status === DirectionalDragArea.Recognized)
68 if (status === DirectionalDragArea.Recognized)
69− dragHandleRecognizedGesture(downwardsDragHandle)
69+ dragHandleRecognizedGesture(downwardsDragHandle);
70 }
70 }
71
71
72 Rectangle { color: "green"; anchors.fill: parent }
72 Rectangle { color: "green"; anchors.fill: parent }