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