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