Merge lp:~verzegnassi-stefano/quick-memo/fix-bottom-edge into lp:quick-memo/trunk

Proposed by Stefano Verzegnassi
Status: Merged
Approved by: Stefano Verzegnassi
Approved revision: 49
Merged at revision: 49
Proposed branch: lp:~verzegnassi-stefano/quick-memo/fix-bottom-edge
Merge into: lp:quick-memo/trunk
Diff against target: 431 lines (+163/-148)
1 file modified
app/components/PageWithBottomEdge.qml (+163/-148)
To merge this branch: bzr merge lp:~verzegnassi-stefano/quick-memo/fix-bottom-edge
Reviewer Review Type Date Requested Status
Stefano Verzegnassi Pending
Review via email: mp+238887@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app/components/PageWithBottomEdge.qml'
2--- app/components/PageWithBottomEdge.qml 2014-10-01 18:00:58 +0000
3+++ app/components/PageWithBottomEdge.qml 2014-10-20 14:09:21 +0000
4@@ -62,7 +62,7 @@
5
6 */
7
8-import QtQuick 2.0
9+import QtQuick 2.2
10 import Ubuntu.Components 1.1
11
12 Page {
13@@ -71,15 +71,15 @@
14 property alias bottomEdgePageComponent: edgeLoader.sourceComponent
15 property alias bottomEdgePageSource: edgeLoader.source
16 property alias bottomEdgeTitle: tipLabel.text
17- property alias bottomEdgeEnabled: bottomEdge.visible
18+ property bool bottomEdgeEnabled: true
19 property int bottomEdgeExpandThreshold: page.height * 0.2
20 property int bottomEdgeExposedArea: bottomEdge.state !== "expanded" ? (page.height - bottomEdge.y - bottomEdge.tipHeight) : _areaWhenExpanded
21 property bool reloadBottomEdgePage: true
22 property alias bottomEdgePageStartY: bottomEdge.pageStartY
23
24 readonly property alias bottomEdgePage: edgeLoader.item
25- readonly property bool isReady: (tip.opacity === 0.0)
26- readonly property bool isCollapsed: (tip.opacity === 1.0)
27+ readonly property bool isReady: ((bottomEdge.y === 0) && bottomEdgePageLoaded && edgeLoader.item.active)
28+ readonly property bool isCollapsed: (bottomEdge.y === page.height)
29 readonly property bool bottomEdgePageLoaded: (edgeLoader.status == Loader.Ready)
30
31 property bool _showEdgePageWhenReady: false
32@@ -143,13 +143,123 @@
33 z: 1
34 }
35
36- Timer {
37- id: hideIndicator
38-
39- interval: 3000
40- running: true
41- repeat: false
42- onTriggered: tipContainer.y = -units.gu(1)
43+ UbuntuShape {
44+ id: tip
45+ objectName: "bottomEdgeTip"
46+
47+ property bool hidden: (activeFocus === false) || ((bottomEdge.y - units.gu(1)) < tip.y)
48+
49+ enabled: mouseArea.enabled
50+ visible: page.bottomEdgeEnabled
51+ anchors {
52+ bottom: parent.bottom
53+ horizontalCenter: bottomEdge.horizontalCenter
54+ bottomMargin: hidden ? - height + units.gu(1) : -units.gu(1)
55+ Behavior on bottomMargin {
56+ SequentialAnimation {
57+ // wait some msecs in case of the focus change again, to avoid flickering
58+ PauseAnimation {
59+ duration: 300
60+ }
61+ UbuntuNumberAnimation {
62+ duration: UbuntuAnimation.SnapDuration
63+ }
64+ }
65+ }
66+ }
67+
68+ z: 1
69+ width: tipLabel.paintedWidth + units.gu(6)
70+ height: bottomEdge.tipHeight + units.gu(1)
71+ color: Theme.palette.normal.overlay
72+ Label {
73+ id: tipLabel
74+
75+ anchors {
76+ top: parent.top
77+ left: parent.left
78+ right: parent.right
79+ }
80+ height: bottomEdge.tipHeight
81+ verticalAlignment: Text.AlignVCenter
82+ horizontalAlignment: Text.AlignHCenter
83+ opacity: tip.hidden ? 0.0 : 1.0
84+ Behavior on opacity {
85+ UbuntuNumberAnimation {
86+ duration: UbuntuAnimation.SnapDuration
87+ }
88+ }
89+ }
90+ }
91+
92+ Rectangle {
93+ id: shadow
94+
95+ anchors {
96+ left: parent.left
97+ right: parent.right
98+ bottom: parent.bottom
99+ }
100+ height: units.gu(1)
101+ z: 1
102+ opacity: 0.0
103+ gradient: Gradient {
104+ GradientStop { position: 0.0; color: "transparent" }
105+ GradientStop { position: 1.0; color: Qt.rgba(0, 0, 0, 0.2) }
106+ }
107+ }
108+
109+ MouseArea {
110+ id: mouseArea
111+
112+ property real previousY: -1
113+ property string dragDirection: "None"
114+
115+ preventStealing: true
116+ drag {
117+ axis: Drag.YAxis
118+ target: bottomEdge
119+ minimumY: bottomEdge.pageStartY
120+ maximumY: page.height
121+ }
122+ enabled: edgeLoader.status == Loader.Ready
123+ visible: page.bottomEdgeEnabled
124+
125+ anchors {
126+ left: parent.left
127+ right: parent.right
128+ bottom: parent.bottom
129+
130+ }
131+ height: bottomEdge.tipHeight
132+ z: 1
133+
134+ onReleased: {
135+ page.bottomEdgeReleased()
136+ if ((dragDirection === "BottomToTop") &&
137+ bottomEdge.y < (page.height - bottomEdgeExpandThreshold - bottomEdge.tipHeight)) {
138+ bottomEdge.state = "expanded"
139+ } else {
140+ bottomEdge.state = "collapsed"
141+ }
142+ previousY = -1
143+ dragDirection = "None"
144+ }
145+
146+ onPressed: {
147+ previousY = mouse.y
148+ tip.forceActiveFocus()
149+ }
150+
151+ onMouseYChanged: {
152+ var yOffset = previousY - mouseY
153+ // skip if was a small move
154+ if (Math.abs(yOffset) <= units.gu(2)) {
155+ return
156+ }
157+ previousY = mouseY
158+ dragDirection = yOffset > 0 ? "BottomToTop" : "TopToBottom"
159+ }
160 }
161
162 Rectangle {
163@@ -162,97 +272,14 @@
164
165 z: 1
166 color: Theme.palette.normal.background
167- parent: page
168+ clip: true
169 anchors {
170 left: parent.left
171 right: parent.right
172 }
173 height: page.height
174 y: height
175-
176- Rectangle {
177- id: shadow
178-
179- anchors {
180- left: parent.left
181- right: parent.right
182- }
183- height: units.gu(1)
184- y: -height
185- opacity: 0.0
186- gradient: Gradient {
187- GradientStop { position: 0.0; color: "transparent" }
188- GradientStop { position: 1.0; color: Qt.rgba(0, 0, 0, 0.2) }
189- }
190- }
191-
192- Item {
193- id: tipContainer
194- objectName: "bottomEdgeTip"
195-
196- width: childrenRect.width
197- height: bottomEdge.tipHeight
198- clip: true
199- y: -bottomEdge.tipHeight
200- anchors.horizontalCenter: parent.horizontalCenter
201- Behavior on y {
202- UbuntuNumberAnimation {}
203- }
204-
205- UbuntuShape {
206- id: tip
207-
208- width: tipLabel.paintedWidth + units.gu(6)
209- height: bottomEdge.tipHeight + units.gu(1)
210- color: Theme.palette.normal.overlay
211- Label {
212- id: tipLabel
213-
214- anchors {
215- top: parent.top
216- left: parent.left
217- right: parent.right
218- }
219-
220- fontSize: "xx-small"
221- height: bottomEdge.tipHeight
222- verticalAlignment: Text.AlignVCenter
223- horizontalAlignment: Text.AlignHCenter
224- }
225- }
226- }
227-
228- MouseArea {
229- preventStealing: true
230- drag.axis: Drag.YAxis
231- drag.target: bottomEdge
232- drag.minimumY: bottomEdge.pageStartY
233- drag.maximumY: page.height
234-
235- anchors {
236- left: parent.left
237- right: parent.right
238- }
239- height: bottomEdge.tipHeight
240- y: -height
241-
242- onReleased: {
243- page.bottomEdgeReleased()
244- if (bottomEdge.y < (page.height - bottomEdgeExpandThreshold - bottomEdge.tipHeight)) {
245- bottomEdge.state = "expanded"
246- } else {
247- bottomEdge.state = "collapsed"
248- bottomEdge.y = bottomEdge.height
249- }
250- }
251-
252- onPressed: bottomEdge.state = "floating"
253- }
254-
255- Behavior on y {
256- UbuntuNumberAnimation {}
257- }
258-
259+ visible: !page.isCollapsed
260 state: "collapsed"
261 states: [
262 State {
263@@ -261,18 +288,6 @@
264 target: bottomEdge
265 y: bottomEdge.height
266 }
267- PropertyChanges {
268- target: tip
269- opacity: 1.0
270- }
271- PropertyChanges {
272- target: tipContainer
273- y: -bottomEdge.tipHeight
274- }
275- PropertyChanges {
276- target: hideIndicator
277- running: true
278- }
279 },
280 State {
281 name: "expanded"
282@@ -280,33 +295,14 @@
283 target: bottomEdge
284 y: bottomEdge.pageStartY
285 }
286- PropertyChanges {
287- target: tip
288- opacity: 0.0
289- }
290- PropertyChanges {
291- target: tipContainer
292- y: -bottomEdge.tipHeight
293- }
294- PropertyChanges {
295- target: hideIndicator
296- running: false
297- }
298 },
299 State {
300 name: "floating"
301+ when: mouseArea.drag.active
302 PropertyChanges {
303 target: shadow
304 opacity: 1.0
305 }
306- PropertyChanges {
307- target: hideIndicator
308- running: false
309- }
310- PropertyChanges {
311- target: tipContainer
312- y: -bottomEdge.tipHeight
313- }
314 }
315 ]
316
317@@ -314,10 +310,27 @@
318 Transition {
319 to: "expanded"
320 SequentialAnimation {
321- UbuntuNumberAnimation {
322- targets: [bottomEdge,tip]
323- properties: "y,opacity"
324- duration: UbuntuAnimation.SlowDuration
325+ alwaysRunToEnd: true
326+
327+ SmoothedAnimation {
328+ target: bottomEdge
329+ property: "y"
330+ duration: UbuntuAnimation.FastDuration
331+ easing.type: Easing.Linear
332+ }
333+ SmoothedAnimation {
334+ target: edgeLoader
335+ property: "anchors.topMargin"
336+ to: - units.gu(4)
337+ duration: UbuntuAnimation.FastDuration
338+ easing.type: Easing.Linear
339+ }
340+ SmoothedAnimation {
341+ target: edgeLoader
342+ property: "anchors.topMargin"
343+ to: 0
344+ duration: UbuntuAnimation.FastDuration
345+ easing: UbuntuAnimation.StandardEasing
346 }
347 ScriptAction {
348 script: page._pushPage()
349@@ -328,16 +341,19 @@
350 from: "expanded"
351 to: "collapsed"
352 SequentialAnimation {
353+ alwaysRunToEnd: true
354+
355 ScriptAction {
356 script: {
357+ Qt.inputMethod.hide()
358 edgeLoader.item.parent = edgeLoader
359 edgeLoader.item.anchors.fill = edgeLoader
360 edgeLoader.item.active = false
361 }
362 }
363- UbuntuNumberAnimation {
364- targets: [bottomEdge,tip]
365- properties: "y,opacity"
366+ SmoothedAnimation {
367+ target: bottomEdge
368+ property: "y"
369 duration: UbuntuAnimation.SlowDuration
370 }
371 ScriptAction {
372@@ -345,15 +361,15 @@
373 // destroy current bottom page
374 if (page.reloadBottomEdgePage) {
375 edgeLoader.active = false
376+ // tip will receive focus on page active true
377+ } else {
378+ tip.forceActiveFocus()
379 }
380
381 // notify
382 page.bottomEdgeDismissed()
383
384- // load a new bottom page in memory
385 edgeLoader.active = true
386-
387- hideIndicator.restart()
388 }
389 }
390 }
391@@ -361,9 +377,10 @@
392 Transition {
393 from: "floating"
394 to: "collapsed"
395- UbuntuNumberAnimation {
396- targets: [bottomEdge,tip]
397- properties: "y,opacity"
398+ SmoothedAnimation {
399+ target: bottomEdge
400+ property: "y"
401+ duration: UbuntuAnimation.FastDuration
402 }
403 }
404 ]
405@@ -371,21 +388,19 @@
406 Loader {
407 id: edgeLoader
408
409- z: 1
410- active: true
411 asynchronous: true
412 anchors.fill: parent
413-
414 //WORKAROUND: The SDK move the page contents down to allocate space for the header we need to avoid that during the page dragging
415 Binding {
416- target: edgeLoader
417+ target: edgeLoader.status === Loader.Ready ? edgeLoader : null
418 property: "anchors.topMargin"
419- value: edgeLoader.item && edgeLoader.item.flickable ? edgeLoader.item.flickable.contentY : 0
420- when: (edgeLoader.status === Loader.Ready && !page.isReady)
421+ value: edgeLoader.item && edgeLoader.item.flickable ? edgeLoader.item.flickable.contentY : 0
422+ when: !page.isReady
423 }
424
425 onLoaded: {
426- if (page.isReady && edgeLoader.item.active != true) {
427+ tip.forceActiveFocus()
428+ if (page.isReady && edgeLoader.item.active !== true) {
429 page._pushPage()
430 }
431 }

Subscribers

People subscribed via source and target branches

to all changes: