Add sample qml application
[staging/HomeScreen.git] / sample-qml / imports / components / NumberPad.qml
1 /* Copyright (C) 2015, Jaguar Land Rover. All Rights Reserved.\r
2  *\r
3  * This Source Code Form is subject to the terms of the Mozilla Public\r
4  * License, v. 2.0. If a copy of the MPL was not distributed with this\r
5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\r
6 \r
7 import QtQuick 2.0\r
8 import utils 1.0\r
9 \r
10 Item {\r
11     id: root\r
12     height: childrenRect.height\r
13     property var letters: ["","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"]\r
14     property var bottomRow: ["*","0","#"]\r
15 \r
16     signal number(string number)\r
17 \r
18     Grid {\r
19         id: numberGrid\r
20         columns: 3\r
21         spacing: 20\r
22 \r
23         Repeater {\r
24             model: 9\r
25             delegate: Item {\r
26                 id: numberKey\r
27                 width: (root.width - ( numberGrid.spacing*(numberGrid.columns-1)))/numberGrid.columns\r
28                 height: numberKey.width * 0.8\r
29                 anchors.margins: 10\r
30 \r
31                 Rectangle {\r
32                     id: shadowTarget\r
33                     anchors.fill: parent\r
34                     border.width: 1\r
35                     border.color: "white"\r
36                     color: "#6653b5ce"\r
37                 }\r
38 \r
39                 Item {\r
40                     height: childrenRect.height\r
41                     width: parent.width\r
42                     anchors.centerIn: parent\r
43 \r
44                     Label {\r
45                         anchors.horizontalCenter: parent.horizontalCenter\r
46                         id: keypadNumber\r
47                         text: index + 1\r
48                     }\r
49 \r
50                     Label {\r
51                         anchors.horizontalCenter: parent.horizontalCenter\r
52                         id: keypadLetters\r
53                         anchors.top: keypadNumber.bottom\r
54                         fontSize: 30\r
55                         fontColor: "#53b5ce"\r
56                         text: letters[index]\r
57                     }\r
58                 }\r
59 \r
60                 MouseArea {\r
61                     anchors.fill: parent\r
62                     onClicked: root.number(keypadNumber.text)\r
63                 }\r
64             }\r
65         }\r
66 \r
67         Repeater {\r
68             model: 3\r
69             delegate: Item {\r
70                 width: (root.width - ( numberGrid.spacing*(numberGrid.columns-1)))/numberGrid.columns\r
71                 height: width * 0.8\r
72                 anchors.margins: 10\r
73 \r
74                 Rectangle {\r
75                     id: shadowTarget\r
76                     anchors.fill: parent\r
77                     border.width: 1\r
78                     border.color: "white"\r
79                     color: "#6653b5ce"\r
80                 }\r
81 \r
82                 Item {\r
83                     height: childrenRect.height\r
84                     width: parent.width\r
85                     anchors.centerIn: parent\r
86 \r
87                     Label {\r
88                         anchors.horizontalCenter: parent.horizontalCenter\r
89                         id: keypadNumber\r
90                         text: bottomRow[index]\r
91                     }\r
92                 }\r
93 \r
94                 MouseArea {\r
95                     anchors.fill: parent\r
96                     onClicked: root.number(keypadNumber.text)\r
97                 }\r
98             }\r
99         }\r
100     }\r
101 }\r