hfdialer has been made a singleton and will only start one
[profile/ivi/hfdialer.git] / qml / CallItemViewLarge.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 import 'javascripts/framework.js' as Support
12
13 Item
14 {
15     id: root
16
17     anchors.fill: parent
18
19     property variant call  
20     property string  callDuration: "00:00:00"
21     property string  callerLabelText: "Unknown Caller"
22     state : 'disconnected'
23
24     onCallChanged: {
25      console.log("*** call changed in large, before if")   
26      if(call && call.msisdn) {
27             console.log("*** in calllarge if >> " + call.state );
28             
29             root.state = call.state
30
31             if (call.name) {
32                 root.callerLabelText = call.name;
33
34             } else {
35
36                 if (call.numberLen <= 10)
37                 {
38                   root.callerLabelText = call.msisdn[0] + call.msisdn[1] + call.msisdn[2] + '-' +
39                                          call.msisdn[3] + call.msisdn[4] + call.msisdn[5] + '-' +
40                                          call.msisdn[6] + call.msisdn[7] + call.msisdn[8] + call.msisdn[9];
41                 }
42                 else
43                   root.callerLabelText = call.msisdn;
44             }
45         }
46     }
47
48     Timer {
49         interval: 1000; repeat: true; running: true;
50
51         onTriggered: {
52             if(call) {
53                 if(call.duration && call.duration > 0)
54                 {
55                     callDuration = Support.friendlyInterval(call.duration);
56                 }
57             }
58         }
59     }
60
61     states {
62         State {
63             name: 'active'           
64             PropertyChanges {target: root; callDuration: "00:00:00"}
65             PropertyChanges {target: answerButton; visible: false}
66             PropertyChanges {target: hangupButton; visible: true; width: parent.width}
67             PropertyChanges {target: stateInd; text: qsTr("Active")}
68         }
69
70         State {
71             name: 'held'          
72             PropertyChanges {target: answerButton; visible: false}
73             PropertyChanges {target: hangupButton; visible: true; width: parent.width}
74             PropertyChanges {target: stateInd; text: qsTr("Held")}
75         }
76
77         State {
78             name: 'dialing'           
79             PropertyChanges {target: root; callDuration: "00:00:00"}
80             PropertyChanges {target: answerButton; visible: false}
81             PropertyChanges {target: hangupButton; visible: true; width: parent.width}
82             PropertyChanges {target: stateInd; text: qsTr("Dialing...")}
83         }
84
85         State {
86             name: 'alerting'           
87             PropertyChanges {target: answerButton; visible: false}
88             PropertyChanges {target: hangupButton; visible: true; width: parent.width}
89             PropertyChanges {target: stateInd; text: qsTr("Alerting...")}
90         }
91
92         State {
93             name: 'incoming'            
94             PropertyChanges {target: root; callDuration: "00:00:00"}
95             PropertyChanges {target: answerButton; visible: true}
96             PropertyChanges {target: hangupButton; visible: true; width: parent.width * 0.45}
97             PropertyChanges {target: stateInd; text: qsTr("Incoming...")}
98         }
99
100         State {
101             name: 'waiting'            
102             PropertyChanges {target: answerButton; visible: false}
103             PropertyChanges {target: hangupButton; visible: true; width: parent.width}
104             PropertyChanges {target: stateInd; text: qsTr("Waiting...")}
105         }
106
107         State {
108             name: 'disconnected'    
109             PropertyChanges {target: callDurationInd; text: "00:00:00"}        
110             PropertyChanges {target: answerButton; visible: false}
111             PropertyChanges {target: hangupButton; visible: false}
112             PropertyChanges {target: stateInd; text: qsTr("Disconnected")}
113         }
114     }
115
116     Text
117     {
118         id: stateInd
119         anchors {top: parent.top; topMargin: 20; horizontalCenter: parent.horizontalCenter}
120         color: '#ffffff'
121         font {pixelSize: 38}
122         text: qsTr("Disconnected")
123     }
124
125     Text
126     {
127         id: callerInd
128         anchors {top: stateInd.bottom; topMargin: 20; horizontalCenter: parent.horizontalCenter}
129         color: '#ffffff'
130         font {pixelSize: 75}
131         text: callerLabelText
132     }
133     
134     Image
135     {
136         id: clock
137         source: "/usr/share/hfdialer/images/ivi_icon-time.png"
138         anchors { right: callDurationInd.left; rightMargin: 2; bottom: callerInd.top}
139         width: 25
140         height: 25
141         smooth: true
142     }
143     
144     Text
145     {
146         id: callDurationInd
147         anchors {bottom: callerInd.top; right: parent.right; topMargin: 10; rightMargin: parent.width * 0.2}
148         font {pixelSize: 22}
149         color: '#dfdfdf'
150         text: callDuration
151     }
152
153     Item
154     {
155         id: buttons
156         anchors {top: callerInd.bottom; topMargin: 15; left: parent.left; leftMargin: parent.width * 0.2; right: parent.right; rightMargin: parent.width * 0.2}
157         
158         width: parent.width * 0.75
159         height: 72
160
161         Image
162         {
163             id: answerButton
164             height: 72
165             width: parent.width *0.45
166             anchors {left: parent.left;}
167             source: "/usr/share/hfdialer/images/ivi_btn-incomingcall-accept.png"
168             
169             Image
170             {
171                 width: 40; height: width
172                 anchors.centerIn: parent
173                 smooth: true
174                 source: "/usr/share/hfdialer/images/ivi_icon-call.png"
175             }
176
177             MouseArea
178             {
179                 anchors.fill: parent
180
181                 onPressed: {
182                     answerButton.source = "/usr/share/hfdialer/images/ivi_btn-incomingcall-accept-active.png"
183                 }
184
185                 onReleased: {
186                     answerButton.source = "/usr/share/hfdialer/images/ivi_btn-incomingcall-accept.png"
187                 }
188
189                 onClicked: {
190                     console.log("*** QML *** :: Answering call");
191                     adapter.currentCall.answer();
192                 }
193             }
194         }
195
196         Image
197         {
198             id: hangupButton
199             height: 72
200             width: parent.width * 0.45
201             anchors {right: parent.right;}
202             source: "/usr/share/hfdialer/images/ivi_btn-incomingcall-decline.png"
203
204             Image
205             {
206                 width: 40; height: width
207                 anchors.centerIn: parent
208                 smooth: true
209                 source: "/usr/share/hfdialer/images/ivi_icon-endcall.png"
210             }
211
212             MouseArea
213             {
214                 anchors.fill: parent
215
216                 onPressed: {
217                     hangupButton.source = "/usr/share/hfdialer/images/ivi_btn-incomingcall-decline-active.png"
218                 }
219
220                 onReleased: {
221                     hangupButton.source = "/usr/share/hfdialer/images/ivi_btn-incomingcall-decline.png"
222                 }
223
224                 onClicked: {
225                     console.log("*** QML *** :: Hanging up call");
226                     root.parent.state = 'disconnected'
227                     adapter.hangupAll();
228                     root.state = 'disconnected'
229                     root.parent.parent.state = 'disconnected'
230                     if (root.parent.parent.call)
231                         root.parent.parent.call = null
232                     if (root.call)
233                         root.call = null
234                 }
235             }
236         }
237     }
238 }
239