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 | 24 | height: grid.height+units.gu(4) | 24 | height: grid.height+units.gu(4) |
6 | 25 | 25 | ||
7 | 26 | property int calcGridUnit: width / 50 | 26 | property int calcGridUnit: width / 50 |
9 | 27 | 27 | property variant keyboardButtons: {'0': zeroButton, | |
10 | 28 | '1': oneButton, | ||
11 | 29 | '2': twoButton, | ||
12 | 30 | '3': threeButton, | ||
13 | 31 | '4': fourButton, | ||
14 | 32 | '5': fiveButton, | ||
15 | 33 | '6': sixButton, | ||
16 | 34 | '7': sevenButton, | ||
17 | 35 | '8': eightButton, | ||
18 | 36 | '9': nineButton, | ||
19 | 37 | '+': plusButton, | ||
20 | 38 | '-': minusButton, | ||
21 | 39 | '*': multiplyButton, | ||
22 | 40 | '/': divideButton, | ||
23 | 41 | '=': equalsButton, | ||
24 | 42 | '.': pointButton, | ||
25 | 43 | 'clear': clearButton} | ||
26 | 28 | 44 | ||
27 | 29 | Text { | 45 | Text { |
28 | 30 | visible: formulaView.__wasAtYBegining && formulaView.__displaceDist > units.gu(2) | 46 | visible: formulaView.__wasAtYBegining && formulaView.__displaceDist > units.gu(2) |
29 | @@ -73,6 +89,7 @@ | |||
30 | 73 | 89 | ||
31 | 74 | KeyboardButton { | 90 | KeyboardButton { |
32 | 75 | objectName: "signButton" | 91 | objectName: "signButton" |
33 | 92 | id: signButton | ||
34 | 76 | x: (calcGridUnit*11) | 93 | x: (calcGridUnit*11) |
35 | 77 | y: 0 | 94 | y: 0 |
36 | 78 | text: "+/-" | 95 | text: "+/-" |
37 | @@ -83,6 +100,7 @@ | |||
38 | 83 | 100 | ||
39 | 84 | KeyboardButton { | 101 | KeyboardButton { |
40 | 85 | objectName: "divideButton" | 102 | objectName: "divideButton" |
41 | 103 | id: divideButton | ||
42 | 86 | x: (calcGridUnit*11)*2 | 104 | x: (calcGridUnit*11)*2 |
43 | 87 | y: 0 | 105 | y: 0 |
44 | 88 | text: "Γ·" | 106 | text: "Γ·" |
45 | @@ -94,6 +112,7 @@ | |||
46 | 94 | 112 | ||
47 | 95 | KeyboardButton { | 113 | KeyboardButton { |
48 | 96 | objectName: "multiplyButton" | 114 | objectName: "multiplyButton" |
49 | 115 | id: multiplyButton | ||
50 | 97 | x: (calcGridUnit*11)*3 | 116 | x: (calcGridUnit*11)*3 |
51 | 98 | y: 0 | 117 | y: 0 |
52 | 99 | text: "Γ" | 118 | text: "Γ" |
53 | @@ -105,6 +124,7 @@ | |||
54 | 105 | 124 | ||
55 | 106 | KeyboardButton { | 125 | KeyboardButton { |
56 | 107 | objectName: "sevenButton" | 126 | objectName: "sevenButton" |
57 | 127 | id: sevenButton | ||
58 | 108 | x: 0 | 128 | x: 0 |
59 | 109 | y: (calcGridUnit*8) | 129 | y: (calcGridUnit*8) |
60 | 110 | text: Number(7).toLocaleString(Qt.locale(), "f", 0) | 130 | text: Number(7).toLocaleString(Qt.locale(), "f", 0) |
61 | @@ -115,6 +135,7 @@ | |||
62 | 115 | 135 | ||
63 | 116 | KeyboardButton { | 136 | KeyboardButton { |
64 | 117 | objectName: "eightButton" | 137 | objectName: "eightButton" |
65 | 138 | id: eightButton | ||
66 | 118 | x: (calcGridUnit*11) | 139 | x: (calcGridUnit*11) |
67 | 119 | y: (calcGridUnit*8) | 140 | y: (calcGridUnit*8) |
68 | 120 | text: Number(8).toLocaleString(Qt.locale(), "f", 0) | 141 | text: Number(8).toLocaleString(Qt.locale(), "f", 0) |
69 | @@ -125,6 +146,7 @@ | |||
70 | 125 | 146 | ||
71 | 126 | KeyboardButton { | 147 | KeyboardButton { |
72 | 127 | objectName: "nineButton" | 148 | objectName: "nineButton" |
73 | 149 | id: nineButton | ||
74 | 128 | x: (calcGridUnit*11)*2 | 150 | x: (calcGridUnit*11)*2 |
75 | 129 | y: (calcGridUnit*8) | 151 | y: (calcGridUnit*8) |
76 | 130 | text: Number(9).toLocaleString(Qt.locale(), "f", 0) | 152 | text: Number(9).toLocaleString(Qt.locale(), "f", 0) |
77 | @@ -135,6 +157,7 @@ | |||
78 | 135 | 157 | ||
79 | 136 | KeyboardButton { | 158 | KeyboardButton { |
80 | 137 | objectName: "minusButton" | 159 | objectName: "minusButton" |
81 | 160 | id: minusButton | ||
82 | 138 | x: (calcGridUnit*11)*3 | 161 | x: (calcGridUnit*11)*3 |
83 | 139 | y: (calcGridUnit*8) | 162 | y: (calcGridUnit*8) |
84 | 140 | text: "β" | 163 | text: "β" |
85 | @@ -146,6 +169,7 @@ | |||
86 | 146 | 169 | ||
87 | 147 | KeyboardButton { | 170 | KeyboardButton { |
88 | 148 | objectName: "fourButton" | 171 | objectName: "fourButton" |
89 | 172 | id: fourButton | ||
90 | 149 | x: 0 | 173 | x: 0 |
91 | 150 | y: (calcGridUnit*8)*2 | 174 | y: (calcGridUnit*8)*2 |
92 | 151 | text: Number(4).toLocaleString(Qt.locale(), "f", 0) | 175 | text: Number(4).toLocaleString(Qt.locale(), "f", 0) |
93 | @@ -156,6 +180,7 @@ | |||
94 | 156 | 180 | ||
95 | 157 | KeyboardButton { | 181 | KeyboardButton { |
96 | 158 | objectName: "fiveButton" | 182 | objectName: "fiveButton" |
97 | 183 | id: fiveButton | ||
98 | 159 | x: (calcGridUnit*11) | 184 | x: (calcGridUnit*11) |
99 | 160 | y: (calcGridUnit*8)*2 | 185 | y: (calcGridUnit*8)*2 |
100 | 161 | text: Number(5).toLocaleString(Qt.locale(), "f", 0) | 186 | text: Number(5).toLocaleString(Qt.locale(), "f", 0) |
101 | @@ -166,6 +191,7 @@ | |||
102 | 166 | 191 | ||
103 | 167 | KeyboardButton { | 192 | KeyboardButton { |
104 | 168 | objectName: "sixButton" | 193 | objectName: "sixButton" |
105 | 194 | id: sixButton | ||
106 | 169 | x: (calcGridUnit*11)*2 | 195 | x: (calcGridUnit*11)*2 |
107 | 170 | y: (calcGridUnit*8)*2 | 196 | y: (calcGridUnit*8)*2 |
108 | 171 | text: Number(6).toLocaleString(Qt.locale(), "f", 0) | 197 | text: Number(6).toLocaleString(Qt.locale(), "f", 0) |
109 | @@ -176,6 +202,7 @@ | |||
110 | 176 | 202 | ||
111 | 177 | KeyboardButton { | 203 | KeyboardButton { |
112 | 178 | objectName: "plusButton" | 204 | objectName: "plusButton" |
113 | 205 | id: plusButton | ||
114 | 179 | x: (calcGridUnit*11)*3 | 206 | x: (calcGridUnit*11)*3 |
115 | 180 | y: (calcGridUnit*8)*2 | 207 | y: (calcGridUnit*8)*2 |
116 | 181 | text: "+" | 208 | text: "+" |
117 | @@ -187,6 +214,7 @@ | |||
118 | 187 | 214 | ||
119 | 188 | KeyboardButton { | 215 | KeyboardButton { |
120 | 189 | objectName: "oneButton" | 216 | objectName: "oneButton" |
121 | 217 | id: oneButton | ||
122 | 190 | x: 0 | 218 | x: 0 |
123 | 191 | y: (calcGridUnit*8)*3 | 219 | y: (calcGridUnit*8)*3 |
124 | 192 | text: Number(1).toLocaleString(Qt.locale(), "f", 0) | 220 | text: Number(1).toLocaleString(Qt.locale(), "f", 0) |
125 | @@ -197,6 +225,7 @@ | |||
126 | 197 | 225 | ||
127 | 198 | KeyboardButton { | 226 | KeyboardButton { |
128 | 199 | objectName: "twoButton" | 227 | objectName: "twoButton" |
129 | 228 | id: twoButton | ||
130 | 200 | x: (calcGridUnit*11) | 229 | x: (calcGridUnit*11) |
131 | 201 | y: (calcGridUnit*8)*3 | 230 | y: (calcGridUnit*8)*3 |
132 | 202 | text: Number(2).toLocaleString(Qt.locale(), "f", 0) | 231 | text: Number(2).toLocaleString(Qt.locale(), "f", 0) |
133 | @@ -207,6 +236,7 @@ | |||
134 | 207 | 236 | ||
135 | 208 | KeyboardButton { | 237 | KeyboardButton { |
136 | 209 | objectName: "threeButton" | 238 | objectName: "threeButton" |
137 | 239 | id: threeButton | ||
138 | 210 | x: (calcGridUnit*11)*2 | 240 | x: (calcGridUnit*11)*2 |
139 | 211 | y: (calcGridUnit*8)*3 | 241 | y: (calcGridUnit*8)*3 |
140 | 212 | text: Number(3).toLocaleString(Qt.locale(), "f", 0) | 242 | text: Number(3).toLocaleString(Qt.locale(), "f", 0) |
141 | @@ -217,6 +247,7 @@ | |||
142 | 217 | 247 | ||
143 | 218 | KeyboardButton { | 248 | KeyboardButton { |
144 | 219 | objectName: "equalsButton" | 249 | objectName: "equalsButton" |
145 | 250 | id: equalsButton | ||
146 | 220 | x: (calcGridUnit*11)*3 | 251 | x: (calcGridUnit*11)*3 |
147 | 221 | y: (calcGridUnit*8)*3 | 252 | y: (calcGridUnit*8)*3 |
148 | 222 | height: (calcGridUnit*14) | 253 | height: (calcGridUnit*14) |
149 | @@ -232,6 +263,7 @@ | |||
150 | 232 | 263 | ||
151 | 233 | KeyboardButton { | 264 | KeyboardButton { |
152 | 234 | objectName: "zeroButton" | 265 | objectName: "zeroButton" |
153 | 266 | id: zeroButton | ||
154 | 235 | x: 0 | 267 | x: 0 |
155 | 236 | y: (calcGridUnit*8)*4 | 268 | y: (calcGridUnit*8)*4 |
156 | 237 | width: (calcGridUnit*20) | 269 | width: (calcGridUnit*20) |
157 | @@ -243,6 +275,7 @@ | |||
158 | 243 | 275 | ||
159 | 244 | KeyboardButton { | 276 | KeyboardButton { |
160 | 245 | objectName: "pointButton" | 277 | objectName: "pointButton" |
161 | 278 | id: pointButton | ||
162 | 246 | x: (calcGridUnit*11)*2 | 279 | x: (calcGridUnit*11)*2 |
163 | 247 | y: (calcGridUnit*8)*4 | 280 | y: (calcGridUnit*8)*4 |
164 | 248 | text: "." | 281 | text: "." |
165 | @@ -255,6 +288,8 @@ | |||
166 | 255 | } | 288 | } |
167 | 256 | } | 289 | } |
168 | 257 | 290 | ||
169 | 291 | Component.onCompleted: page.keyboardButtons = keyboardButtons | ||
170 | 292 | |||
171 | 258 | states: [ | 293 | states: [ |
172 | 259 | State { | 294 | State { |
173 | 260 | name: "calculationCompleted" | 295 | name: "calculationCompleted" |
174 | 261 | 296 | ||
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 | 64 | calcKeyboardVisible = false | 64 | calcKeyboardVisible = false |
180 | 65 | } | 65 | } |
181 | 66 | else | 66 | else |
185 | 67 | saveCalcLabel(index, labelText); | 67 | labelText = saveCalcLabel(index, labelText); |
183 | 68 | |||
184 | 69 | |||
186 | 70 | } | 68 | } |
187 | 71 | 69 | ||
188 | 72 | readOnly: labelReadOnly | 70 | readOnly: labelReadOnly |
189 | 73 | 71 | ||
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 | 33 | 33 | ||
195 | 34 | signal clicked() | 34 | signal clicked() |
196 | 35 | signal pressAndHold() | 35 | signal pressAndHold() |
197 | 36 | signal released() | ||
198 | 37 | |||
199 | 38 | onClicked: rectangle.color = pressedColor; | ||
200 | 39 | onReleased: rectangle.color = buttonColor; | ||
201 | 36 | 40 | ||
202 | 37 | Rectangle { | 41 | Rectangle { |
203 | 42 | id: rectangle | ||
204 | 38 | width: parent.width-2 | 43 | width: parent.width-2 |
205 | 39 | height: parent.height-2 | 44 | height: parent.height-2 |
206 | 40 | anchors.centerIn: parent | 45 | anchors.centerIn: parent |
207 | 41 | radius: (calcGridUnit*1) | 46 | radius: (calcGridUnit*1) |
209 | 42 | color: buttonMA.pressed ? pressedColor : buttonColor | 47 | color: buttonColor |
210 | 43 | 48 | ||
211 | 44 | Text { | 49 | Text { |
212 | 45 | id: buttonText | 50 | id: buttonText |
213 | @@ -52,7 +57,8 @@ | |||
214 | 52 | MouseArea { | 57 | MouseArea { |
215 | 53 | id: buttonMA | 58 | id: buttonMA |
216 | 54 | anchors.fill: parent | 59 | anchors.fill: parent |
218 | 55 | onClicked: buttonRect.clicked() | 60 | onPressed: buttonRect.clicked() |
219 | 61 | onReleased: buttonRect.released() | ||
220 | 56 | onPressAndHold: buttonRect.pressAndHold(); | 62 | onPressAndHold: buttonRect.pressAndHold(); |
221 | 57 | } | 63 | } |
222 | 58 | } | 64 | } |
223 | 59 | 65 | ||
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 | 28 | 28 | ||
229 | 29 | property var ops | 29 | property var ops |
230 | 30 | property bool newCalculation: false | 30 | property bool newCalculation: false |
231 | 31 | property bool labelVisible: false | ||
232 | 32 | signal useAnswer(string answerToUse, string formulaData) | 31 | signal useAnswer(string answerToUse, string formulaData) |
233 | 33 | signal labelTextUpdated(int idx, string newText) | 32 | signal labelTextUpdated(int idx, string newText) |
234 | 34 | signal mainLabelUpdated(int idx, string newText) | 33 | signal mainLabelUpdated(int idx, string newText) |
235 | 35 | 34 | ||
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 | 22 | import "../formula.js" as F | 22 | import "../formula.js" as F |
241 | 23 | 23 | ||
242 | 24 | Page { | 24 | Page { |
243 | 25 | |||
244 | 26 | property var formula: new F.Formula() | 25 | property var formula: new F.Formula() |
245 | 27 | property var screenFormula: [{_text:'', _operation: '', _number:''}] | 26 | property var screenFormula: [{_text:'', _operation: '', _number:''}] |
246 | 28 | property bool calcKeyboardVisible: true | 27 | property bool calcKeyboardVisible: true |
247 | 28 | property bool labelVisible: false | ||
248 | 29 | property bool saveLabel: true | ||
249 | 29 | /* | 30 | /* |
250 | 30 | * hasToAddDot became true if dot is last pressed button. | 31 | * hasToAddDot became true if dot is last pressed button. |
251 | 31 | * It is necessary only for +/- | 32 | * It is necessary only for +/- |
252 | @@ -41,6 +42,10 @@ | |||
253 | 41 | */ | 42 | */ |
254 | 42 | property bool isFinished: true | 43 | property bool isFinished: true |
255 | 43 | 44 | ||
256 | 45 | property variant keyboardButtons: null | ||
257 | 46 | |||
258 | 47 | id: page | ||
259 | 48 | |||
260 | 44 | function formulaPush(visual) { | 49 | function formulaPush(visual) { |
261 | 45 | var added = false; | 50 | var added = false; |
262 | 46 | try{ | 51 | try{ |
263 | @@ -104,8 +109,10 @@ | |||
264 | 104 | // We modify result here to have max precision in the calc, but to have a limited number of decimal displayed | 109 | // We modify result here to have max precision in the calc, but to have a limited number of decimal displayed |
265 | 105 | // .replace is to avoid to write final 0 in simple calc, because toPrecision add 0 | 110 | // .replace is to avoid to write final 0 in simple calc, because toPrecision add 0 |
266 | 106 | // CALC.PRECISION is set in engine.js | 111 | // CALC.PRECISION is set in engine.js |
269 | 107 | result = result.toPrecision(CALC.PRECISION).replace(/\.0+$/,"") | 112 | if (result) { |
270 | 108 | screenFormula.push({_text:'', _operation: '=', _number: result.toString()}); | 113 | result = result.toPrecision(CALC.PRECISION).replace(/\.0+$/,""); |
271 | 114 | screenFormula.push({_text:'', _operation: '=', _number: result.toString()}); | ||
272 | 115 | } | ||
273 | 109 | formulaView.currentOperatorsChanged(); | 116 | formulaView.currentOperatorsChanged(); |
274 | 110 | } | 117 | } |
275 | 111 | 118 | ||
276 | @@ -182,73 +189,78 @@ | |||
277 | 182 | clip: true | 189 | clip: true |
278 | 183 | focus: true | 190 | focus: true |
279 | 184 | 191 | ||
280 | 192 | /* We need to override default behavior: when user click on up or down key | ||
281 | 193 | * screen has to go up or down of always the same size | ||
282 | 194 | * By default with up and down QT changes the focus and scrolls only if | ||
283 | 195 | * focused Item is not on screen | ||
284 | 196 | */ | ||
285 | 197 | Keys.onUpPressed: { | ||
286 | 198 | if (!formulaView.atYBeginning) | ||
287 | 199 | scrollWithKeyboard(-100); | ||
288 | 200 | } | ||
289 | 201 | Keys.onDownPressed: { | ||
290 | 202 | if (!formulaView.atYEnd) | ||
291 | 203 | scrollWithKeyboard(100); | ||
292 | 204 | } | ||
293 | 205 | |||
294 | 206 | function buttonClicked(buttonName) { | ||
295 | 207 | keyboardButtons[buttonName].clicked(); | ||
296 | 208 | } | ||
297 | 209 | |||
298 | 210 | function buttonReleased(buttonName) { | ||
299 | 211 | keyboardButtons[buttonName].released(); | ||
300 | 212 | } | ||
301 | 213 | |||
302 | 185 | Keys.onPressed: { | 214 | Keys.onPressed: { |
336 | 186 | if(event.key === Qt.Key_0){ | 215 | // No label focused |
337 | 187 | formulaPush(Number(0).toLocaleString(Qt.locale(), "f", 0)) | 216 | if (calcKeyboardVisible) { |
338 | 188 | } | 217 | if (event.key === Qt.Key_Escape || event.key === Qt.Key_Delete || event.key === Qt.Key_Backspace ) |
339 | 189 | if(event.key === Qt.Key_1){ | 218 | formulaView.atYEnd ? buttonClicked('clear') : formulaView.positionViewAtBeginning(); |
340 | 190 | formulaPush(Number(1).toLocaleString(Qt.locale(), "f", 0)) | 219 | else if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return || event.key === Qt.Key_Equal) |
341 | 191 | } | 220 | (event.modifiers & Qt.ControlModifier) ? tearedOff() : buttonClicked('='); |
342 | 192 | if(event.key === Qt.Key_2){ | 221 | else if ((!isNaN(event.text) || |
343 | 193 | formulaPush(Number(2).toLocaleString(Qt.locale(), "f", 0)) | 222 | event.text === "+" || |
344 | 194 | } | 223 | event.text === "-" || |
345 | 195 | if(event.key === Qt.Key_3){ | 224 | event.text === "*" || |
346 | 196 | formulaPush(Number(3).toLocaleString(Qt.locale(), "f", 0)) | 225 | event.text === "/" || |
347 | 197 | } | 226 | event.text === "." || |
348 | 198 | if(event.key === Qt.Key_4){ | 227 | event.text === "=") && |
349 | 199 | formulaPush(Number(4).toLocaleString(Qt.locale(), "f", 0)) | 228 | event.text !== "") |
350 | 200 | } | 229 | buttonClicked(event.text) |
351 | 201 | if(event.key === Qt.Key_5){ | 230 | |
352 | 202 | formulaPush(Number(5).toLocaleString(Qt.locale(), "f", 0)) | 231 | event.accepted = true; |
353 | 203 | } | 232 | } |
354 | 204 | if(event.key === Qt.Key_6){ | 233 | else { |
355 | 205 | formulaPush(Number(6).toLocaleString(Qt.locale(), "f", 0)) | 234 | if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return || event.key === Qt.Key_Escape) { |
356 | 206 | } | 235 | if (event.key === Qt.Key_Escape) |
357 | 207 | if(event.key === Qt.Key_7){ | 236 | saveLabel = false; |
358 | 208 | formulaPush(Number(7).toLocaleString(Qt.locale(), "f", 0)) | 237 | labelVisible = false; |
359 | 209 | } | 238 | calcKeyboardVisible = true; |
360 | 210 | if(event.key === Qt.Key_8){ | 239 | // Remove the cursor from the label |
361 | 211 | formulaPush(Number(8).toLocaleString(Qt.locale(), "f", 0)) | 240 | storage.forceActiveFocus(); |
329 | 212 | } | ||
330 | 213 | if(event.key === Qt.Key_9){ | ||
331 | 214 | formulaPush(Number(9).toLocaleString(Qt.locale(), "f", 0)) | ||
332 | 215 | } | ||
333 | 216 | if(event.key === 46){ | ||
334 | 217 | if (!hasToAddDot) { // To avoid multiple dots | ||
335 | 218 | hasToAddDot = formulaPush("."); | ||
362 | 219 | } | 241 | } |
395 | 220 | } | 242 | event.accepted = true; |
396 | 221 | if(event.key === Qt.Key_Escape){ | 243 | } |
397 | 222 | clear(); | 244 | } |
398 | 223 | hasToAddDot = false; | 245 | |
399 | 224 | } | 246 | Keys.onReleased: { |
400 | 225 | if(event.key === Qt.Key_Plus){ | 247 | // No label focused |
401 | 226 | formulaPush("+") | 248 | if (calcKeyboardVisible) { |
402 | 227 | hasToAddDot = false; | 249 | if (event.key === Qt.Key_Escape || event.key === Qt.Key_Delete || event.key === Qt.Key_Backspace ) |
403 | 228 | } | 250 | buttonReleased('clear'); |
404 | 229 | if(event.key === Qt.Key_Minus){ | 251 | else if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return || event.key === Qt.Key_Equal) |
405 | 230 | formulaPush("-") | 252 | buttonReleased('='); |
406 | 231 | hasToAddDot = false; | 253 | else if ((!isNaN(event.text) || |
407 | 232 | } | 254 | event.text === "+" || |
408 | 233 | if(event.key === Qt.Key_plusminus){ | 255 | event.text === "-" || |
409 | 234 | changeSign() | 256 | event.text === "*" || |
410 | 235 | } | 257 | event.text === "/" || |
411 | 236 | if(event.key === Qt.Key_multiply){ | 258 | event.text === "." || |
412 | 237 | formulaPush("*") | 259 | event.text === "=") && |
413 | 238 | hasToAddDot = false; | 260 | event.text !== "") |
414 | 239 | } | 261 | buttonReleased(event.text) |
415 | 240 | if(event.key === Qt.Key_division){ | 262 | } |
416 | 241 | formulaPush("/") | 263 | event.accepted = true; |
385 | 242 | hasToAddDot = false; | ||
386 | 243 | } | ||
387 | 244 | if(event.key === Qt.Key_Enter){ | ||
388 | 245 | calculate(); | ||
389 | 246 | hasToAddDot = false; | ||
390 | 247 | } | ||
391 | 248 | if(event.key === 16777220){ | ||
392 | 249 | calculate(); | ||
393 | 250 | hasToAddDot = false; | ||
394 | 251 | } | ||
417 | 252 | } | 264 | } |
418 | 253 | 265 | ||
419 | 254 | /* | 266 | /* |
420 | @@ -316,6 +328,8 @@ | |||
421 | 316 | positionViewAtBeginning(); | 328 | positionViewAtBeginning(); |
422 | 317 | } | 329 | } |
423 | 318 | 330 | ||
424 | 331 | currentIndex: -1; | ||
425 | 332 | |||
426 | 319 | model: Memory{ | 333 | model: Memory{ |
427 | 320 | id: memory | 334 | id: memory |
428 | 321 | Component.onCompleted: { | 335 | Component.onCompleted: { |
429 | @@ -350,23 +364,35 @@ | |||
430 | 350 | } | 364 | } |
431 | 351 | 365 | ||
432 | 352 | function saveMainLabel(newText) { | 366 | function saveMainLabel(newText) { |
434 | 353 | if (index !== 0) { | 367 | if (index !== 0 && saveLabel) { |
435 | 354 | var calculation = []; | 368 | var calculation = []; |
436 | 355 | var calc = storage.getCalculation(memory.get(index).dbId); | 369 | var calc = storage.getCalculation(memory.get(index).dbId); |
437 | 356 | calc.mainLabel = newText | 370 | calc.mainLabel = newText |
438 | 357 | calculation.push({"calc": calc}); | 371 | calculation.push({"calc": calc}); |
439 | 358 | storage.updateCalculation(calculation, memory.get(index).dbId); | 372 | storage.updateCalculation(calculation, memory.get(index).dbId); |
440 | 359 | } | 373 | } |
441 | 374 | else { | ||
442 | 375 | saveLabel = true; | ||
443 | 376 | var oldLabel = storage.getCalculation(memory.get(index).dbId); | ||
444 | 377 | memory.get(index).mainLabel = oldLabel.mainLabel; | ||
445 | 378 | } | ||
446 | 360 | } | 379 | } |
447 | 361 | 380 | ||
448 | 362 | function saveCalcLabel(idx, newText) { | 381 | function saveCalcLabel(idx, newText) { |
450 | 363 | if (index !== 0) { | 382 | if (index !== 0 && saveLabel) { |
451 | 364 | var calculation = []; | 383 | var calculation = []; |
452 | 365 | var calc = storage.getCalculation(memory.get(index).dbId); | 384 | var calc = storage.getCalculation(memory.get(index).dbId); |
453 | 366 | calc.operators[idx]._text = newText; | 385 | calc.operators[idx]._text = newText; |
454 | 367 | calculation.push({"calc": calc}); | 386 | calculation.push({"calc": calc}); |
455 | 368 | storage.updateCalculation(calculation, memory.get(index).dbId); | 387 | storage.updateCalculation(calculation, memory.get(index).dbId); |
456 | 369 | } | 388 | } |
457 | 389 | else { | ||
458 | 390 | saveLabel = true | ||
459 | 391 | var oldLabel = storage.getCalculation(memory.get(index).dbId); | ||
460 | 392 | newText = oldLabel.operators[idx]._text; | ||
461 | 393 | } | ||
462 | 394 | |||
463 | 395 | return newText; | ||
464 | 370 | } | 396 | } |
465 | 371 | 397 | ||
466 | 372 | onRemoveItem: { | 398 | onRemoveItem: { |
467 | @@ -386,20 +412,6 @@ | |||
468 | 386 | formulaView.forceActiveFocus(); | 412 | formulaView.forceActiveFocus(); |
469 | 387 | } | 413 | } |
470 | 388 | 414 | ||
471 | 389 | /* We need to override default behavior: when user click on up or down key | ||
472 | 390 | * screen has to go up or down of always the same size | ||
473 | 391 | * By default with up and down QT changes the focus and scrolls only if | ||
474 | 392 | * focused Item is not on screen | ||
475 | 393 | */ | ||
476 | 394 | Keys.onUpPressed: { | ||
477 | 395 | if (!formulaView.atYBeginning) | ||
478 | 396 | scrollWithKeyboard(-100); | ||
479 | 397 | } | ||
480 | 398 | Keys.onDownPressed: { | ||
481 | 399 | if (!formulaView.atYEnd) | ||
482 | 400 | scrollWithKeyboard(100); | ||
483 | 401 | } | ||
484 | 402 | |||
485 | 403 | onMovementStarted: { | 415 | onMovementStarted: { |
486 | 404 | __wasAtYBegining = atYEnd | 416 | __wasAtYBegining = atYEnd |
487 | 405 | __initialContentY = contentY | 417 | __initialContentY = contentY |
488 | @@ -415,7 +427,14 @@ | |||
489 | 415 | } | 427 | } |
490 | 416 | } | 428 | } |
491 | 417 | onMovementEnded: { | 429 | onMovementEnded: { |
493 | 418 | if (__toBeRefresh && isFinished) { | 430 | if (__toBeRefresh) { |
494 | 431 | tearedOff(); | ||
495 | 432 | __toBeRefresh = false | ||
496 | 433 | } | ||
497 | 434 | } | ||
498 | 435 | |||
499 | 436 | function tearedOff(){ | ||
500 | 437 | if (isFinished) { | ||
501 | 419 | isFinished = false; | 438 | isFinished = false; |
502 | 420 | 439 | ||
503 | 421 | if (formulaView.addCurrentToMemory()) { | 440 | if (formulaView.addCurrentToMemory()) { |
504 | @@ -440,11 +459,8 @@ | |||
505 | 440 | 459 | ||
506 | 441 | storage.saveCalculations(calculations); | 460 | storage.saveCalculations(calculations); |
507 | 442 | } | 461 | } |
508 | 443 | |||
509 | 444 | clear(); | 462 | clear(); |
510 | 445 | __toBeRefresh = false | ||
511 | 446 | hasToAddDot=false; | 463 | hasToAddDot=false; |
512 | 447 | |||
513 | 448 | isFinished = true; | 464 | isFinished = true; |
514 | 449 | } | 465 | } |
515 | 450 | } | 466 | } |
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://