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 QtQml 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: 640; 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) }
63 Keys.onPressed: doOp(event.text);
69 anchors.centerIn: parent
74 anchors { fill: parent; topMargin: 6; bottomMargin: 6; leftMargin: 6; rightMargin: 6 }
83 id: column; spacing: 6
85 property real h: ((box.height - 72) / 6) - ((spacing * (6 - 1)) / 6)
86 property real w: (box.width / 4) - ((spacing * (4 - 1)) / 4)
90 Button { width: column.w; height: column.h; color: 'purple'; operation: "Off" }
91 Button { width: column.w; height: column.h; color: 'purple'; operation: leftArrow }
92 Button { width: column.w; height: column.h; color: 'purple'; operation: "C" }
93 Button { width: column.w; height: column.h; color: 'purple'; operation: "AC" }
98 property real w: (box.width / 4) - ((spacing * (4 - 1)) / 4)
100 Button { width: column.w; height: column.h; color: 'green'; operation: "mc" }
101 Button { width: column.w; height: column.h; color: 'green'; operation: "m+" }
102 Button { width: column.w; height: column.h; color: 'green'; operation: "m-" }
103 Button { width: column.w; height: column.h; color: 'green'; operation: "mr" }
107 id: grid; rows: 5; columns: 5; spacing: 6
109 property real w: (box.width / columns) - ((spacing * (columns - 1)) / columns)
111 Button { width: grid.w; height: column.h; operation: "7"; color: 'blue' }
112 Button { width: grid.w; height: column.h; operation: "8"; color: 'blue' }
113 Button { width: grid.w; height: column.h; operation: "9"; color: 'blue' }
114 Button { width: grid.w; height: column.h; operation: division }
115 Button { width: grid.w; height: column.h; operation: squareRoot }
116 Button { width: grid.w; height: column.h; operation: "4"; color: 'blue' }
117 Button { width: grid.w; height: column.h; operation: "5"; color: 'blue' }
118 Button { width: grid.w; height: column.h; operation: "6"; color: 'blue' }
119 Button { width: grid.w; height: column.h; operation: multiplication }
120 Button { width: grid.w; height: column.h; operation: "x^2" }
121 Button { width: grid.w; height: column.h; operation: "1"; color: 'blue' }
122 Button { width: grid.w; height: column.h; operation: "2"; color: 'blue' }
123 Button { width: grid.w; height: column.h; operation: "3"; color: 'blue' }
124 Button { width: grid.w; height: column.h; operation: "-" }
125 Button { width: grid.w; height: column.h; operation: "1/x" }
126 Button { width: grid.w; height: column.h; operation: "0"; color: 'blue' }
127 Button { width: grid.w; height: column.h; operation: "." }
128 Button { width: grid.w; height: column.h; operation: plusminus }
129 Button { width: grid.w; height: column.h; operation: "+" }
130 Button { width: grid.w; height: column.h; operation: "="; color: 'red' }