initial commit
[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         
18     height: parent.height
19     property real buttonHeight: (parent.height / 5) - 41;
20
21     function insertText(text)
22     {
23         entry.appendChar(text)
24     }
25
26     function show()
27     {
28         height = 72 * 5 + 4;
29         numPadShown = true;
30     }
31
32     function hide()
33     {
34         height = 72;
35         numPadShown = false;
36     }
37
38     function toggle()
39     {
40         if(numPadShown == true) {hide()} else {show()}
41     }
42
43     Behavior on height {PropertyAnimation {duration: 500; easing.type: Easing.OutBounce}}
44
45     Image
46     {
47         id: numpad
48         width: parent.width; height: childrenRect.height + 21;
49         source: "/usr/share/hfdialer/images/ivi_buttonarea.png"
50         Behavior on opacity {PropertyAnimation {duration: 500}}
51
52         Column
53         {
54            id: columnBox
55            anchors {top: parent.top; right: parent.right; left: parent.left; margins: 11}
56            spacing: 5
57
58             Row
59             {
60                 width: parent.width
61                 anchors {bottomMargin: 5}
62                 spacing: 5
63
64                 DialNumPadButton {
65                     id: dial1
66                     text: qsTr("1");
67                     height: buttonHeight;
68                     onClicked: root.insertText(text);
69                     onPressAndHold: main.dialMailbox();
70                 }
71                 DialNumPadButton {
72                     text: qsTr("2");
73                     height: buttonHeight;               
74                     detail: qsTr("abc");
75                     onClicked: root.insertText(text);
76                     onPressAndHold: main.dialSpeedDial(1);
77                 }
78                 DialNumPadButton {
79                     text: qsTr("3");
80                     height: buttonHeight;               
81                detail: qsTr("def");
82                     onClicked: root.insertText(text);
83                     onPressAndHold: main.dialSpeedDial(2);
84                 }
85             }
86             Row
87             {
88                 width: parent.width
89                 anchors.horizontalCenter: parent.horizontalCenter
90                 spacing: 5
91                 DialNumPadButton {
92                     text: qsTr("4");
93                     height: buttonHeight;
94                     detail: qsTr("ghi");
95                     onClicked: root.insertText(text);
96                     onPressAndHold: main.dialSpeedDial(3);
97                 }
98                 DialNumPadButton {
99                     text: qsTr("5");
100                    height: buttonHeight;
101                    detail: qsTr("jkl");
102                     onClicked: root.insertText(text);
103                     onPressAndHold: main.dialSpeedDial(4);
104                 }
105                 DialNumPadButton {
106                     text: qsTr("6");
107                    height: buttonHeight;
108                    detail: qsTr("mno");
109                     onClicked: root.insertText(text);
110                     onPressAndHold: main.dialSpeedDial(5);
111                 }
112             }
113             Row
114             {
115                 width: parent.width
116                 anchors.horizontalCenter: parent.horizontalCenter
117               spacing: 5
118                   DialNumPadButton {
119                     text: qsTr("7");
120                    height: buttonHeight;
121                    detail: qsTr("pqrs");
122                     onClicked: root.insertText(text);
123                     onPressAndHold: main.dialSpeedDial(6);
124                 }
125                 DialNumPadButton {
126                     text: qsTr("8");
127                    height: buttonHeight;
128                    detail: qsTr("tuv");
129                     onClicked: root.insertText(text);
130                     onPressAndHold: main.dialSpeedDial(7);
131                 }
132                 DialNumPadButton {
133                     text: qsTr("9");
134                   height: buttonHeight;
135                     detail: qsTr("wxyz");
136                     onClicked: root.insertText(text);
137                     onPressAndHold: main.dialSpeedDial(8);
138                 }
139             }
140             Row
141             {
142                 width: parent.width
143                 anchors.horizontalCenter: parent.horizontalCenter
144               spacing: 5
145                   DialNumPadButton {
146                     text: qsTr("*");
147                    height: buttonHeight;
148                    onClicked: root.insertText(text);
149                     onPressAndHold: root.insertText("p");
150                 }
151                 DialNumPadButton {
152                     text: qsTr("0");
153                   height: buttonHeight;
154                     detail: qsTr("+");
155                     onClicked: root.insertText(text);
156                     onPressAndHold: root.insertText("+");
157                 }
158                 DialNumPadButton {
159                     text: qsTr("#");
160                  height: buttonHeight;
161                      onClicked: root.insertText(text);
162                     onPressAndHold: root.insertText("w");
163                 }
164             }
165         
166    
167
168     Row
169     {
170         id: actions
171         width: parent.width; height: dial1.height
172
173         spacing: 5
174             Image {
175                 id: bDelete;               
176                 width: parent.width / 4; height: parent.height
177                 source: "/usr/share/hfdialer/images/ivi_btn-delete.png"
178                 Image { 
179                    anchors{ left: bDelete.left}
180                    height: parent.height
181                    width: parent.width
182                    source: "/usr/share/hfdialer/images/ivi_icon-delete.png"
183                    fillMode: Image.PreserveAspectFit
184                 } 
185                 MouseArea
186                 {
187                    anchors.fill: parent
188                    onClicked: 
189                    {
190                         if(entry.textInput.text == entry.placeHolderText)
191                           return;
192                         
193                         entry.textInput.text = entry.textInput.text.substring(0, entry.textInput.text.length -1);
194                    }
195                  
196                    onPressAndHold: entry.clear();
197
198                 }
199             }
200             
201             Image {
202                 id: bCall;
203
204                 height: parent.height
205                 width: parent.width - bDelete.width - 5 
206                 source: "/usr/share/hfdialer/images/ivi_btn-call.png"
207
208                 Image {
209                   anchors { centerIn: parent}
210                   height: parent.height
211                   width: parent.width
212                   source: "/usr/share/hfdialer/images/ivi_icon-call.png"
213                   fillMode: Image.PreserveAspectFit
214                 }
215
216                 MouseArea{
217                 anchors.fill: parent
218                 onClicked: {
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    }
236 }