Fix name of close button image
[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     function show()
34     {
35         height = 72 * 5 + 4;
36         numPadShown = true;
37     }
38
39     function hide()
40     {
41         height = 72;
42         numPadShown = false;
43     }
44
45     function toggle()
46     {
47         if(numPadShown == true) {hide()} else {show()}
48     }
49
50     Behavior on height {PropertyAnimation {duration: 500; easing.type: Easing.OutBounce}}
51
52     Image
53     {
54         id: numpad
55         width: parent.width; height: childrenRect.height + 21;
56         source: "/usr/share/hfdialer/images/ivi_buttonarea.png"
57         Behavior on opacity {PropertyAnimation {duration: 500}}
58
59         Column
60         {
61             id: columnBox
62             anchors {top: parent.top; right: parent.right; left: parent.left; margins: 11}
63             spacing: 5
64
65             Row
66             {
67                 width: parent.width
68                 anchors {bottomMargin: 5}
69                 spacing: 5
70
71                 DialNumPadButton {
72                     id: dial1
73                     text: qsTr("1");
74                     height: buttonHeight;
75                     onClicked: root.insertText(text);
76                     onPressAndHold: main.dialMailbox();
77                 }
78                 DialNumPadButton {
79                     text: qsTr("2");
80                     height: buttonHeight;
81                     detail: qsTr("abc");
82                     onClicked: root.insertText(text);
83                     onPressAndHold: main.dialSpeedDial(1);
84                 }
85                 DialNumPadButton {
86                     text: qsTr("3");
87                     height: buttonHeight;
88                     detail: qsTr("def");
89                     onClicked: root.insertText(text);
90                     onPressAndHold: main.dialSpeedDial(2);
91                 }
92             }
93             Row
94             {
95                 width: parent.width
96                 anchors.horizontalCenter: parent.horizontalCenter
97                 spacing: 5
98                 DialNumPadButton {
99                     text: qsTr("4");
100                     height: buttonHeight;
101                     detail: qsTr("ghi");
102                     onClicked: root.insertText(text);
103                     onPressAndHold: main.dialSpeedDial(3);
104                 }
105                 DialNumPadButton {
106                     text: qsTr("5");
107                     height: buttonHeight;
108                     detail: qsTr("jkl");
109                     onClicked: root.insertText(text);
110                     onPressAndHold: main.dialSpeedDial(4);
111                 }
112                 DialNumPadButton {
113                     text: qsTr("6");
114                     height: buttonHeight;
115                     detail: qsTr("mno");
116                     onClicked: root.insertText(text);
117                     onPressAndHold: main.dialSpeedDial(5);
118                 }
119             }
120             Row
121             {
122                 width: parent.width
123                 anchors.horizontalCenter: parent.horizontalCenter
124                 spacing: 5
125                 DialNumPadButton {
126                     text: qsTr("7");
127                     height: buttonHeight;
128                     detail: qsTr("pqrs");
129                     onClicked: root.insertText(text);
130                     onPressAndHold: main.dialSpeedDial(6);
131                 }
132                 DialNumPadButton {
133                     text: qsTr("8");
134                     height: buttonHeight;
135                     detail: qsTr("tuv");
136                     onClicked: root.insertText(text);
137                     onPressAndHold: main.dialSpeedDial(7);
138                 }
139                 DialNumPadButton {
140                     text: qsTr("9");
141                     height: buttonHeight;
142                     detail: qsTr("wxyz");
143                     onClicked: root.insertText(text);
144                     onPressAndHold: main.dialSpeedDial(8);
145                 }
146             }
147             Row
148             {
149                 width: parent.width
150                 anchors.horizontalCenter: parent.horizontalCenter
151                 spacing: 5
152                 DialNumPadButton {
153                     text: qsTr("*");
154                     height: buttonHeight;
155                     onClicked: root.insertText(text);
156                     onPressAndHold: root.insertText("p");
157                 }
158                 DialNumPadButton {
159                     text: qsTr("0");
160                     height: buttonHeight;
161                     detail: qsTr("+");
162                     onClicked: root.insertText(text);
163                     onPressAndHold: root.insertText("+");
164                 }
165                 DialNumPadButton {
166                     text: qsTr("#");
167                     height: buttonHeight;
168                     onClicked: root.insertText(text);
169                     onPressAndHold: root.insertText("w");
170                 }
171             }
172
173
174
175             Row
176             {
177                 id: actions
178                 width: parent.width; height: dial1.height
179
180                 spacing: 5
181                 Image {
182                     id: bDelete;
183                     width: parent.width / 4; height: parent.height
184                     source: "/usr/share/hfdialer/images/ivi_btn-delete.png"
185                     Image {
186                         anchors{ left: bDelete.left}
187                         height: parent.height
188                         width: parent.width
189                         source: "/usr/share/hfdialer/images/ivi_icon-delete.png"
190                         fillMode: Image.PreserveAspectFit
191                     }
192                     MouseArea
193                     {
194                         anchors.fill: parent
195                         onClicked:
196                         {
197                             if (!pidRequest){
198
199                                 if(entry.textInput.text == entry.placeHolderText)
200                                     return;
201
202                                 entry.textInput.text = entry.textInput.text.substring(0, entry.textInput.text.length -1);
203                             }
204                             else
205                                 pidEdit.text = pidEdit.text.substring(0, pidEdit.text.length -1);
206                         }
207
208                         onPressAndHold:
209                         {
210                             if (!pidRequest)
211                                 entry.clear();
212                             else
213                                 pidEdit.text = "";
214                         }
215                     }
216                 }
217
218                 Image {
219                     id: bCall;
220
221                     height: parent.height
222                     width: parent.width - bDelete.width - closeButton.width - 5
223                     source: "/usr/share/hfdialer/images/ivi_btn-call.png"
224
225                     Image {
226                         anchors { centerIn: parent}
227                         height: parent.height
228                         width: parent.width
229                         source: "/usr/share/hfdialer/images/ivi_icon-call.png"
230                         fillMode: Image.PreserveAspectFit
231                     }
232
233                     MouseArea{
234                         anchors.fill: parent
235                         onClicked: {
236                             if (!pidRequest)
237                             {
238                                 if(entry.isBlank())
239                                 {
240                                     console.log("*** QML *** :: You can not dial without a number!");
241                                     main.showErrorMessage(qsTr("You can't dial without a number!"));
242                                     return;
243                                 }
244
245                                 if(main.dial(entry.textInput.text))
246                                 {
247                                     entry.clear();
248                                 }
249                             }
250                         }
251                     }
252                 }
253
254                 Image
255                 {
256                     id: closeButton
257                     source: "/usr/share/hfdialer/images/ivi_btn-close.png"
258                     //anchors { left: parent.left; top: parent.top;}
259                     height: parent.height   
260                     width: (parent.width / 7) - 5
261
262                     MouseArea {
263                         id: closeArea
264                           anchors.fill: parent
265
266                     onClicked: {
267                         console.log("CLOSE BUTTON CLICKED")
268                         Qt.quit()
269                         }
270                     }
271                 }
272             }
273         }
274     }
275 }