2 * Copyright (C) 2016 The Qt Company Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 import QtQuick.Layouts 1.1
19 import QtQuick.Controls 2.0
20 import QtMultimedia 5.5
21 import AGL.Demo.Controls 1.0
29 return new Date().getTime()
32 // Elapsed time in hh:mm:ss format
33 function getElapsedTimeString(startTime) {
34 var seconds = Math.floor((getTime() - startTime) / 1000);
35 var time = new Date(null);
36 time.setSeconds(seconds);
37 return time.toISOString().substr(11, 8);
44 property var startTime
45 onTriggered: callStatusLabel.text = getElapsedTimeString(startTime)
51 property string callStatus: "disconnected"
52 property string callClipColp: ""
54 onCallStatusChanged: {
55 if (callStatus == "incoming") {
56 soundmgr.connect("calling")
57 //ringtone.active = true
58 //rejectButton.active = true
59 //callStatusLabel.text = "Incoming call from " + callClipColp
60 } else if (callStatus == "dialing") {
61 callStatusLabel.text = "Dialing " + callClipColp
62 } else if (callStatus == "active") {
63 rejectButton.active = false
64 callTimer.startTime = getTime()
66 } else if (callStatus == "disconnected") {
67 ringtone.active = false
68 rejectButton.active = false
69 callButton.checked = false
71 callStatusLabel.text = ""
76 API.BindingSoundManager {
79 console.log("Sound Right Approved")
80 switch(telephony.callStatus){
84 telephony.dial(number.text)
85 break; // WARNING! these cases are not tested excluding incomming
87 ringtone.active = true
88 rejectButton.active = true
89 callStatusLabel.text = "Incoming call from " + telephony.callClipColp
97 console.log("Sound Right Denyed due to emergency")
100 console.log("paused") // this doesn't come maybe
107 sourceComponent: Component {
109 loops: SoundEffect.Infinite
110 source: './Phone.wav'
112 Component.onCompleted: play()
118 function call(contact) {
119 name.text = contact.name
120 number.text = contact.number
121 callButton.checked = true
125 anchors.left: parent.left
126 anchors.top: parent.top
130 offImage: './images/HMI_Phone_Contacts-01.svg'
131 onClicked: root.showContacts()
136 anchors.topMargin: 50
137 anchors.bottomMargin: 50
140 Layout.alignment: Qt.AlignHCenter
151 anchors.right: parent.right
152 anchors.verticalCenter: parent.verticalCenter
153 offImage: './images/HMI_Phone_Back_Icon.svg'
155 if (number.text.length > 0)
156 number.text = number.text.substring(0, number.text.length - 1)
163 Layout.alignment: Qt.AlignHCenter
169 ListElement { value: '1'; image: '1' }
170 ListElement { value: '2'; image: '2' }
171 ListElement { value: '3'; image: '3' }
172 ListElement { value: '4'; image: '4' }
173 ListElement { value: '5'; image: '5' }
174 ListElement { value: '6'; image: '6' }
175 ListElement { value: '7'; image: '7' }
176 ListElement { value: '8'; image: '8' }
177 ListElement { value: '9'; image: '9' }
178 ListElement { value: '*'; image: 'asterisk' }
179 ListElement { value: '0'; image: '0' }
180 ListElement { value: '#'; image: 'NumberSign' }
183 onImage: './images/HMI_Phone_Button_%1_Active-01.svg'.arg(model.image)
184 offImage: './images/HMI_Phone_Button_%1_Inactive-01.svg'.arg(model.image)
186 number.text += model.value
194 Layout.alignment: Qt.AlignHCenter
200 Layout.alignment: Qt.AlignHCenter
201 onImage: './images/HMI_Phone_Hangup.svg'
202 offImage: './images/HMI_Phone_Call.svg'
203 property var active: (number.text.length > 0) || (telephony.callStatus == "incoming") || (telephony.callStatus == "active")
204 opacity: active ? 1 : 0.25
209 callButton.checked = false
213 var contact = {'name': name.text, 'number': number.text}
214 if (contact.name === '')
215 contact.name = 'Unknown'
216 history.insert(0, contact)
217 if (telephony.callStatus == "incoming") {
219 ringtone.active = false;
222 //telephony.dial(number.text)
228 soundmgr.disconnect()
235 Layout.alignment: Qt.AlignHCenter
237 sourceComponent: ImageButton {
238 offImage: './images/HMI_Phone_Hangup.svg'
241 soundmgr.disconnect()
247 Layout.fillWidth: true
248 Layout.preferredHeight: 130
249 orientation: Qt.Horizontal
251 model: CallHistoryModel { id: history }
253 delegate: MouseArea {
254 width: root.width / 2.5
255 height: ListView.view.height
260 source: './images/HMI_Phone_Contact_BlankPhoto.svg'
264 Layout.fillWidth: true
270 Layout.fillWidth: true
276 onClicked: root.call(model)