1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the QtDeclarative module of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
43 import QtQuick.Window 2.0
44 import "CalculatorCore"
45 import "CalculatorCore/calculator.js" as CalcEngine
50 width: 320; height: 480
53 property string rotateLeft: "\u2939"
54 property string rotateRight: "\u2935"
55 property string leftArrow: "\u2190"
56 property string division : "\u00f7"
57 property string multiplication : "\u00d7"
58 property string squareRoot : "\u221a"
59 property string plusminus : "\u00b1"
61 function doOp(operation) { CalcEngine.doOperation(operation) }
65 state: "orientation " + Screen.orientation
67 //Note: Assumes a primarily portrait device
68 property bool landscapeWindow: window.width > window.height
69 property real baseWidth: landscapeWindow ? window.height : window.width
70 property real baseHeight: landscapeWindow ? window.width : window.height
71 property real rotationDelta: landscapeWindow ? -90 : 0
73 rotation: rotationDelta
75 height: main.baseHeight
76 anchors.centerIn: parent
81 anchors { fill: parent; topMargin: 6; bottomMargin: 6; leftMargin: 6; rightMargin: 6 }
90 id: column; spacing: 6
92 property real h: ((box.height - 72) / 6) - ((spacing * (6 - 1)) / 6)
93 property real w: (box.width / 4) - ((spacing * (4 - 1)) / 4)
97 Button { width: column.w; height: column.h; color: 'purple'; operation: "Off" }
98 Button { width: column.w; height: column.h; color: 'purple'; operation: leftArrow }
99 Button { width: column.w; height: column.h; color: 'purple'; operation: "C" }
100 Button { width: column.w; height: column.h; color: 'purple'; operation: "AC" }
105 property real w: (box.width / 4) - ((spacing * (4 - 1)) / 4)
107 Button { width: column.w; height: column.h; color: 'green'; operation: "mc" }
108 Button { width: column.w; height: column.h; color: 'green'; operation: "m+" }
109 Button { width: column.w; height: column.h; color: 'green'; operation: "m-" }
110 Button { width: column.w; height: column.h; color: 'green'; operation: "mr" }
114 id: grid; rows: 5; columns: 5; spacing: 6
116 property real w: (box.width / columns) - ((spacing * (columns - 1)) / columns)
118 Button { width: grid.w; height: column.h; operation: "7"; color: 'blue' }
119 Button { width: grid.w; height: column.h; operation: "8"; color: 'blue' }
120 Button { width: grid.w; height: column.h; operation: "9"; color: 'blue' }
121 Button { width: grid.w; height: column.h; operation: division }
122 Button { width: grid.w; height: column.h; operation: squareRoot }
123 Button { width: grid.w; height: column.h; operation: "4"; color: 'blue' }
124 Button { width: grid.w; height: column.h; operation: "5"; color: 'blue' }
125 Button { width: grid.w; height: column.h; operation: "6"; color: 'blue' }
126 Button { width: grid.w; height: column.h; operation: multiplication }
127 Button { width: grid.w; height: column.h; operation: "x^2" }
128 Button { width: grid.w; height: column.h; operation: "1"; color: 'blue' }
129 Button { width: grid.w; height: column.h; operation: "2"; color: 'blue' }
130 Button { width: grid.w; height: column.h; operation: "3"; color: 'blue' }
131 Button { width: grid.w; height: column.h; operation: "-" }
132 Button { width: grid.w; height: column.h; operation: "1/x" }
133 Button { width: grid.w; height: column.h; operation: "0"; color: 'blue' }
134 Button { width: grid.w; height: column.h; operation: "." }
135 Button { width: grid.w; height: column.h; operation: plusminus }
136 Button { width: grid.w; height: column.h; operation: "+" }
137 Button { width: grid.w; height: column.h; operation: "="; color: 'red' }
144 name: "orientation " + Qt.LandscapeOrientation
145 PropertyChanges { target: main; rotation: 90 + rotationDelta; width: main.baseHeight; height: main.baseWidth }
148 name: "orientation " + Qt.InvertedPortraitOrientation
149 PropertyChanges { target: main; rotation: 180 + rotationDelta; }
152 name: "orientation " + Qt.InvertedLandscapeOrientation
153 PropertyChanges { target: main; rotation: 270 + rotationDelta; width: main.baseHeight; height: main.baseWidth }
157 transitions: Transition {
158 SequentialAnimation {
159 RotationAnimation { direction: RotationAnimation.Shortest; duration: 300; easing.type: Easing.InOutQuint }
160 NumberAnimation { properties: "x,y,width,height"; duration: 300; easing.type: Easing.InOutQuint }