Merge lp:~rpadovani/ubuntu-calculator-app/1267820 into lp:~ubuntu-calculator-dev/ubuntu-calculator-app/old_trunk
- 1267820
- Merge into old_trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Gustavo Pichorim Boiko | ||||
Approved revision: | 220 | ||||
Merged at revision: | 208 | ||||
Proposed branch: | lp:~rpadovani/ubuntu-calculator-app/1267820 | ||||
Merge into: | lp:~ubuntu-calculator-dev/ubuntu-calculator-app/old_trunk | ||||
Diff against target: |
515 lines (+149/-95) 5 files modified
Simple/CalcKeyboard.qml (+36/-1) Simple/CalcLabel.qml (+1/-3) Simple/KeyboardButton.qml (+8/-2) Simple/Screen.qml (+0/-1) Simple/SimplePage.qml (+104/-88) |
||||
To merge this branch: | bzr merge lp:~rpadovani/ubuntu-calculator-app/1267820 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Gustavo Pichorim Boiko (community) | Approve | ||
Ubuntu Phone Apps Jenkins Bot | continuous-integration | Approve | |
Review via email: mp+201313@code.launchpad.net |
Commit message
Fixed #1267820
Description of the change
Changed keyboard shortcut. Now if a label is selected:
- enter ends editing
- esc ends editing and restores previous value
If no label is selected:
- enter do the calc
- ctrl + enter tears off
- esc scrolls back
- 208. By Riccardo Padovani
-
Added CTRL+ENTER shortcut
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
Alan Pope πΊπ§π± π¦ (popey) wrote : | # |
Tested and found numeric keys work as do + and -, but * / = . (multiply, divide, equals, point) do not. I would expect we would support all of those too.
I also can't move from one field to another when entering labels, which we should probably assign to "tab"?
- 209. By Riccardo Padovani
-
Added supporto for * / =
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:209
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 210. By Riccardo Padovani
-
Restart Jenkins test
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:210
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:210
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Alan Pope πΊπ§π± π¦ (popey) wrote : | # |
Escape key seems not to function.
- 211. By Riccardo Padovani
-
Added support for Escape key. Added a check to result var to avoid errors
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:211
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 212. By Riccardo Padovani
-
Fixed clear() function
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:212
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Alan Pope πΊπ§π± π¦ (popey) wrote : | # |
CTRL+Enter still seems a bit glitchy.
I typed in a calculation, pressed "enter" to finish it, and then "ctrl+enter" to tear off.
- 213. By Riccardo Padovani
-
Updated listView behavior to avoid keyboard scroll
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:213
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 214. By Riccardo Padovani
-
Added two codes for delete
- 215. By Riccardo Padovani
-
Updated onMovementEnded to avoid crash
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:215
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Gustavo Pichorim Boiko (boiko) wrote : | # |
Can you please replace those hardcoded values by:
163 + if(event.key === 46){
--> Qt.Key_Period
167 + if (event.key === Qt.Key_Escape || event.key === 16777216 || event.key === 16777223 || event.key === 16777219 ) {
--> Qt.Key_Escape || Qt.Key_Delete || Qt.Key_Backspace
- 216. By Riccardo Padovani
-
Removed harcoded codes
- 217. By Riccardo Padovani
-
Added id of buttons in CalcKeyboard.qml
- 218. By Riccardo Padovani
-
Rewrited keyshortcut handler
- 219. By Riccardo Padovani
-
Added animations for keyboard shortcut
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:219
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 220. By Riccardo Padovani
-
Deleted hard-coded codes
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:220
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Gustavo Pichorim Boiko (boiko) wrote : | # |
Code looks good now and works as expected!
Preview Diff
1 | === modified file 'Simple/CalcKeyboard.qml' |
2 | --- Simple/CalcKeyboard.qml 2013-11-15 09:27:22 +0000 |
3 | +++ Simple/CalcKeyboard.qml 2014-01-23 20:12:51 +0000 |
4 | @@ -24,7 +24,23 @@ |
5 | height: grid.height+units.gu(4) |
6 | |
7 | property int calcGridUnit: width / 50 |
8 | - |
9 | + property variant keyboardButtons: {'0': zeroButton, |
10 | + '1': oneButton, |
11 | + '2': twoButton, |
12 | + '3': threeButton, |
13 | + '4': fourButton, |
14 | + '5': fiveButton, |
15 | + '6': sixButton, |
16 | + '7': sevenButton, |
17 | + '8': eightButton, |
18 | + '9': nineButton, |
19 | + '+': plusButton, |
20 | + '-': minusButton, |
21 | + '*': multiplyButton, |
22 | + '/': divideButton, |
23 | + '=': equalsButton, |
24 | + '.': pointButton, |
25 | + 'clear': clearButton} |
26 | |
27 | Text { |
28 | visible: formulaView.__wasAtYBegining && formulaView.__displaceDist > units.gu(2) |
29 | @@ -73,6 +89,7 @@ |
30 | |
31 | KeyboardButton { |
32 | objectName: "signButton" |
33 | + id: signButton |
34 | x: (calcGridUnit*11) |
35 | y: 0 |
36 | text: "+/-" |
37 | @@ -83,6 +100,7 @@ |
38 | |
39 | KeyboardButton { |
40 | objectName: "divideButton" |
41 | + id: divideButton |
42 | x: (calcGridUnit*11)*2 |
43 | y: 0 |
44 | text: "Γ·" |
45 | @@ -94,6 +112,7 @@ |
46 | |
47 | KeyboardButton { |
48 | objectName: "multiplyButton" |
49 | + id: multiplyButton |
50 | x: (calcGridUnit*11)*3 |
51 | y: 0 |
52 | text: "Γ" |
53 | @@ -105,6 +124,7 @@ |
54 | |
55 | KeyboardButton { |
56 | objectName: "sevenButton" |
57 | + id: sevenButton |
58 | x: 0 |
59 | y: (calcGridUnit*8) |
60 | text: Number(7).toLocaleString(Qt.locale(), "f", 0) |
61 | @@ -115,6 +135,7 @@ |
62 | |
63 | KeyboardButton { |
64 | objectName: "eightButton" |
65 | + id: eightButton |
66 | x: (calcGridUnit*11) |
67 | y: (calcGridUnit*8) |
68 | text: Number(8).toLocaleString(Qt.locale(), "f", 0) |
69 | @@ -125,6 +146,7 @@ |
70 | |
71 | KeyboardButton { |
72 | objectName: "nineButton" |
73 | + id: nineButton |
74 | x: (calcGridUnit*11)*2 |
75 | y: (calcGridUnit*8) |
76 | text: Number(9).toLocaleString(Qt.locale(), "f", 0) |
77 | @@ -135,6 +157,7 @@ |
78 | |
79 | KeyboardButton { |
80 | objectName: "minusButton" |
81 | + id: minusButton |
82 | x: (calcGridUnit*11)*3 |
83 | y: (calcGridUnit*8) |
84 | text: "β" |
85 | @@ -146,6 +169,7 @@ |
86 | |
87 | KeyboardButton { |
88 | objectName: "fourButton" |
89 | + id: fourButton |
90 | x: 0 |
91 | y: (calcGridUnit*8)*2 |
92 | text: Number(4).toLocaleString(Qt.locale(), "f", 0) |
93 | @@ -156,6 +180,7 @@ |
94 | |
95 | KeyboardButton { |
96 | objectName: "fiveButton" |
97 | + id: fiveButton |
98 | x: (calcGridUnit*11) |
99 | y: (calcGridUnit*8)*2 |
100 | text: Number(5).toLocaleString(Qt.locale(), "f", 0) |
101 | @@ -166,6 +191,7 @@ |
102 | |
103 | KeyboardButton { |
104 | objectName: "sixButton" |
105 | + id: sixButton |
106 | x: (calcGridUnit*11)*2 |
107 | y: (calcGridUnit*8)*2 |
108 | text: Number(6).toLocaleString(Qt.locale(), "f", 0) |
109 | @@ -176,6 +202,7 @@ |
110 | |
111 | KeyboardButton { |
112 | objectName: "plusButton" |
113 | + id: plusButton |
114 | x: (calcGridUnit*11)*3 |
115 | y: (calcGridUnit*8)*2 |
116 | text: "+" |
117 | @@ -187,6 +214,7 @@ |
118 | |
119 | KeyboardButton { |
120 | objectName: "oneButton" |
121 | + id: oneButton |
122 | x: 0 |
123 | y: (calcGridUnit*8)*3 |
124 | text: Number(1).toLocaleString(Qt.locale(), "f", 0) |
125 | @@ -197,6 +225,7 @@ |
126 | |
127 | KeyboardButton { |
128 | objectName: "twoButton" |
129 | + id: twoButton |
130 | x: (calcGridUnit*11) |
131 | y: (calcGridUnit*8)*3 |
132 | text: Number(2).toLocaleString(Qt.locale(), "f", 0) |
133 | @@ -207,6 +236,7 @@ |
134 | |
135 | KeyboardButton { |
136 | objectName: "threeButton" |
137 | + id: threeButton |
138 | x: (calcGridUnit*11)*2 |
139 | y: (calcGridUnit*8)*3 |
140 | text: Number(3).toLocaleString(Qt.locale(), "f", 0) |
141 | @@ -217,6 +247,7 @@ |
142 | |
143 | KeyboardButton { |
144 | objectName: "equalsButton" |
145 | + id: equalsButton |
146 | x: (calcGridUnit*11)*3 |
147 | y: (calcGridUnit*8)*3 |
148 | height: (calcGridUnit*14) |
149 | @@ -232,6 +263,7 @@ |
150 | |
151 | KeyboardButton { |
152 | objectName: "zeroButton" |
153 | + id: zeroButton |
154 | x: 0 |
155 | y: (calcGridUnit*8)*4 |
156 | width: (calcGridUnit*20) |
157 | @@ -243,6 +275,7 @@ |
158 | |
159 | KeyboardButton { |
160 | objectName: "pointButton" |
161 | + id: pointButton |
162 | x: (calcGridUnit*11)*2 |
163 | y: (calcGridUnit*8)*4 |
164 | text: "." |
165 | @@ -255,6 +288,8 @@ |
166 | } |
167 | } |
168 | |
169 | + Component.onCompleted: page.keyboardButtons = keyboardButtons |
170 | + |
171 | states: [ |
172 | State { |
173 | name: "calculationCompleted" |
174 | |
175 | === modified file 'Simple/CalcLabel.qml' |
176 | --- Simple/CalcLabel.qml 2013-09-13 20:46:03 +0000 |
177 | +++ Simple/CalcLabel.qml 2014-01-23 20:12:51 +0000 |
178 | @@ -64,9 +64,7 @@ |
179 | calcKeyboardVisible = false |
180 | } |
181 | else |
182 | - saveCalcLabel(index, labelText); |
183 | - |
184 | - |
185 | + labelText = saveCalcLabel(index, labelText); |
186 | } |
187 | |
188 | readOnly: labelReadOnly |
189 | |
190 | === modified file 'Simple/KeyboardButton.qml' |
191 | --- Simple/KeyboardButton.qml 2013-09-10 10:47:14 +0000 |
192 | +++ Simple/KeyboardButton.qml 2014-01-23 20:12:51 +0000 |
193 | @@ -33,13 +33,18 @@ |
194 | |
195 | signal clicked() |
196 | signal pressAndHold() |
197 | + signal released() |
198 | + |
199 | + onClicked: rectangle.color = pressedColor; |
200 | + onReleased: rectangle.color = buttonColor; |
201 | |
202 | Rectangle { |
203 | + id: rectangle |
204 | width: parent.width-2 |
205 | height: parent.height-2 |
206 | anchors.centerIn: parent |
207 | radius: (calcGridUnit*1) |
208 | - color: buttonMA.pressed ? pressedColor : buttonColor |
209 | + color: buttonColor |
210 | |
211 | Text { |
212 | id: buttonText |
213 | @@ -52,7 +57,8 @@ |
214 | MouseArea { |
215 | id: buttonMA |
216 | anchors.fill: parent |
217 | - onClicked: buttonRect.clicked() |
218 | + onPressed: buttonRect.clicked() |
219 | + onReleased: buttonRect.released() |
220 | onPressAndHold: buttonRect.pressAndHold(); |
221 | } |
222 | } |
223 | |
224 | === modified file 'Simple/Screen.qml' |
225 | --- Simple/Screen.qml 2013-09-24 21:06:21 +0000 |
226 | +++ Simple/Screen.qml 2014-01-23 20:12:51 +0000 |
227 | @@ -28,7 +28,6 @@ |
228 | |
229 | property var ops |
230 | property bool newCalculation: false |
231 | - property bool labelVisible: false |
232 | signal useAnswer(string answerToUse, string formulaData) |
233 | signal labelTextUpdated(int idx, string newText) |
234 | signal mainLabelUpdated(int idx, string newText) |
235 | |
236 | === modified file 'Simple/SimplePage.qml' |
237 | --- Simple/SimplePage.qml 2014-01-03 19:19:58 +0000 |
238 | +++ Simple/SimplePage.qml 2014-01-23 20:12:51 +0000 |
239 | @@ -22,10 +22,11 @@ |
240 | import "../formula.js" as F |
241 | |
242 | Page { |
243 | - |
244 | property var formula: new F.Formula() |
245 | property var screenFormula: [{_text:'', _operation: '', _number:''}] |
246 | property bool calcKeyboardVisible: true |
247 | + property bool labelVisible: false |
248 | + property bool saveLabel: true |
249 | /* |
250 | * hasToAddDot became true if dot is last pressed button. |
251 | * It is necessary only for +/- |
252 | @@ -41,6 +42,10 @@ |
253 | */ |
254 | property bool isFinished: true |
255 | |
256 | + property variant keyboardButtons: null |
257 | + |
258 | + id: page |
259 | + |
260 | function formulaPush(visual) { |
261 | var added = false; |
262 | try{ |
263 | @@ -104,8 +109,10 @@ |
264 | // We modify result here to have max precision in the calc, but to have a limited number of decimal displayed |
265 | // .replace is to avoid to write final 0 in simple calc, because toPrecision add 0 |
266 | // CALC.PRECISION is set in engine.js |
267 | - result = result.toPrecision(CALC.PRECISION).replace(/\.0+$/,"") |
268 | - screenFormula.push({_text:'', _operation: '=', _number: result.toString()}); |
269 | + if (result) { |
270 | + result = result.toPrecision(CALC.PRECISION).replace(/\.0+$/,""); |
271 | + screenFormula.push({_text:'', _operation: '=', _number: result.toString()}); |
272 | + } |
273 | formulaView.currentOperatorsChanged(); |
274 | } |
275 | |
276 | @@ -182,73 +189,78 @@ |
277 | clip: true |
278 | focus: true |
279 | |
280 | + /* We need to override default behavior: when user click on up or down key |
281 | + * screen has to go up or down of always the same size |
282 | + * By default with up and down QT changes the focus and scrolls only if |
283 | + * focused Item is not on screen |
284 | + */ |
285 | + Keys.onUpPressed: { |
286 | + if (!formulaView.atYBeginning) |
287 | + scrollWithKeyboard(-100); |
288 | + } |
289 | + Keys.onDownPressed: { |
290 | + if (!formulaView.atYEnd) |
291 | + scrollWithKeyboard(100); |
292 | + } |
293 | + |
294 | + function buttonClicked(buttonName) { |
295 | + keyboardButtons[buttonName].clicked(); |
296 | + } |
297 | + |
298 | + function buttonReleased(buttonName) { |
299 | + keyboardButtons[buttonName].released(); |
300 | + } |
301 | + |
302 | Keys.onPressed: { |
303 | - if(event.key === Qt.Key_0){ |
304 | - formulaPush(Number(0).toLocaleString(Qt.locale(), "f", 0)) |
305 | - } |
306 | - if(event.key === Qt.Key_1){ |
307 | - formulaPush(Number(1).toLocaleString(Qt.locale(), "f", 0)) |
308 | - } |
309 | - if(event.key === Qt.Key_2){ |
310 | - formulaPush(Number(2).toLocaleString(Qt.locale(), "f", 0)) |
311 | - } |
312 | - if(event.key === Qt.Key_3){ |
313 | - formulaPush(Number(3).toLocaleString(Qt.locale(), "f", 0)) |
314 | - } |
315 | - if(event.key === Qt.Key_4){ |
316 | - formulaPush(Number(4).toLocaleString(Qt.locale(), "f", 0)) |
317 | - } |
318 | - if(event.key === Qt.Key_5){ |
319 | - formulaPush(Number(5).toLocaleString(Qt.locale(), "f", 0)) |
320 | - } |
321 | - if(event.key === Qt.Key_6){ |
322 | - formulaPush(Number(6).toLocaleString(Qt.locale(), "f", 0)) |
323 | - } |
324 | - if(event.key === Qt.Key_7){ |
325 | - formulaPush(Number(7).toLocaleString(Qt.locale(), "f", 0)) |
326 | - } |
327 | - if(event.key === Qt.Key_8){ |
328 | - formulaPush(Number(8).toLocaleString(Qt.locale(), "f", 0)) |
329 | - } |
330 | - if(event.key === Qt.Key_9){ |
331 | - formulaPush(Number(9).toLocaleString(Qt.locale(), "f", 0)) |
332 | - } |
333 | - if(event.key === 46){ |
334 | - if (!hasToAddDot) { // To avoid multiple dots |
335 | - hasToAddDot = formulaPush("."); |
336 | + // No label focused |
337 | + if (calcKeyboardVisible) { |
338 | + if (event.key === Qt.Key_Escape || event.key === Qt.Key_Delete || event.key === Qt.Key_Backspace ) |
339 | + formulaView.atYEnd ? buttonClicked('clear') : formulaView.positionViewAtBeginning(); |
340 | + else if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return || event.key === Qt.Key_Equal) |
341 | + (event.modifiers & Qt.ControlModifier) ? tearedOff() : buttonClicked('='); |
342 | + else if ((!isNaN(event.text) || |
343 | + event.text === "+" || |
344 | + event.text === "-" || |
345 | + event.text === "*" || |
346 | + event.text === "/" || |
347 | + event.text === "." || |
348 | + event.text === "=") && |
349 | + event.text !== "") |
350 | + buttonClicked(event.text) |
351 | + |
352 | + event.accepted = true; |
353 | + } |
354 | + else { |
355 | + if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return || event.key === Qt.Key_Escape) { |
356 | + if (event.key === Qt.Key_Escape) |
357 | + saveLabel = false; |
358 | + labelVisible = false; |
359 | + calcKeyboardVisible = true; |
360 | + // Remove the cursor from the label |
361 | + storage.forceActiveFocus(); |
362 | } |
363 | - } |
364 | - if(event.key === Qt.Key_Escape){ |
365 | - clear(); |
366 | - hasToAddDot = false; |
367 | - } |
368 | - if(event.key === Qt.Key_Plus){ |
369 | - formulaPush("+") |
370 | - hasToAddDot = false; |
371 | - } |
372 | - if(event.key === Qt.Key_Minus){ |
373 | - formulaPush("-") |
374 | - hasToAddDot = false; |
375 | - } |
376 | - if(event.key === Qt.Key_plusminus){ |
377 | - changeSign() |
378 | - } |
379 | - if(event.key === Qt.Key_multiply){ |
380 | - formulaPush("*") |
381 | - hasToAddDot = false; |
382 | - } |
383 | - if(event.key === Qt.Key_division){ |
384 | - formulaPush("/") |
385 | - hasToAddDot = false; |
386 | - } |
387 | - if(event.key === Qt.Key_Enter){ |
388 | - calculate(); |
389 | - hasToAddDot = false; |
390 | - } |
391 | - if(event.key === 16777220){ |
392 | - calculate(); |
393 | - hasToAddDot = false; |
394 | - } |
395 | + event.accepted = true; |
396 | + } |
397 | + } |
398 | + |
399 | + Keys.onReleased: { |
400 | + // No label focused |
401 | + if (calcKeyboardVisible) { |
402 | + if (event.key === Qt.Key_Escape || event.key === Qt.Key_Delete || event.key === Qt.Key_Backspace ) |
403 | + buttonReleased('clear'); |
404 | + else if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return || event.key === Qt.Key_Equal) |
405 | + buttonReleased('='); |
406 | + else if ((!isNaN(event.text) || |
407 | + event.text === "+" || |
408 | + event.text === "-" || |
409 | + event.text === "*" || |
410 | + event.text === "/" || |
411 | + event.text === "." || |
412 | + event.text === "=") && |
413 | + event.text !== "") |
414 | + buttonReleased(event.text) |
415 | + } |
416 | + event.accepted = true; |
417 | } |
418 | |
419 | /* |
420 | @@ -316,6 +328,8 @@ |
421 | positionViewAtBeginning(); |
422 | } |
423 | |
424 | + currentIndex: -1; |
425 | + |
426 | model: Memory{ |
427 | id: memory |
428 | Component.onCompleted: { |
429 | @@ -350,23 +364,35 @@ |
430 | } |
431 | |
432 | function saveMainLabel(newText) { |
433 | - if (index !== 0) { |
434 | + if (index !== 0 && saveLabel) { |
435 | var calculation = []; |
436 | var calc = storage.getCalculation(memory.get(index).dbId); |
437 | calc.mainLabel = newText |
438 | calculation.push({"calc": calc}); |
439 | storage.updateCalculation(calculation, memory.get(index).dbId); |
440 | } |
441 | + else { |
442 | + saveLabel = true; |
443 | + var oldLabel = storage.getCalculation(memory.get(index).dbId); |
444 | + memory.get(index).mainLabel = oldLabel.mainLabel; |
445 | + } |
446 | } |
447 | |
448 | function saveCalcLabel(idx, newText) { |
449 | - if (index !== 0) { |
450 | + if (index !== 0 && saveLabel) { |
451 | var calculation = []; |
452 | var calc = storage.getCalculation(memory.get(index).dbId); |
453 | calc.operators[idx]._text = newText; |
454 | calculation.push({"calc": calc}); |
455 | storage.updateCalculation(calculation, memory.get(index).dbId); |
456 | } |
457 | + else { |
458 | + saveLabel = true |
459 | + var oldLabel = storage.getCalculation(memory.get(index).dbId); |
460 | + newText = oldLabel.operators[idx]._text; |
461 | + } |
462 | + |
463 | + return newText; |
464 | } |
465 | |
466 | onRemoveItem: { |
467 | @@ -386,20 +412,6 @@ |
468 | formulaView.forceActiveFocus(); |
469 | } |
470 | |
471 | - /* We need to override default behavior: when user click on up or down key |
472 | - * screen has to go up or down of always the same size |
473 | - * By default with up and down QT changes the focus and scrolls only if |
474 | - * focused Item is not on screen |
475 | - */ |
476 | - Keys.onUpPressed: { |
477 | - if (!formulaView.atYBeginning) |
478 | - scrollWithKeyboard(-100); |
479 | - } |
480 | - Keys.onDownPressed: { |
481 | - if (!formulaView.atYEnd) |
482 | - scrollWithKeyboard(100); |
483 | - } |
484 | - |
485 | onMovementStarted: { |
486 | __wasAtYBegining = atYEnd |
487 | __initialContentY = contentY |
488 | @@ -415,7 +427,14 @@ |
489 | } |
490 | } |
491 | onMovementEnded: { |
492 | - if (__toBeRefresh && isFinished) { |
493 | + if (__toBeRefresh) { |
494 | + tearedOff(); |
495 | + __toBeRefresh = false |
496 | + } |
497 | + } |
498 | + |
499 | + function tearedOff(){ |
500 | + if (isFinished) { |
501 | isFinished = false; |
502 | |
503 | if (formulaView.addCurrentToMemory()) { |
504 | @@ -440,11 +459,8 @@ |
505 | |
506 | storage.saveCalculations(calculations); |
507 | } |
508 | - |
509 | clear(); |
510 | - __toBeRefresh = false |
511 | hasToAddDot=false; |
512 | - |
513 | isFinished = true; |
514 | } |
515 | } |
PASSED: Continuous integration, rev:208 91.189. 93.70:8080/ job/ubuntu- calculator- app-ci/ 143/ 91.189. 93.70:8080/ job/generic- mediumtests- trusty/ 673 91.189. 93.70:8080/ job/ubuntu- calculator- app-raring- amd64-ci/ 142 91.189. 93.70:8080/ job/ubuntu- calculator- app-saucy- amd64-ci/ 142 91.189. 93.70:8080/ job/ubuntu- calculator- app-trusty- amd64-ci/ 14
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild: 91.189. 93.70:8080/ job/ubuntu- calculator- app-ci/ 143/rebuild
http://