Merge lp:~rpadovani/ubuntu-calculator-app/1287340 into lp:~ubuntu-calculator-dev/ubuntu-calculator-app/old_trunk
- 1287340
- Merge into old_trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Riccardo Padovani | ||||
Approved revision: | 227 | ||||
Merged at revision: | 232 | ||||
Proposed branch: | lp:~rpadovani/ubuntu-calculator-app/1287340 | ||||
Merge into: | lp:~ubuntu-calculator-dev/ubuntu-calculator-app/old_trunk | ||||
Diff against target: |
84 lines (+19/-10) 2 files modified
Simple/CalcKeyboard.qml (+2/-2) Simple/SimplePage.qml (+17/-8) |
||||
To merge this branch: | bzr merge lp:~rpadovani/ubuntu-calculator-app/1287340 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ubuntu Phone Apps Jenkins Bot | continuous-integration | Approve | |
Mihir Soni | Approve | ||
Bartosz Kosiorek | Approve | ||
Review via email: mp+209411@code.launchpad.net |
Commit message
Fixed #1287340
Description of the change
Fixed #1287340
Now separator is localized, so keyboard shortcut
Riccardo Padovani (rpadovani) wrote : | # |
Thanks Bartosz, nice catch.
I should have fixed it, could you confirm, please?
Bartosz Kosiorek (gang65) wrote : | # |
One more comment:
Instead of replacing:
result = result.replace(".", separator);
you could use toLocaleString without checking
result = result.
Instead of replacing separators,
if (buttonName === separator) {
}
}
if (buttonName === separator) {
}
}
try to use contruction:
Keys.onPressed: {
...
Keys.onReleased: {
...
else if (event.text === separator) {
Instead of
if (separator !== '.' && last.value.
}
use:
Thanks !
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:225
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Riccardo Padovani (rpadovani) wrote : | # |
> One more comment:
>
> Instead of replacing:
> result = result.replace(".", separator);
> you could use toLocaleString without checking
> result = result.
> ng(Qt.locale(), "f", 0);
Doesn't work (here in Italy we use , as separator):
console.
console.
console.
result: 12.5
result.
Qt.locale(
> Instead of replacing separators,
> function buttonClicked(
> if (buttonName === separator) {
> buttonName = '.';
> }
> keyboardButtons
> }
>
> function buttonReleased(
> if (buttonName === separator) {
> buttonName = '.';
> }
> keyboardButtons
> }
>
> try to use contruction:
> Keys.onPressed: {
> ...
> Keys.onReleased: {
> ...
>
> else if (event.text === separator) {
> buttonClicked(".")
Good idea, done!
> Instead of
> if (separator !== '.' && last.value.
> last.value = separator;
> }
> screenFormula[
> last.value.
>
> use:
> screenFormula[
> last.value.
Doesn't work:
console.
console.
console.
last.value: .
last.value.
Qt.locale(
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:226
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:227
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Bartosz Kosiorek (gang65) : | # |
Mihir Soni (mihirsoni) wrote : | # |
Looks good.
Thank you Riccardo :)
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) : | # |
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Autolanding.
Unapproved changes made after approval.
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) : | # |
Preview Diff
1 | === modified file 'Simple/CalcKeyboard.qml' | |||
2 | --- Simple/CalcKeyboard.qml 2014-01-23 18:34:48 +0000 | |||
3 | +++ Simple/CalcKeyboard.qml 2014-03-10 18:41:03 +0000 | |||
4 | @@ -278,10 +278,10 @@ | |||
5 | 278 | id: pointButton | 278 | id: pointButton |
6 | 279 | x: (calcGridUnit*11)*2 | 279 | x: (calcGridUnit*11)*2 |
7 | 280 | y: (calcGridUnit*8)*4 | 280 | y: (calcGridUnit*8)*4 |
9 | 281 | text: "." | 281 | text: separator |
10 | 282 | onClicked: { | 282 | onClicked: { |
11 | 283 | if (!hasToAddDot) { // To avoid multiple dots | 283 | if (!hasToAddDot) { // To avoid multiple dots |
13 | 284 | hasToAddDot = formulaPush(text); | 284 | hasToAddDot = formulaPush('.'); // Engine uses dot, but on screen there is local separator |
14 | 285 | } | 285 | } |
15 | 286 | } | 286 | } |
16 | 287 | } | 287 | } |
17 | 288 | 288 | ||
18 | === modified file 'Simple/SimplePage.qml' | |||
19 | --- Simple/SimplePage.qml 2014-03-09 21:53:29 +0000 | |||
20 | +++ Simple/SimplePage.qml 2014-03-10 18:41:03 +0000 | |||
21 | @@ -26,6 +26,7 @@ | |||
22 | 26 | property var screenFormula: [{_text:'', _operation: '', _number:''}] | 26 | property var screenFormula: [{_text:'', _operation: '', _number:''}] |
23 | 27 | property bool labelVisible: false | 27 | property bool labelVisible: false |
24 | 28 | property bool saveLabel: true | 28 | property bool saveLabel: true |
25 | 29 | property var separator: Qt.locale().decimalPoint | ||
26 | 29 | /* | 30 | /* |
27 | 30 | * hasToAddDot became true if dot is last pressed button. | 31 | * hasToAddDot became true if dot is last pressed button. |
28 | 31 | * It is necessary only for +/- | 32 | * It is necessary only for +/- |
29 | @@ -62,6 +63,9 @@ | |||
30 | 62 | if (last !== undefined && last !== 'invalidOperation') { // Just to check it is not blank and if is a valid operation | 63 | if (last !== undefined && last !== 'invalidOperation') { // Just to check it is not blank and if is a valid operation |
31 | 63 | // If the element is a number it has to be added to current line | 64 | // If the element is a number it has to be added to current line |
32 | 64 | if (last.type === CALC.T_NUMBER || last.type === CALC.T_UNARY_MINUS) { | 65 | if (last.type === CALC.T_NUMBER || last.type === CALC.T_UNARY_MINUS) { |
33 | 66 | if (separator !== '.' && last.value.toString() === '.') { | ||
34 | 67 | last.value = separator; | ||
35 | 68 | } | ||
36 | 65 | screenFormula[screenFormula.length - 1]._number += last.value.toString(); | 69 | screenFormula[screenFormula.length - 1]._number += last.value.toString(); |
37 | 66 | added = true; | 70 | added = true; |
38 | 67 | } else if (last.type === CALC.T_MINUS && screenFormula[screenFormula.length - 1]._number === ''){ | 71 | } else if (last.type === CALC.T_MINUS && screenFormula[screenFormula.length - 1]._number === ''){ |
39 | @@ -101,6 +105,9 @@ | |||
40 | 101 | // CALC.PRECISION is set in engine.js | 105 | // CALC.PRECISION is set in engine.js |
41 | 102 | if (result) { | 106 | if (result) { |
42 | 103 | result = result.toPrecision(CALC.PRECISION).replace(/\.0+$/,""); | 107 | result = result.toPrecision(CALC.PRECISION).replace(/\.0+$/,""); |
43 | 108 | if (separator !== '.' && result.indexOf('.') !== -1) { | ||
44 | 109 | result = result.replace(".", separator); | ||
45 | 110 | } | ||
46 | 104 | screenFormula.push({_text:'', _operation: '=', _number: result.toString()}); | 111 | screenFormula.push({_text:'', _operation: '=', _number: result.toString()}); |
47 | 105 | } | 112 | } |
48 | 106 | formulaView.currentOperatorsChanged(); | 113 | formulaView.currentOperatorsChanged(); |
49 | @@ -232,10 +239,11 @@ | |||
50 | 232 | event.text === "-" || | 239 | event.text === "-" || |
51 | 233 | event.text === "*" || | 240 | event.text === "*" || |
52 | 234 | event.text === "/" || | 241 | event.text === "/" || |
53 | 235 | event.text === "." || | ||
54 | 236 | event.text === "=") && | 242 | event.text === "=") && |
55 | 237 | event.text !== "") { | 243 | event.text !== "") { |
56 | 238 | buttonClicked(event.text) | 244 | buttonClicked(event.text) |
57 | 245 | } else if (event.text === separator) { | ||
58 | 246 | buttonClicked('.'); | ||
59 | 239 | } | 247 | } |
60 | 240 | } | 248 | } |
61 | 241 | else { | 249 | else { |
62 | @@ -257,14 +265,15 @@ | |||
63 | 257 | } else if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return || event.key === Qt.Key_Equal) { | 265 | } else if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return || event.key === Qt.Key_Equal) { |
64 | 258 | buttonReleased('='); | 266 | buttonReleased('='); |
65 | 259 | } else if ((!isNaN(event.text) || | 267 | } else if ((!isNaN(event.text) || |
73 | 260 | event.text === "+" || | 268 | event.text === "+" || |
74 | 261 | event.text === "-" || | 269 | event.text === "-" || |
75 | 262 | event.text === "*" || | 270 | event.text === "*" || |
76 | 263 | event.text === "/" || | 271 | event.text === "/" || |
77 | 264 | event.text === "." || | 272 | event.text === "=") && |
78 | 265 | event.text === "=") && | 273 | event.text !== "") { |
72 | 266 | event.text !== "") { | ||
79 | 267 | buttonReleased(event.text) | 274 | buttonReleased(event.text) |
80 | 275 | } else if (event.text === separator) { | ||
81 | 276 | buttonReleased('.'); | ||
82 | 268 | } | 277 | } |
83 | 269 | } | 278 | } |
84 | 270 | } | 279 | } |
Thanks Riccardo for patch.
It works perfectly for me. Numpad works as it should.
I found one small visual issue: When you press "." on numpad the "dot button" on screen is always pressing down