|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the QtDeclarative module of the Qt Toolkit. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 import Qt 4.7 |
|
43 import "Core" |
|
44 import "Core/calculator.js" as CalcEngine |
|
45 |
|
46 Rectangle { |
|
47 id: window |
|
48 |
|
49 width: 480; height: 360 |
|
50 color: "#282828" |
|
51 |
|
52 property string rotateLeft: "\u2939" |
|
53 property string rotateRight: "\u2935" |
|
54 property string leftArrow: "\u2190" |
|
55 property string division : "\u00f7" |
|
56 property string multiplication : "\u00d7" |
|
57 property string squareRoot : "\u221a" |
|
58 property string plusminus : "\u00b1" |
|
59 |
|
60 function doOp(operation) { CalcEngine.doOperation(operation) } |
|
61 |
|
62 Item { |
|
63 id: main |
|
64 state: (runtime.orientation == Orientation.Portrait) ? '' : 'rotated' |
|
65 width: parent.width; height: parent.height; anchors.centerIn: parent |
|
66 |
|
67 Column { |
|
68 id: box; spacing: 8 |
|
69 |
|
70 anchors { fill: parent; topMargin: 6; bottomMargin: 6; leftMargin: 6; rightMargin: 6 } |
|
71 |
|
72 Row { |
|
73 Display { id: display; width: box.width; height: 64 } |
|
74 } |
|
75 |
|
76 Column { |
|
77 id: column; spacing: 6 |
|
78 |
|
79 property real h: ((box.height - 72) / 6) - ((spacing * (6 - 1)) / 6) |
|
80 property real w: (box.width / 4) - ((spacing * (4 - 1)) / 4) |
|
81 |
|
82 Row { |
|
83 spacing: 6 |
|
84 |
|
85 Button { |
|
86 id: rotateButton |
|
87 width: column.w; height: column.h; color: 'purple'; operation: rotateLeft |
|
88 } |
|
89 Button { width: column.w; height: column.h; color: 'purple'; operation: leftArrow } |
|
90 Button { width: column.w; height: column.h; color: 'purple'; operation: "C" } |
|
91 Button { width: column.w; height: column.h; color: 'purple'; operation: "AC" } |
|
92 } |
|
93 |
|
94 Row { |
|
95 spacing: 6 |
|
96 property real w: (box.width / 4) - ((spacing * (4 - 1)) / 4) |
|
97 |
|
98 Button { width: column.w; height: column.h; color: 'green'; operation: "mc" } |
|
99 Button { width: column.w; height: column.h; color: 'green'; operation: "m+" } |
|
100 Button { width: column.w; height: column.h; color: 'green'; operation: "m-" } |
|
101 Button { width: column.w; height: column.h; color: 'green'; operation: "mr" } |
|
102 } |
|
103 |
|
104 Grid { |
|
105 id: grid; rows: 4; columns: 5; spacing: 6 |
|
106 |
|
107 property real w: (box.width / columns) - ((spacing * (columns - 1)) / columns) |
|
108 |
|
109 Button { width: grid.w; height: column.h; operation: "7"; color: 'blue' } |
|
110 Button { width: grid.w; height: column.h; operation: "8"; color: 'blue' } |
|
111 Button { width: grid.w; height: column.h; operation: "9"; color: 'blue' } |
|
112 Button { width: grid.w; height: column.h; operation: division } |
|
113 Button { width: grid.w; height: column.h; operation: squareRoot } |
|
114 Button { width: grid.w; height: column.h; operation: "4"; color: 'blue' } |
|
115 Button { width: grid.w; height: column.h; operation: "5"; color: 'blue' } |
|
116 Button { width: grid.w; height: column.h; operation: "6"; color: 'blue' } |
|
117 Button { width: grid.w; height: column.h; operation: multiplication } |
|
118 Button { width: grid.w; height: column.h; operation: "x^2" } |
|
119 Button { width: grid.w; height: column.h; operation: "1"; color: 'blue' } |
|
120 Button { width: grid.w; height: column.h; operation: "2"; color: 'blue' } |
|
121 Button { width: grid.w; height: column.h; operation: "3"; color: 'blue' } |
|
122 Button { width: grid.w; height: column.h; operation: "-" } |
|
123 Button { width: grid.w; height: column.h; operation: "1/x" } |
|
124 Button { width: grid.w; height: column.h; operation: "0"; color: 'blue' } |
|
125 Button { width: grid.w; height: column.h; operation: "." } |
|
126 Button { width: grid.w; height: column.h; operation: plusminus } |
|
127 Button { width: grid.w; height: column.h; operation: "+" } |
|
128 Button { width: grid.w; height: column.h; operation: "="; color: 'red' } |
|
129 } |
|
130 } |
|
131 } |
|
132 |
|
133 states: State { |
|
134 name: 'rotated' |
|
135 PropertyChanges { target: main; rotation: -90; width: window.height; height: window.width } |
|
136 PropertyChanges { target: rotateButton; operation: rotateRight } |
|
137 } |
|
138 |
|
139 transitions: Transition { |
|
140 SequentialAnimation { |
|
141 PropertyAction { target: rotateButton; property: "operation" } |
|
142 NumberAnimation { properties: "rotation"; duration: 300; easing.type: Easing.InOutQuint } |
|
143 NumberAnimation { properties: "x,y,width,height"; duration: 300; easing.type: Easing.InOutQuint } |
|
144 } |
|
145 } |
|
146 } |
|
147 } |