1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the QtDeclarative module of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
44 import "Core/calculator.js" as CalcEngine
49 width: 360; height: 480
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"
60 function doOp(operation) { CalcEngine.doOperation(operation) }
64 state: "orientation " + runtime.orientation
66 property bool landscapeWindow: window.width > window.height
67 property real baseWidth: landscapeWindow ? window.height : window.width
68 property real baseHeight: landscapeWindow ? window.width : window.height
69 property real rotationDelta: landscapeWindow ? -90 : 0
71 rotation: rotationDelta
73 height: main.baseHeight
74 anchors.centerIn: parent
79 anchors { fill: parent; topMargin: 6; bottomMargin: 6; leftMargin: 6; rightMargin: 6 }
88 id: column; spacing: 6
90 property real h: ((box.height - 72) / 6) - ((spacing * (6 - 1)) / 6)
91 property real w: (box.width / 4) - ((spacing * (4 - 1)) / 4)
95 Button { width: column.w; height: column.h; color: 'purple'; operation: "Off" }
96 Button { width: column.w; height: column.h; color: 'purple'; operation: leftArrow }
97 Button { width: column.w; height: column.h; color: 'purple'; operation: "C" }
98 Button { width: column.w; height: column.h; color: 'purple'; operation: "AC" }
103 property real w: (box.width / 4) - ((spacing * (4 - 1)) / 4)
105 Button { width: column.w; height: column.h; color: 'green'; operation: "mc" }
106 Button { width: column.w; height: column.h; color: 'green'; operation: "m+" }
107 Button { width: column.w; height: column.h; color: 'green'; operation: "m-" }
108 Button { width: column.w; height: column.h; color: 'green'; operation: "mr" }
112 id: grid; rows: 5; columns: 5; spacing: 6
114 property real w: (box.width / columns) - ((spacing * (columns - 1)) / columns)
116 Button { width: grid.w; height: column.h; operation: "7"; color: 'blue' }
117 Button { width: grid.w; height: column.h; operation: "8"; color: 'blue' }
118 Button { width: grid.w; height: column.h; operation: "9"; color: 'blue' }
119 Button { width: grid.w; height: column.h; operation: division }
120 Button { width: grid.w; height: column.h; operation: squareRoot }
121 Button { width: grid.w; height: column.h; operation: "4"; color: 'blue' }
122 Button { width: grid.w; height: column.h; operation: "5"; color: 'blue' }
123 Button { width: grid.w; height: column.h; operation: "6"; color: 'blue' }
124 Button { width: grid.w; height: column.h; operation: multiplication }
125 Button { width: grid.w; height: column.h; operation: "x^2" }
126 Button { width: grid.w; height: column.h; operation: "1"; color: 'blue' }
127 Button { width: grid.w; height: column.h; operation: "2"; color: 'blue' }
128 Button { width: grid.w; height: column.h; operation: "3"; color: 'blue' }
129 Button { width: grid.w; height: column.h; operation: "-" }
130 Button { width: grid.w; height: column.h; operation: "1/x" }
131 Button { width: grid.w; height: column.h; operation: "0"; color: 'blue' }
132 Button { width: grid.w; height: column.h; operation: "." }
133 Button { width: grid.w; height: column.h; operation: plusminus }
134 Button { width: grid.w; height: column.h; operation: "+" }
135 Button { width: grid.w; height: column.h; operation: "="; color: 'red' }
142 name: "orientation " + Orientation.Landscape
143 PropertyChanges { target: main; rotation: 90 + rotationDelta; width: main.baseHeight; height: main.baseWidth }
146 name: "orientation " + Orientation.PortraitInverted
147 PropertyChanges { target: main; rotation: 180 + rotationDelta; }
150 name: "orientation " + Orientation.LandscapeInverted
151 PropertyChanges { target: main; rotation: 270 + rotationDelta; width: main.baseHeight; height: main.baseWidth }
155 transitions: Transition {
156 SequentialAnimation {
157 RotationAnimation { direction: RotationAnimation.Shortest; duration: 300; easing.type: Easing.InOutQuint }
158 NumberAnimation { properties: "x,y,width,height"; duration: 300; easing.type: Easing.InOutQuint }