a4d8b68c039898ee8c9aa57b6d0141f0192c8c0b
[profile/ivi/hfdialer.git] / qml / DialNumPad.qml
1 /*
2  * Copyright 2012 Intel Corporation.
3  *
4  * This program is licensed under the terms and conditions of the
5  * Apache License, version 2.0.  The full text of the Apache License is at
6  * http://www.apache.org/licenses/LICENSE-2.0
7  */
8
9 import Qt 4.7
10
11 Item
12 {
13     id: root
14
15     property bool numPadShown: true
16     property DialNumberEntry entry
17     property TextInput pidEdit
18     property bool pidRequest: false
19
20     height: parent.height
21     property real buttonHeight: (parent.height / 5) - 41;
22
23     function insertText(text)
24     {
25         if (!pidRequest)
26             entry.appendChar(text)
27         else if (text != "*" && text != "#")
28         {
29             pidEdit.text += text
30         }
31     }
32
33     Image
34     {
35         id: numpad
36         width: parent.width; height: childrenRect.height + 21;
37         source: "/usr/share/hfdialer/images/ivi_buttonarea.png"
38         Behavior on opacity {PropertyAnimation {duration: 500}}
39
40         Column
41         {
42             id: columnBox
43             anchors {top: parent.top; right: parent.right; left: parent.left; margins: 11}
44             spacing: 5
45
46             Row
47             {
48                 width: parent.width
49                 anchors {bottomMargin: 5}
50                 spacing: 5
51
52                 DialNumPadButton {
53                     id: dial1
54                     text: qsTr("1");
55                     height: buttonHeight;
56                     onClicked: root.insertText(text);
57                     onPressAndHold: main.dialMailbox();
58                 }
59                 DialNumPadButton {
60                     text: qsTr("2");
61                     height: buttonHeight;
62                     detail: qsTr("abc");
63                     onClicked: root.insertText(text);
64                     onPressAndHold: main.dialSpeedDial(1);
65                 }
66                 DialNumPadButton {
67                     text: qsTr("3");
68                     height: buttonHeight;
69                     detail: qsTr("def");
70                     onClicked: root.insertText(text);
71                     onPressAndHold: main.dialSpeedDial(2);
72                 }
73             }
74             Row
75             {
76                 width: parent.width
77                 anchors.horizontalCenter: parent.horizontalCenter
78                 spacing: 5
79                 DialNumPadButton {
80                     text: qsTr("4");
81                     height: buttonHeight;
82                     detail: qsTr("ghi");
83                     onClicked: root.insertText(text);
84                     onPressAndHold: main.dialSpeedDial(3);
85                 }
86                 DialNumPadButton {
87                     text: qsTr("5");
88                     height: buttonHeight;
89                     detail: qsTr("jkl");
90                     onClicked: root.insertText(text);
91                     onPressAndHold: main.dialSpeedDial(4);
92                 }
93                 DialNumPadButton {
94                     text: qsTr("6");
95                     height: buttonHeight;
96                     detail: qsTr("mno");
97                     onClicked: root.insertText(text);
98                     onPressAndHold: main.dialSpeedDial(5);
99                 }
100             }
101             Row
102             {
103                 width: parent.width
104                 anchors.horizontalCenter: parent.horizontalCenter
105                 spacing: 5
106                 DialNumPadButton {
107                     text: qsTr("7");
108                     height: buttonHeight;
109                     detail: qsTr("pqrs");
110                     onClicked: root.insertText(text);
111                     onPressAndHold: main.dialSpeedDial(6);
112                 }
113                 DialNumPadButton {
114                     text: qsTr("8");
115                     height: buttonHeight;
116                     detail: qsTr("tuv");
117                     onClicked: root.insertText(text);
118                     onPressAndHold: main.dialSpeedDial(7);
119                 }
120                 DialNumPadButton {
121                     text: qsTr("9");
122                     height: buttonHeight;
123                     detail: qsTr("wxyz");
124                     onClicked: root.insertText(text);
125                     onPressAndHold: main.dialSpeedDial(8);
126                 }
127             }
128             Row
129             {
130                 width: parent.width
131                 anchors.horizontalCenter: parent.horizontalCenter
132                 spacing: 5
133                 DialNumPadButton {
134                     text: qsTr("*");
135                     height: buttonHeight;
136                     onClicked: root.insertText(text);
137                     onPressAndHold: root.insertText("p");
138                 }
139                 DialNumPadButton {
140                     text: qsTr("0");
141                     height: buttonHeight;
142                     detail: qsTr("+");
143                     onClicked: root.insertText(text);
144                     onPressAndHold: root.insertText("+");
145                 }
146                 DialNumPadButton {
147                     text: qsTr("#");
148                     height: buttonHeight;
149                     onClicked: root.insertText(text);
150                     onPressAndHold: root.insertText("w");
151                 }
152             }
153
154
155
156             Row
157             {
158                 id: actions
159                 width: parent.width; height: dial1.height
160
161                 spacing: 5
162                 Image {
163                     id: bDelete;
164                     width: parent.width / 4; height: parent.height
165                     source: "/usr/share/hfdialer/images/ivi_btn-delete.png"
166                     Image {
167                         anchors{ left: bDelete.left}
168                         height: parent.height
169                         width: parent.width
170                         source: "/usr/share/hfdialer/images/ivi_icon-delete.png"
171                         fillMode: Image.PreserveAspectFit
172                     }
173                     MouseArea
174                     {
175                         anchors.fill: parent
176                         onClicked:
177                         {
178                             if (!pidRequest){
179
180                                 if(entry.textInput.text == entry.placeHolderText)
181                                     return;
182
183                                 entry.textInput.text = entry.textInput.text.substring(0, entry.textInput.text.length -1);
184                             }
185                             else
186                                 pidEdit.text = pidEdit.text.substring(0, pidEdit.text.length -1);
187                         }
188
189                         onPressAndHold:
190                         {
191                             if (!pidRequest)
192                                 entry.clear();
193                             else
194                                 pidEdit.text = "";
195                         }
196                     }
197                 }
198
199                 Image {
200                     id: bCall;
201
202                     height: parent.height
203                     width: parent.width - bDelete.width - closeButton.width - 5
204                     source: "/usr/share/hfdialer/images/ivi_btn-call.png"
205
206                     Image {
207                         anchors { centerIn: parent}
208                         height: parent.height
209                         width: parent.width
210                         source: "/usr/share/hfdialer/images/ivi_icon-call.png"
211                         fillMode: Image.PreserveAspectFit
212                     }
213
214                     MouseArea{
215                         anchors.fill: parent
216                         onClicked: {
217                             if (!pidRequest)
218                             {
219                                 if(entry.isBlank())
220                                 {
221                                     console.log("*** QML *** :: You can not dial without a number!");
222                                     main.showErrorMessage(qsTr("You can't dial without a number!"));
223                                     return;
224                                 }
225
226                                 if(main.dial(entry.textInput.text))
227                                 {
228                                     entry.clear();
229                                 }
230                             }
231                         }
232                     }
233                 }
234
235                 Image
236                 {
237                     id: closeButton
238                     source: "/usr/share/hfdialer/images/ivi_btn-close.png"
239                     height: parent.height   
240                     width: (parent.width / 7) - 5
241
242                     MouseArea {
243                         id: closeArea
244                           anchors.fill: parent
245
246                     onClicked: {
247                         console.log("CLOSE BUTTON CLICKED")
248
249                         Qt.quit()
250                         }
251                     }
252                 }
253             }
254         }
255     }
256 }