update
[apps/onscreenapp.git] / sample / ons / phone.qml
1 import QtQuick 2.6
2 import QtQuick.Window 2.2
3 import QtQuick.Layouts 1.1
4 import QtQuick.Controls 2.0
5 import AGL.Demo.Controls 1.0
6
7 Item {
8     id: onScreenPhone
9     visible: true
10     width: 1079
11     height: 400
12     property string messageText: "Incoming Call"
13
14     function qmlOnScreenParameter(message) {
15         console.log(qsTr('OnScreenApp:QML:Phone >>> qmlOnScreenParameter.'), message);
16         var message_json = JSON.parse (message);
17         var text = message_json.status
18
19         if(text === "incoming call")
20         {
21             messageText = "Incoming Call";
22             answerButton.active = true;
23             answerButton.checked = false;
24         }
25         else if(text === "call answered")
26         {
27             messageText = "Call Answered";
28             answerButton.active = false;
29             answerButton.checked = true;
30         }
31         else if(text === "call rejected")
32         {
33             messageText = "Call Rejected";
34             answerButton.active = false;
35             answerButton.checked = true;
36         }
37         else {
38             messageText = text;
39         }
40     }
41
42     Image {
43         id : background_image
44         anchors.fill: parent
45         anchors.topMargin: 0
46         anchors.bottomMargin: 0
47         source: "images/heart_1079x400.png"
48     }
49
50    ToggleButton {
51        id: answerButton
52        x: 53
53        y: 147
54        width: 228
55        height: 230
56        onImage: 'images/disable.png'
57        offImage: 'images/answer.png'
58        property bool active: true
59
60        onCheckedChanged: {
61            if(!checked && !active) {
62                checked = true;
63            }
64            if(active && checked)
65            {
66                messageText = "Call Answer"
67                eventHandler.onScreenReply("call answer");
68                active = false;
69            }
70        }
71    }
72
73    ImageButton {
74        id: rejectButton
75        x: 804
76        y: 142
77        width: 228
78        height: 230
79        offImage: 'images/reject.png'
80
81        onClicked: {
82            messageText = "Call Reject"
83            eventHandler.onScreenReply("call reject");
84        }
85    }
86
87     Label {
88         x: 400
89         y: 115
90         width: 280
91         height: 100
92         color: "#000000"
93         text: messageText
94         textFormat: Text.AutoText
95         wrapMode: Text.WordWrap
96         verticalAlignment: Text.AlignVCenter
97         horizontalAlignment: Text.AlignHCenter
98         font.pixelSize: 50
99         font.weight: Font.ExtraBold
100     }
101
102     Label {
103         x: 395
104         y: 112
105         width: 280
106         height: 100
107         color: "#6BFBFF"
108         text: messageText
109         textFormat: Text.AutoText
110         wrapMode: Text.WordWrap
111         verticalAlignment: Text.AlignVCenter
112         horizontalAlignment: Text.AlignHCenter
113         font.pixelSize: 50
114         font.weight: Font.DemiBold
115     }
116
117 }