~ahayzen/ubuntu-calculator-app/autopilot-move-py3

« back to all changes in this revision

Viewing changes to Scientific/StdKeyboard.qml

  • Committer: Riccardo Ferrazzo
  • Date: 2013-03-08 10:02:20 UTC
  • mto: This revision was merged to the branch mainline in revision 20.
  • Revision ID: f.riccardo87@gmail.com-20130308100220-8k6v0ebwyaaglq0t
added some files

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import QtQuick 2.0
 
2
import Ubuntu.Components 0.1
 
3
 
 
4
Item {
 
5
    width: parent.width
 
6
    height: grid.height+units.gu(4)
 
7
 
 
8
    Grid {
 
9
        id: grid
 
10
        columns: Math.floor(parent.width / units.gu(46))
 
11
 
 
12
        anchors{
 
13
            top: parent.top
 
14
            topMargin: units.gu(2)
 
15
            horizontalCenter: parent.horizontalCenter
 
16
        }
 
17
        spacing: units.gu(2)
 
18
        Grid{
 
19
            columns:4
 
20
            spacing: units.gu(2)
 
21
 
 
22
            KeyboardButton {
 
23
                text: "("
 
24
                onClicked: formulaPush('(', '(', 'group')
 
25
            }
 
26
 
 
27
            KeyboardButton {
 
28
                text: ")"
 
29
                onClicked: formulaPush(')', ')', 'group')
 
30
            }
 
31
 
 
32
            KeyboardButton {
 
33
                text: "C"
 
34
                onClicked: {
 
35
                    formulaView.addCurrentToMemory();
 
36
                    formulaReset();
 
37
                }
 
38
            }
 
39
 
 
40
            KeyboardButton {
 
41
                text: "M"
 
42
                onClicked: {
 
43
                    formulaView.addCurrentToMemory();
 
44
                }
 
45
            }
 
46
 
 
47
            KeyboardButton {
 
48
                text: "7"
 
49
                onClicked: formulaPush('7', '7', 'number')
 
50
            }
 
51
 
 
52
            KeyboardButton {
 
53
                text: "8"
 
54
                onClicked: formulaPush('8', '8', 'number')
 
55
            }
 
56
 
 
57
            KeyboardButton {
 
58
                text: "9"
 
59
                onClicked: formulaPush('9', '9', 'number')
 
60
            }
 
61
 
 
62
            KeyboardButton {
 
63
                text: "÷"
 
64
                onClicked: formulaPush('÷', '/', 'operation')
 
65
            }
 
66
 
 
67
            KeyboardButton {
 
68
                text: "4"
 
69
                onClicked: formulaPush('4', '4', 'number')
 
70
            }
 
71
 
 
72
            KeyboardButton {
 
73
                text: "5"
 
74
                onClicked: formulaPush('5', '5', 'number')
 
75
            }
 
76
 
 
77
            KeyboardButton {
 
78
                text: "6"
 
79
                onClicked: formulaPush('6', '6', 'number')
 
80
            }
 
81
 
 
82
            KeyboardButton {
 
83
                text: "×"
 
84
                onClicked: formulaPush('×', '*', 'operation')
 
85
            }
 
86
 
 
87
            KeyboardButton {
 
88
                text: "1"
 
89
                onClicked: formulaPush('1', '1', 'number')
 
90
            }
 
91
 
 
92
            KeyboardButton {
 
93
                text: "2"
 
94
                onClicked: formulaPush('2', '2', 'number')
 
95
            }
 
96
 
 
97
            KeyboardButton {
 
98
                text: "3"
 
99
                onClicked: formulaPush('3', '3', 'number')
 
100
            }
 
101
 
 
102
            KeyboardButton {
 
103
                text: "+"
 
104
                onClicked: formulaPush('+', '+', 'operation')
 
105
            }
 
106
 
 
107
            KeyboardButton {
 
108
                text: "0"
 
109
                onClicked: formulaPush('0', '0', 'number')
 
110
            }
 
111
 
 
112
            KeyboardButton {
 
113
                text: "."
 
114
                onClicked: formulaPush('.', '.', 'real')
 
115
            }
 
116
 
 
117
            KeyboardButton {
 
118
                text: "←"
 
119
                onClicked: formulaPop()
 
120
                onPressAndHold: formulaReset()
 
121
            }
 
122
 
 
123
            KeyboardButton {
 
124
                text: "−"
 
125
                onClicked: formulaPush('−', '-', 'operation')
 
126
            }
 
127
 
 
128
        }
 
129
 
 
130
        Grid{
 
131
            spacing: units.gu(2)
 
132
 
 
133
            KeyboardButton {
 
134
                text: "sin"
 
135
                onClicked: formulaPush('sin', 'sin', 'function')
 
136
            }
 
137
 
 
138
            KeyboardButton {
 
139
                text: "cos"
 
140
                onClicked: formulaPush('cos', 'cos', 'function')
 
141
            }
 
142
 
 
143
            KeyboardButton {
 
144
                text: "tan"
 
145
                onClicked: formulaPush('tan', 'tan', 'function')
 
146
            }
 
147
 
 
148
            KeyboardButton {
 
149
                text: angularUnit
 
150
                onClicked: {
 
151
                    if (angularUnit === 'RAD') {
 
152
                        angularUnit = 'DEG';
 
153
                    }
 
154
                    else if (angularUnit === 'DEG') {
 
155
                        angularUnit = 'GRAD';
 
156
                    }
 
157
                    else if (angularUnit === 'GRAD') {
 
158
                        angularUnit = 'RAD'
 
159
                    }
 
160
                    calculate();
 
161
                }
 
162
            }
 
163
 
 
164
            KeyboardButton {
 
165
                text: "asin"
 
166
                onClicked: formulaPush('asin', 'asin', 'function')
 
167
            }
 
168
 
 
169
            KeyboardButton {
 
170
                text: "acos"
 
171
                onClicked: formulaPush('acos', 'acos', 'function')
 
172
            }
 
173
 
 
174
            KeyboardButton {
 
175
                text: "atan"
 
176
                onClicked: formulaPush('atan', 'atan', 'function')
 
177
            }
 
178
 
 
179
 
 
180
            KeyboardButton {
 
181
                text: "ln"
 
182
                onClicked: formulaPush('ln', 'ln', 'function')
 
183
            }
 
184
 
 
185
            KeyboardButton {
 
186
                text: "√"
 
187
                onClicked: formulaPush('√', '√', 'function')
 
188
            }
 
189
 
 
190
            KeyboardButton {
 
191
                text: "π"
 
192
                onClicked: formulaPush('π', 'π', 'const')
 
193
            }
 
194
 
 
195
            KeyboardButton {
 
196
                text: "e"
 
197
                onClicked: formulaPush('e', 'E', 'const')
 
198
            }
 
199
 
 
200
            KeyboardButton {
 
201
                text: "log"
 
202
                onClicked: formulaPush('log', 'log', 'function')
 
203
            }
 
204
 
 
205
            KeyboardButton {
 
206
                text: "%"
 
207
                onClicked: formulaPush('%', '%', 'operation')
 
208
            }
 
209
 
 
210
            KeyboardButton {
 
211
                text: "!"
 
212
                onClicked: formulaPush('!', '!', 'operation')
 
213
            }
 
214
 
 
215
            KeyboardButton {
 
216
                text: "^"
 
217
                onClicked: formulaPush('^', '^', 'operation')
 
218
            }
 
219
        }
 
220
 
 
221
    }
 
222
}