initial commit
[profile/ivi/hfdialer.git] / qml / RequestPidCodeDialog.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 Rectangle {
12     id: root
13     anchors.fill: parent
14     color: "#51504F"
15
16     signal replyRequestPidCode(string reply)
17     signal cancelRequest()
18     property string deviceName
19     property string replyValue: legacyPairing ? "0000" : Math.floor(Math.random()*999999)
20     property bool legacyPairing: false
21
22 Column {
23     width: parent.width - 15
24     anchors {centerIn: parent}
25     spacing: 10
26
27     Text {
28         id: textlabel
29         text: qsTr("Enter the following code on %1").arg(deviceName)
30         width: parent.width
31         wrapMode: Text.WordWrap
32         horizontalAlignment: Text.AlignHCenter
33         font.pixelSize: 24
34         color: "white"
35     }
36
37
38
39     Rectangle {
40         id: textInput
41         anchors.horizontalCenter: parent.horizontalCenter
42         height: 40
43         width: parent.width
44         color: "white"
45         radius: 5
46
47         TextEdit {
48             id: textInputField           
49             anchors.centerIn: parent
50             width: parent.width
51             height: parent.height * 0.75
52             font.pixelSize: 24
53             color: "black"
54             text: replyValue
55             horizontalAlignment: Text.AlignHCenter
56         }
57     }
58
59     Row {
60         id: buttonGroup
61         anchors.horizontalCenter: parent.horizontalCenter
62         spacing: 10
63         width: parent.width
64         height: 50
65
66     Image {
67         id: acceptButton
68         source: "/usr/share/hfdialer/images/ivi_btn-incomingcall-accept.png"
69         width: buttonGroup.width / 2 - 5
70         height: parent.height
71
72         MouseArea {
73               anchors.fill: parent
74         onClicked: {
75             console.log(deviceName + " replying with key: " + textInputField.text)
76             replyRequestPidCode(textInputField.text);
77         }
78         }
79
80         Text {
81             id: acceptButtonText
82              text: qsTr("Accept")
83              anchors.centerIn:parent
84              horizontalAlignment: Text.AlignHCenter
85              font.pixelSize: 20
86              color: "white"
87          }
88     }
89
90     Image {
91         id: rejectButton
92         source: "/usr/share/hfdialer/images/ivi_btn-incomingcall-decline.png"
93         width: buttonGroup.width / 2 - 5
94         height: parent.height
95
96         MouseArea {
97               anchors.fill: parent
98         onClicked: {
99             console.log(deviceName + " replying with key: " + textInputField.text)
100             cancelRequest()
101         }
102         }
103
104         Text {
105             id: cancelButtonText
106              text: qsTr("Cancel")
107              anchors.centerIn:parent
108              horizontalAlignment: Text.AlignHCenter
109              font.pixelSize: 20
110              color: "white"
111          }
112     }
113
114
115     }
116
117 }
118     ///we do this because this property is actually set post onCompleted:
119     onLegacyPairingChanged: {
120         console.log("legacy pair? " + legacyPairing)
121         if(!legacyPairing) {
122             replyRequestPidCode(textInputField.text);
123             console.log(deviceName + " replying with key: " + replyValue)
124         }
125     }
126
127 }