Merge lp:~rpadovani/ubuntu-calculator-app/keyboardImprovement into lp:ubuntu-calculator-app
- keyboardImprovement
- Merge into trunk
Proposed by
Riccardo Padovani
Status: | Merged |
---|---|
Merged at revision: | 5 |
Proposed branch: | lp:~rpadovani/ubuntu-calculator-app/keyboardImprovement |
Merge into: | lp:ubuntu-calculator-app |
Prerequisite: | lp:~rpadovani/ubuntu-calculator-app/cleanUp |
Diff against target: |
934 lines (+411/-481) 2 files modified
app/ubuntu-calculator-app.qml (+1/-1) app/ui/CalcKeyboard.qml (+410/-480) |
To merge this branch: | bzr merge lp:~rpadovani/ubuntu-calculator-app/keyboardImprovement |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Bartosz Kosiorek | Approve | ||
Review via email: mp+242887@code.launchpad.net |
Commit message
Added swype to advanced functions and support for them
Description of the change
Added swype to advanced functions and support for them
To post a comment you must log in.
- 6. By Riccardo Padovani
-
Updated copyright
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'app/ubuntu-calculator-app.qml' | |||
2 | --- app/ubuntu-calculator-app.qml 2014-11-26 09:41:07 +0000 | |||
3 | +++ app/ubuntu-calculator-app.qml 2014-11-26 09:41:07 +0000 | |||
4 | @@ -42,7 +42,7 @@ | |||
5 | 42 | 42 | ||
6 | 43 | function calculate() { | 43 | function calculate() { |
7 | 44 | console.log("Formula: " + formula) | 44 | console.log("Formula: " + formula) |
9 | 45 | var result = MathJs.eval(formula); | 45 | var result = mathJs.eval(formula); |
10 | 46 | result = result.toString(); | 46 | result = result.toString(); |
11 | 47 | console.log("Result: " + result); | 47 | console.log("Result: " + result); |
12 | 48 | formula = ''; | 48 | formula = ''; |
13 | 49 | 49 | ||
14 | === modified file 'app/ui/CalcKeyboard.qml' | |||
15 | --- app/ui/CalcKeyboard.qml 2014-11-26 09:41:07 +0000 | |||
16 | +++ app/ui/CalcKeyboard.qml 2014-11-26 09:41:07 +0000 | |||
17 | @@ -1,13 +1,13 @@ | |||
18 | 1 | /* | 1 | /* |
28 | 2 | * Copyright 2014 Canonical Ltd. | 2 | * Copyright (C) 2014 Canonical Ltd |
29 | 3 | * | 3 | * |
30 | 4 | * This file is part of ubuntu-calculator-app. | 4 | * This file is part of Ubuntu Calculator App |
31 | 5 | * | 5 | * |
32 | 6 | * ubuntu-calculator-app is free software; you can redistribute it and/or modify | 6 | * Ubuntu Calculator App is free software: you can redistribute it and/or modify |
33 | 7 | * it under the terms of the GNU General Public License as published by | 7 | * it under the terms of the GNU General Public License version 3 as |
34 | 8 | * the Free Software Foundation; version 3. | 8 | * published by the Free Software Foundation. |
35 | 9 | * | 9 | * |
36 | 10 | * ubuntu-calculator-app is distributed in the hope that it will be useful, | 10 | * Ubuntu Calculator App is distributed in the hope that it will be useful, |
37 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
38 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
39 | 13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. |
40 | @@ -15,14 +15,13 @@ | |||
41 | 15 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License |
42 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
43 | 17 | */ | 17 | */ |
44 | 18 | |||
45 | 19 | import QtQuick 2.3 | 18 | import QtQuick 2.3 |
46 | 20 | import Ubuntu.Components 1.1 | 19 | import Ubuntu.Components 1.1 |
47 | 21 | 20 | ||
48 | 22 | Item { | 21 | Item { |
49 | 23 | id: virtualKeyboard | 22 | id: virtualKeyboard |
50 | 24 | width: parent.width | 23 | width: parent.width |
52 | 25 | height: parent.height / 2 | 24 | height: grid.height+units.gu(2) |
53 | 26 | 25 | ||
54 | 27 | property int calcGridUnit: width / 50 | 26 | property int calcGridUnit: width / 50 |
55 | 28 | property variant keyboardButtons: {'0': zeroButton, | 27 | property variant keyboardButtons: {'0': zeroButton, |
56 | @@ -51,478 +50,409 @@ | |||
57 | 51 | 'clear': clearButton, | 50 | 'clear': clearButton, |
58 | 52 | 'backspace': backspaceButton } | 51 | 'backspace': backspaceButton } |
59 | 53 | 52 | ||
64 | 54 | Rectangle { | 53 | Flickable { |
65 | 55 | width: virtualKeyboard.width * 2 | 54 | id: flickableKeyboard |
66 | 56 | height: grid.height + units.gu(2) | 55 | anchors.fill: parent |
67 | 57 | color: "#ffffff" | 56 | flickableDirection: Flickable.HorizontalFlick |
68 | 57 | contentWidth: virtualKeyboard.width * 2 | ||
69 | 58 | contentHeight: grid.height + units.gu(4) | ||
70 | 59 | boundsBehavior: Flickable.DragOverBounds | ||
71 | 58 | 60 | ||
75 | 59 | anchors{ | 61 | onMovementEnded: { |
76 | 60 | top: parent.top | 62 | // if we are not on the border of the virtual calculator keyboard |
77 | 61 | topMargin: formulaView.__wasAtYBegining & formulaView.__displaceDist > 0 ? formulaView.__displaceDist : 0 | 63 | // then trigger flick |
78 | 64 | if (!flickableKeyboard.atXBeginning && !flickableKeyboard.atXEnd) { | ||
79 | 65 | if (contentX < virtualKeyboard.width / 2) { | ||
80 | 66 | flickableKeyboard.flick( units.gu(200), 0); | ||
81 | 67 | } else { | ||
82 | 68 | flickableKeyboard.flick( -units.gu(200), 0); | ||
83 | 69 | } | ||
84 | 70 | } | ||
85 | 62 | } | 71 | } |
86 | 63 | 72 | ||
549 | 64 | Item { | 73 | Rectangle { |
550 | 65 | id: grid | 74 | width: virtualKeyboard.width * 2 |
551 | 66 | 75 | height: grid.height + units.gu(2) | |
552 | 67 | // 8 keys and 7 space between and border | 76 | color: "#ffffff" |
553 | 68 | width: (calcGridUnit*12)*8 + (calcGridUnit)*7 + calcGridUnit | 77 | |
554 | 69 | height: (calcGridUnit*9)*5 + (calcGridUnit)*4 | 78 | Item { |
555 | 70 | 79 | id: grid | |
556 | 71 | anchors{ | 80 | |
557 | 72 | horizontalCenter: parent.horizontalCenter | 81 | // 8 keys and 7 space between and border |
558 | 73 | top: parent.top | 82 | width: (calcGridUnit*12)*8 + (calcGridUnit)*7 + calcGridUnit |
559 | 74 | topMargin: units.gu(1) | 83 | height: (calcGridUnit*9)*5 + (calcGridUnit)*4 |
560 | 75 | } | 84 | |
561 | 76 | 85 | anchors{ | |
562 | 77 | KeyboardButton { | 86 | horizontalCenter: parent.horizontalCenter |
563 | 78 | objectName: "clearButton" | 87 | top: parent.top |
564 | 79 | id: clearButton | 88 | topMargin: units.gu(1) |
565 | 80 | x: 0 | 89 | } |
566 | 81 | y: 0 | 90 | |
567 | 82 | // TRANSLATORS: Refers to Clear, keep the translation to 2 characters | 91 | KeyboardButton { |
568 | 83 | text: i18n.tr("←") | 92 | objectName: "clearButton" |
569 | 84 | onReleased: { | 93 | id: clearButton |
570 | 85 | numeralPop(); | 94 | x: 0 |
571 | 86 | 95 | y: 0 | |
572 | 87 | } | 96 | // TRANSLATORS: Refers to Clear, keep the translation to 2 characters |
573 | 88 | } | 97 | text: i18n.tr("←") |
574 | 89 | 98 | // TODO: implement function to remove last char | |
575 | 90 | KeyboardButton { | 99 | // onReleased: numeralPop(); |
576 | 91 | objectName: "signButton" | 100 | } |
577 | 92 | id: signButton | 101 | |
578 | 93 | x: (calcGridUnit*13) | 102 | KeyboardButton { |
579 | 94 | y: 0 | 103 | objectName: "signButton" |
580 | 95 | text: "+/-" | 104 | id: signButton |
581 | 96 | onReleased: { | 105 | x: (calcGridUnit*13) |
582 | 97 | changeSign(); | 106 | y: 0 |
583 | 98 | } | 107 | text: "+/-" |
584 | 99 | } | 108 | // TODO: implement changeSign function |
585 | 100 | 109 | // onReleased: changeSign(); | |
586 | 101 | KeyboardButton { | 110 | } |
587 | 102 | objectName: "divideButton" | 111 | |
588 | 103 | id: divideButton | 112 | KeyboardButton { |
589 | 104 | x: (calcGridUnit*13)*2 | 113 | objectName: "divideButton" |
590 | 105 | y: 0 | 114 | id: divideButton |
591 | 106 | text: "÷" | 115 | x: (calcGridUnit*13)*2 |
592 | 107 | onReleased: { | 116 | y: 0 |
593 | 108 | formulaPush('/'); | 117 | text: "÷" |
594 | 109 | 118 | onReleased: formulaPush('/'); | |
595 | 110 | } | 119 | } |
596 | 111 | } | 120 | |
597 | 112 | 121 | KeyboardButton { | |
598 | 113 | KeyboardButton { | 122 | objectName: "multiplyButton" |
599 | 114 | objectName: "multiplyButton" | 123 | id: multiplyButton |
600 | 115 | id: multiplyButton | 124 | x: (calcGridUnit*13)*3 |
601 | 116 | x: (calcGridUnit*13)*3 | 125 | y: 0 |
602 | 117 | y: 0 | 126 | text: "×" |
603 | 118 | text: "×" | 127 | onReleased: formulaPush('*'); |
604 | 119 | onReleased: { | 128 | } |
605 | 120 | formulaPush('*'); | 129 | |
606 | 121 | 130 | KeyboardButton { | |
607 | 122 | } | 131 | objectName: "powerButton" |
608 | 123 | } | 132 | id: powerButton |
609 | 124 | 133 | x: (calcGridUnit*13)*4 + calcGridUnit | |
610 | 125 | KeyboardButton { | 134 | y: 0 |
611 | 126 | objectName: "powerButton" | 135 | text: "xⁿ" |
612 | 127 | id: powerButton | 136 | onReleased: formulaPush('^'); |
613 | 128 | x: (calcGridUnit*13)*4 + calcGridUnit | 137 | } |
614 | 129 | y: 0 | 138 | |
615 | 130 | text: "xⁿ" | 139 | |
616 | 131 | onReleased: { | 140 | KeyboardButton { |
617 | 132 | formulaPush('^'); | 141 | objectName: "squareButton" |
618 | 133 | } | 142 | id: squareButton |
619 | 134 | } | 143 | x: (calcGridUnit*13)*5 + calcGridUnit |
620 | 135 | 144 | y: 0 | |
621 | 136 | 145 | text: "x²" | |
622 | 137 | KeyboardButton { | 146 | onReleased: { |
623 | 138 | objectName: "squareButton" | 147 | if (formulaPush('^') === true) { |
624 | 139 | id: squareButton | 148 | formulaPush('2') |
625 | 140 | x: (calcGridUnit*13)*5 + calcGridUnit | 149 | } |
626 | 141 | y: 0 | 150 | } |
627 | 142 | text: "x²" | 151 | } |
628 | 143 | onReleased: { | 152 | |
629 | 144 | if (formulaPush('^') === true) { | 153 | KeyboardButton { |
630 | 145 | hasToAddDot = true | 154 | objectName: "cubeButton" |
631 | 146 | formulaPush('2') | 155 | id: cubeButton |
632 | 147 | } | 156 | x: (calcGridUnit*13)*6 + calcGridUnit |
633 | 148 | } | 157 | y: 0 |
634 | 149 | } | 158 | text: "x³" |
635 | 150 | 159 | onReleased: { | |
636 | 151 | KeyboardButton { | 160 | if (formulaPush('^') === true) { |
637 | 152 | objectName: "cubeButton" | 161 | formulaPush('3') |
638 | 153 | id: cubeButton | 162 | } |
639 | 154 | x: (calcGridUnit*13)*6 + calcGridUnit | 163 | } |
640 | 155 | y: 0 | 164 | } |
641 | 156 | text: "x³" | 165 | |
642 | 157 | onReleased: { | 166 | KeyboardButton { |
643 | 158 | if (formulaPush('^') === true) { | 167 | objectName: "backspaceButton" |
644 | 159 | //make sure that we have integers (to avoid expressions like 2^2.1) | 168 | id: backspaceButton |
645 | 160 | hasToAddDot = true | 169 | x: (calcGridUnit*13)*7 + calcGridUnit |
646 | 161 | formulaPush('3') | 170 | y: 0 |
647 | 162 | } | 171 | text: "←" |
648 | 163 | } | 172 | // TODO: implement function to delete last char |
649 | 164 | } | 173 | // onReleased: numeralPop(); |
650 | 165 | 174 | } | |
651 | 166 | KeyboardButton { | 175 | |
652 | 167 | objectName: "backspaceButton" | 176 | KeyboardButton { |
653 | 168 | id: backspaceButton | 177 | objectName: "sevenButton" |
654 | 169 | x: (calcGridUnit*13)*7 + calcGridUnit | 178 | id: sevenButton |
655 | 170 | y: 0 | 179 | x: 0 |
656 | 171 | text: "←" | 180 | y: (calcGridUnit*10) |
657 | 172 | onReleased: { | 181 | text: Number(7).toLocaleString(Qt.locale(), "f", 0) |
658 | 173 | numeralPop(); | 182 | onReleased: formulaPush(text); |
659 | 174 | } | 183 | } |
660 | 175 | } | 184 | |
661 | 176 | 185 | KeyboardButton { | |
662 | 177 | KeyboardButton { | 186 | objectName: "eightButton" |
663 | 178 | objectName: "sevenButton" | 187 | id: eightButton |
664 | 179 | id: sevenButton | 188 | x: (calcGridUnit*13) |
665 | 180 | x: 0 | 189 | y: (calcGridUnit*10) |
666 | 181 | y: (calcGridUnit*10) | 190 | text: Number(8).toLocaleString(Qt.locale(), "f", 0) |
667 | 182 | text: Number(7).toLocaleString(Qt.locale(), "f", 0) | 191 | onReleased: formulaPush(text); |
668 | 183 | onReleased: { | 192 | } |
669 | 184 | formulaPush(text); | 193 | |
670 | 185 | } | 194 | KeyboardButton { |
671 | 186 | } | 195 | objectName: "nineButton" |
672 | 187 | 196 | id: nineButton | |
673 | 188 | KeyboardButton { | 197 | x: (calcGridUnit*13)*2 |
674 | 189 | objectName: "eightButton" | 198 | y: (calcGridUnit*10) |
675 | 190 | id: eightButton | 199 | text: Number(9).toLocaleString(Qt.locale(), "f", 0) |
676 | 191 | x: (calcGridUnit*13) | 200 | onReleased: formulaPush(text); |
677 | 192 | y: (calcGridUnit*10) | 201 | } |
678 | 193 | text: Number(8).toLocaleString(Qt.locale(), "f", 0) | 202 | |
679 | 194 | onReleased: { | 203 | KeyboardButton { |
680 | 195 | formulaPush(text); | 204 | objectName: "minusButton" |
681 | 196 | } | 205 | id: minusButton |
682 | 197 | } | 206 | x: (calcGridUnit*13)*3 |
683 | 198 | 207 | y: (calcGridUnit*10) | |
684 | 199 | KeyboardButton { | 208 | text: "−" |
685 | 200 | objectName: "nineButton" | 209 | onReleased: formulaPush('-'); |
686 | 201 | id: nineButton | 210 | } |
687 | 202 | x: (calcGridUnit*13)*2 | 211 | |
688 | 203 | y: (calcGridUnit*10) | 212 | KeyboardButton { |
689 | 204 | text: Number(9).toLocaleString(Qt.locale(), "f", 0) | 213 | objectName: "eNumberButton" |
690 | 205 | onReleased: { | 214 | id: eNumberButton |
691 | 206 | formulaPush(text); | 215 | x: (calcGridUnit*13)*4 + calcGridUnit |
692 | 207 | } | 216 | y: (calcGridUnit*10) |
693 | 208 | } | 217 | text: "e" |
694 | 209 | 218 | onReleased: formulaPush('E'); | |
695 | 210 | KeyboardButton { | 219 | } |
696 | 211 | objectName: "minusButton" | 220 | |
697 | 212 | id: minusButton | 221 | KeyboardButton { |
698 | 213 | x: (calcGridUnit*13)*3 | 222 | objectName: "piNumberButton" |
699 | 214 | y: (calcGridUnit*10) | 223 | id: piNumberButton |
700 | 215 | text: "−" | 224 | x: (calcGridUnit*13)*5 + calcGridUnit |
701 | 216 | onReleased: { | 225 | y: (calcGridUnit*10) |
702 | 217 | formulaPush('-'); | 226 | text: "π" |
703 | 218 | 227 | onReleased: formulaPush('pi'); | |
704 | 219 | } | 228 | } |
705 | 220 | } | 229 | |
706 | 221 | 230 | KeyboardButton { | |
707 | 222 | 231 | objectName: "moduloButton" | |
708 | 223 | KeyboardButton { | 232 | id: moduloButton |
709 | 224 | objectName: "eNumberButton" | 233 | x: (calcGridUnit*13)*6 + calcGridUnit |
710 | 225 | id: eNumberButton | 234 | y: (calcGridUnit*10) |
711 | 226 | x: (calcGridUnit*13)*4 + calcGridUnit | 235 | // TRANSLATORS: Refers to Modulo - operation that finds the remainder of division of one number by another. |
712 | 227 | y: (calcGridUnit*10) | 236 | text: i18n.tr("mod") |
713 | 228 | text: "e" | 237 | onReleased: formulaPush('%'); |
714 | 229 | onReleased: { | 238 | } |
715 | 230 | formulaPush('E'); | 239 | |
716 | 231 | 240 | KeyboardButton { | |
717 | 232 | } | 241 | objectName: "factorialNumberButton" |
718 | 233 | } | 242 | id: factorialNumberButton |
719 | 234 | 243 | x: (calcGridUnit*13)*7 + calcGridUnit | |
720 | 235 | KeyboardButton { | 244 | y: (calcGridUnit*10) |
721 | 236 | objectName: "piNumberButton" | 245 | text: "!" |
722 | 237 | id: piNumberButton | 246 | onReleased: formulaPush('!'); |
723 | 238 | x: (calcGridUnit*13)*5 + calcGridUnit | 247 | } |
724 | 239 | y: (calcGridUnit*10) | 248 | |
725 | 240 | text: "π" | 249 | KeyboardButton { |
726 | 241 | onReleased: { | 250 | objectName: "fourButton" |
727 | 242 | formulaPush('pi'); | 251 | id: fourButton |
728 | 243 | 252 | x: 0 | |
729 | 244 | } | 253 | y: (calcGridUnit*10)*2 |
730 | 245 | } | 254 | text: Number(4).toLocaleString(Qt.locale(), "f", 0) |
731 | 246 | 255 | onReleased: formulaPush(text); | |
732 | 247 | KeyboardButton { | 256 | } |
733 | 248 | objectName: "moduloButton" | 257 | |
734 | 249 | id: moduloButton | 258 | KeyboardButton { |
735 | 250 | x: (calcGridUnit*13)*6 + calcGridUnit | 259 | objectName: "fiveButton" |
736 | 251 | y: (calcGridUnit*10) | 260 | id: fiveButton |
737 | 252 | // TRANSLATORS: Refers to Modulo - operation that finds the remainder of division of one number by another. | 261 | x: (calcGridUnit*13) |
738 | 253 | text: i18n.tr("mod") | 262 | y: (calcGridUnit*10)*2 |
739 | 254 | onReleased: { | 263 | text: Number(5).toLocaleString(Qt.locale(), "f", 0) |
740 | 255 | formulaPush('%'); | 264 | onReleased: formulaPush(text); |
741 | 256 | 265 | } | |
742 | 257 | } | 266 | |
743 | 258 | } | 267 | KeyboardButton { |
744 | 259 | 268 | objectName: "sixButton" | |
745 | 260 | KeyboardButton { | 269 | id: sixButton |
746 | 261 | objectName: "factorialNumberButton" | 270 | x: (calcGridUnit*13)*2 |
747 | 262 | id: factorialNumberButton | 271 | y: (calcGridUnit*10)*2 |
748 | 263 | x: (calcGridUnit*13)*7 + calcGridUnit | 272 | text: Number(6).toLocaleString(Qt.locale(), "f", 0) |
749 | 264 | y: (calcGridUnit*10) | 273 | onReleased: formulaPush(text); |
750 | 265 | text: "!" | 274 | } |
751 | 266 | onReleased: { | 275 | |
752 | 267 | formulaPush('!'); | 276 | KeyboardButton { |
753 | 268 | 277 | objectName: "plusButton" | |
754 | 269 | } | 278 | id: plusButton |
755 | 270 | } | 279 | x: (calcGridUnit*13)*3 |
756 | 271 | 280 | y: (calcGridUnit*10)*2 | |
757 | 272 | KeyboardButton { | 281 | text: "+" |
758 | 273 | objectName: "fourButton" | 282 | onReleased: formulaPush(text); |
759 | 274 | id: fourButton | 283 | } |
760 | 275 | x: 0 | 284 | |
761 | 276 | y: (calcGridUnit*10)*2 | 285 | KeyboardButton { |
762 | 277 | text: Number(4).toLocaleString(Qt.locale(), "f", 0) | 286 | objectName: "openBracketButton" |
763 | 278 | onReleased: { | 287 | id: openBracketButton |
764 | 279 | formulaPush(text); | 288 | x: (calcGridUnit*13)*4 + calcGridUnit |
765 | 280 | } | 289 | y: (calcGridUnit*10)*2 |
766 | 281 | } | 290 | text: "(" |
767 | 282 | 291 | onReleased: formulaPush('('); | |
768 | 283 | KeyboardButton { | 292 | } |
769 | 284 | objectName: "fiveButton" | 293 | |
770 | 285 | id: fiveButton | 294 | KeyboardButton { |
771 | 286 | x: (calcGridUnit*13) | 295 | objectName: "closeBracketButton" |
772 | 287 | y: (calcGridUnit*10)*2 | 296 | id: closeBracketButton |
773 | 288 | text: Number(5).toLocaleString(Qt.locale(), "f", 0) | 297 | x: (calcGridUnit*13)*5 + calcGridUnit |
774 | 289 | onReleased: { | 298 | y: (calcGridUnit*10)*2 |
775 | 290 | formulaPush(text); | 299 | text: ")" |
776 | 291 | } | 300 | onReleased: formulaPush(')'); |
777 | 292 | } | 301 | } |
778 | 293 | 302 | ||
779 | 294 | KeyboardButton { | 303 | KeyboardButton { |
780 | 295 | objectName: "sixButton" | 304 | objectName: "multiplicativeInverseButton" |
781 | 296 | id: sixButton | 305 | id: multiplicativeInverseButton |
782 | 297 | x: (calcGridUnit*13)*2 | 306 | x: (calcGridUnit*13)*6 + calcGridUnit |
783 | 298 | y: (calcGridUnit*10)*2 | 307 | y: (calcGridUnit*10)*2 |
784 | 299 | text: Number(6).toLocaleString(Qt.locale(), "f", 0) | 308 | text: "1/x" |
785 | 300 | onReleased: { | 309 | onReleased: { |
786 | 301 | formulaPush(text); | 310 | if (formulaPush('^') === true) { |
787 | 302 | } | 311 | formulaPush('-1') |
788 | 303 | } | 312 | } |
789 | 304 | 313 | } | |
790 | 305 | KeyboardButton { | 314 | } |
791 | 306 | objectName: "plusButton" | 315 | |
792 | 307 | id: plusButton | 316 | KeyboardButton { |
793 | 308 | x: (calcGridUnit*13)*3 | 317 | objectName: "multiplicativeInverseButton2" |
794 | 309 | y: (calcGridUnit*10)*2 | 318 | id: multiplicativeInverseButton2 |
795 | 310 | text: "+" | 319 | x: (calcGridUnit*13)*7 + calcGridUnit |
796 | 311 | onReleased: { | 320 | y: (calcGridUnit*10)*2 |
797 | 312 | formulaPush(text); | 321 | text: "1/x²" |
798 | 313 | 322 | onReleased: { | |
799 | 314 | } | 323 | if (formulaPush('^') === true) { |
800 | 315 | } | 324 | formulaPush('-2') |
801 | 316 | 325 | } | |
802 | 317 | KeyboardButton { | 326 | } |
803 | 318 | objectName: "openBracketButton" | 327 | } |
804 | 319 | id: openBracketButton | 328 | |
805 | 320 | x: (calcGridUnit*13)*4 + calcGridUnit | 329 | KeyboardButton { |
806 | 321 | y: (calcGridUnit*10)*2 | 330 | objectName: "oneButton" |
807 | 322 | text: "(" | 331 | id: oneButton |
808 | 323 | onReleased: { | 332 | x: 0 |
809 | 324 | formulaPush('('); | 333 | y: (calcGridUnit*10)*3 |
810 | 325 | 334 | text: Number(1).toLocaleString(Qt.locale(), "f", 0) | |
811 | 326 | } | 335 | onReleased: formulaPush(text); |
812 | 327 | } | 336 | } |
813 | 328 | 337 | ||
814 | 329 | KeyboardButton { | 338 | KeyboardButton { |
815 | 330 | objectName: "closeBracketButton" | 339 | objectName: "twoButton" |
816 | 331 | id: closeBracketButton | 340 | id: twoButton |
817 | 332 | x: (calcGridUnit*13)*5 + calcGridUnit | 341 | x: (calcGridUnit*13) |
818 | 333 | y: (calcGridUnit*10)*2 | 342 | y: (calcGridUnit*10)*3 |
819 | 334 | text: ")" | 343 | text: Number(2).toLocaleString(Qt.locale(), "f", 0) |
820 | 335 | onReleased: { | 344 | onReleased: formulaPush(text); |
821 | 336 | formulaPush(')'); | 345 | } |
822 | 337 | 346 | ||
823 | 338 | } | 347 | KeyboardButton { |
824 | 339 | } | 348 | objectName: "threeButton" |
825 | 340 | 349 | id: threeButton | |
826 | 341 | KeyboardButton { | 350 | x: (calcGridUnit*13)*2 |
827 | 342 | objectName: "multiplicativeInverseButton" | 351 | y: (calcGridUnit*10)*3 |
828 | 343 | id: multiplicativeInverseButton | 352 | text: Number(3).toLocaleString(Qt.locale(), "f", 0) |
829 | 344 | x: (calcGridUnit*13)*6 + calcGridUnit | 353 | onReleased: formulaPush(text); |
830 | 345 | y: (calcGridUnit*10)*2 | 354 | } |
831 | 346 | text: "1/x" | 355 | |
832 | 347 | onReleased: { | 356 | KeyboardButton { |
833 | 348 | if (formulaPush('^') === true) { | 357 | objectName: "equalsButton" |
834 | 349 | //make sure that we have integers (to avoid expressions like 2^2.1) | 358 | id: equalsButton |
835 | 350 | hasToAddDot = true | 359 | x: (calcGridUnit*13)*3 |
836 | 351 | formulaPush('-1') | 360 | y: (calcGridUnit*10)*3 |
837 | 352 | } | 361 | height: (calcGridUnit*19) |
838 | 353 | } | 362 | text: "=" |
839 | 354 | } | 363 | onReleased: calculate(); |
840 | 355 | 364 | } | |
841 | 356 | KeyboardButton { | 365 | |
842 | 357 | objectName: "multiplicativeInverseButton2" | 366 | KeyboardButton { |
843 | 358 | id: multiplicativeInverseButton2 | 367 | objectName: "sqrtButton" |
844 | 359 | x: (calcGridUnit*13)*7 + calcGridUnit | 368 | id: sqrtButton |
845 | 360 | y: (calcGridUnit*10)*2 | 369 | x: (calcGridUnit*13)*4 + calcGridUnit |
846 | 361 | text: "1/x²" | 370 | y: (calcGridUnit*10)*3 |
847 | 362 | onReleased: { | 371 | text: "√ " |
848 | 363 | if (formulaPush('^') === true) { | 372 | onReleased: formulaPush('sqrt(') |
849 | 364 | //make sure that we have integers (to avoid expressions like 2^2.1) | 373 | } |
850 | 365 | hasToAddDot = true | 374 | |
851 | 366 | formulaPush('-2') | 375 | KeyboardButton { |
852 | 367 | } | 376 | objectName: "cosinusButton2" |
853 | 368 | } | 377 | id: cosinusButton2 |
854 | 369 | } | 378 | x: (calcGridUnit*13)*5 + calcGridUnit |
855 | 370 | 379 | y: (calcGridUnit*10)*3 | |
856 | 371 | KeyboardButton { | 380 | text: "cos" |
857 | 372 | objectName: "oneButton" | 381 | onReleased: formulaPush('cos(') |
858 | 373 | id: oneButton | 382 | } |
859 | 374 | x: 0 | 383 | |
860 | 375 | y: (calcGridUnit*10)*3 | 384 | KeyboardButton { |
861 | 376 | text: Number(1).toLocaleString(Qt.locale(), "f", 0) | 385 | objectName: "tangensButton2" |
862 | 377 | onReleased: { | 386 | id: tangensButton2 |
863 | 378 | formulaPush(text); | 387 | x: (calcGridUnit*13)*6 + calcGridUnit |
864 | 379 | } | 388 | y: (calcGridUnit*10)*3 |
865 | 380 | } | 389 | text: "tan" |
866 | 381 | 390 | onReleased: formulaPush('tan(') | |
867 | 382 | KeyboardButton { | 391 | } |
868 | 383 | objectName: "twoButton" | 392 | |
869 | 384 | id: twoButton | 393 | KeyboardButton { |
870 | 385 | x: (calcGridUnit*13) | 394 | objectName: "cotangensButton2" |
871 | 386 | y: (calcGridUnit*10)*3 | 395 | id: cotangensButton2 |
872 | 387 | text: Number(2).toLocaleString(Qt.locale(), "f", 0) | 396 | x: (calcGridUnit*13)*7 + calcGridUnit |
873 | 388 | onReleased: { | 397 | y: (calcGridUnit*10)*3 |
874 | 389 | formulaPush(text); | 398 | text: "ctg" |
875 | 390 | } | 399 | onReleased: formulaPush('atan(') |
876 | 391 | } | 400 | } |
877 | 392 | 401 | ||
878 | 393 | KeyboardButton { | 402 | KeyboardButton { |
879 | 394 | objectName: "threeButton" | 403 | objectName: "zeroButton" |
880 | 395 | id: threeButton | 404 | id: zeroButton |
881 | 396 | x: (calcGridUnit*13)*2 | 405 | x: 0 |
882 | 397 | y: (calcGridUnit*10)*3 | 406 | y: (calcGridUnit*10)*4 |
883 | 398 | text: Number(3).toLocaleString(Qt.locale(), "f", 0) | 407 | width: (calcGridUnit*12)*2+calcGridUnit |
884 | 399 | onReleased: { | 408 | text: Number(0).toLocaleString(Qt.locale(), "f", 0) |
885 | 400 | formulaPush(text); | 409 | onReleased: formulaPush(text); |
886 | 401 | } | 410 | } |
887 | 402 | } | 411 | |
888 | 403 | 412 | KeyboardButton { | |
889 | 404 | KeyboardButton { | 413 | objectName: "pointButton" |
890 | 405 | objectName: "equalsButton" | 414 | id: pointButton |
891 | 406 | id: equalsButton | 415 | x: (calcGridUnit*13)*2 |
892 | 407 | x: (calcGridUnit*13)*3 | 416 | y: (calcGridUnit*10)*4 |
893 | 408 | y: (calcGridUnit*10)*3 | 417 | text: "." |
894 | 409 | height: (calcGridUnit*19) | 418 | // TODO: check if there isn't already a dot in the calc |
895 | 410 | text: "=" | 419 | onReleased: formulaPush('.'); |
896 | 411 | onReleased: { | 420 | } |
897 | 412 | calculate(); | 421 | |
898 | 413 | 422 | KeyboardButton { | |
899 | 414 | } | 423 | objectName: "sinusButton" |
900 | 415 | } | 424 | id: sinusButton |
901 | 416 | 425 | x: (calcGridUnit*13)*4 + calcGridUnit | |
902 | 417 | KeyboardButton { | 426 | y: (calcGridUnit*10)*4 |
903 | 418 | objectName: "sqrtButton" | 427 | text: "sin" |
904 | 419 | id: sqrtButton | 428 | onReleased: formulaPush('sin(') |
905 | 420 | x: (calcGridUnit*13)*4 + calcGridUnit | 429 | } |
906 | 421 | y: (calcGridUnit*10)*3 | 430 | |
907 | 422 | text: "√ " | 431 | KeyboardButton { |
908 | 423 | onReleased: { | 432 | objectName: "cosinusButton" |
909 | 424 | formulaPush('sqrt(') | 433 | id: cosinusButton |
910 | 425 | hasToAddDot = true | 434 | x: (calcGridUnit*13)*5 + calcGridUnit |
911 | 426 | } | 435 | y: (calcGridUnit*10)*4 |
912 | 427 | } | 436 | text: "cos" |
913 | 428 | 437 | onReleased: formulaPush('cos(') | |
914 | 429 | KeyboardButton { | 438 | } |
915 | 430 | objectName: "cosinusButton2" | 439 | |
916 | 431 | id: cosinusButton2 | 440 | KeyboardButton { |
917 | 432 | x: (calcGridUnit*13)*5 + calcGridUnit | 441 | objectName: "tangensButton" |
918 | 433 | y: (calcGridUnit*10)*3 | 442 | id: tangensButton |
919 | 434 | text: "cos" | 443 | x: (calcGridUnit*13)*6 + calcGridUnit |
920 | 435 | onReleased: { | 444 | y: (calcGridUnit*10)*4 |
921 | 436 | formulaPush('cos(') | 445 | text: "tan" |
922 | 437 | hasToAddDot = true | 446 | onReleased: formulaPush('tan(') |
923 | 438 | } | 447 | } |
924 | 439 | } | 448 | |
925 | 440 | 449 | KeyboardButton { | |
926 | 441 | KeyboardButton { | 450 | objectName: "cotangensButton" |
927 | 442 | objectName: "tangensButton2" | 451 | id: cotangensButton |
928 | 443 | id: tangensButton2 | 452 | x: (calcGridUnit*13)*7 + calcGridUnit |
929 | 444 | x: (calcGridUnit*13)*6 + calcGridUnit | 453 | y: (calcGridUnit*10)*4 |
930 | 445 | y: (calcGridUnit*10)*3 | 454 | text: "ctg" |
931 | 446 | text: "tan" | 455 | onReleased: formulaPush('atan(') |
470 | 447 | onReleased: { | ||
471 | 448 | formulaPush('tan(') | ||
472 | 449 | hasToAddDot = true | ||
473 | 450 | } | ||
474 | 451 | } | ||
475 | 452 | |||
476 | 453 | KeyboardButton { | ||
477 | 454 | objectName: "cotangensButton2" | ||
478 | 455 | id: cotangensButton2 | ||
479 | 456 | x: (calcGridUnit*13)*7 + calcGridUnit | ||
480 | 457 | y: (calcGridUnit*10)*3 | ||
481 | 458 | text: "ctg" | ||
482 | 459 | onReleased: { | ||
483 | 460 | formulaPush('atan(') | ||
484 | 461 | hasToAddDot = true | ||
485 | 462 | } | ||
486 | 463 | } | ||
487 | 464 | |||
488 | 465 | KeyboardButton { | ||
489 | 466 | objectName: "zeroButton" | ||
490 | 467 | id: zeroButton | ||
491 | 468 | x: 0 | ||
492 | 469 | y: (calcGridUnit*10)*4 | ||
493 | 470 | width: (calcGridUnit*12)*2+calcGridUnit | ||
494 | 471 | text: Number(0).toLocaleString(Qt.locale(), "f", 0) | ||
495 | 472 | onReleased: { | ||
496 | 473 | formulaPush(text); | ||
497 | 474 | } | ||
498 | 475 | } | ||
499 | 476 | |||
500 | 477 | KeyboardButton { | ||
501 | 478 | objectName: "pointButton" | ||
502 | 479 | id: pointButton | ||
503 | 480 | x: (calcGridUnit*13)*2 | ||
504 | 481 | y: (calcGridUnit*10)*4 | ||
505 | 482 | text: '.' | ||
506 | 483 | } | ||
507 | 484 | |||
508 | 485 | KeyboardButton { | ||
509 | 486 | objectName: "sinusButton" | ||
510 | 487 | id: sinusButton | ||
511 | 488 | x: (calcGridUnit*13)*4 + calcGridUnit | ||
512 | 489 | y: (calcGridUnit*10)*4 | ||
513 | 490 | text: "sin" | ||
514 | 491 | onReleased: { | ||
515 | 492 | formulaPush('sin(') | ||
516 | 493 | } | ||
517 | 494 | } | ||
518 | 495 | |||
519 | 496 | KeyboardButton { | ||
520 | 497 | objectName: "cosinusButton" | ||
521 | 498 | id: cosinusButton | ||
522 | 499 | x: (calcGridUnit*13)*5 + calcGridUnit | ||
523 | 500 | y: (calcGridUnit*10)*4 | ||
524 | 501 | text: "cos" | ||
525 | 502 | onReleased: { | ||
526 | 503 | formulaPush('cos(') | ||
527 | 504 | } | ||
528 | 505 | } | ||
529 | 506 | |||
530 | 507 | KeyboardButton { | ||
531 | 508 | objectName: "tangensButton" | ||
532 | 509 | id: tangensButton | ||
533 | 510 | x: (calcGridUnit*13)*6 + calcGridUnit | ||
534 | 511 | y: (calcGridUnit*10)*4 | ||
535 | 512 | text: "tan" | ||
536 | 513 | onReleased: { | ||
537 | 514 | formulaPush('tan(') | ||
538 | 515 | } | ||
539 | 516 | } | ||
540 | 517 | |||
541 | 518 | KeyboardButton { | ||
542 | 519 | objectName: "cotangensButton" | ||
543 | 520 | id: cotangensButton | ||
544 | 521 | x: (calcGridUnit*13)*7 + calcGridUnit | ||
545 | 522 | y: (calcGridUnit*10)*4 | ||
546 | 523 | text: "ctg" | ||
547 | 524 | onReleased: { | ||
548 | 525 | formulaPush('atan(') | ||
932 | 526 | } | 456 | } |
933 | 527 | } | 457 | } |
934 | 528 | } | 458 | } |
Looks ok