hfdialer has been made a singleton and will only start one
[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     Component.onCompleted: {
23         numPad.pidRequest = true
24         numPad.pidEdit = textInputField
25     }
26
27     Column {
28         width: parent.width - 15
29         anchors {centerIn: parent}
30         spacing: 10
31
32         Text {
33             id: textlabel
34             text: qsTr("Enter the following code on %1").arg(deviceName)
35             width: parent.width
36             wrapMode: Text.WordWrap
37             horizontalAlignment: Text.AlignHCenter
38             font.pixelSize: 24
39             color: "white"
40         }
41
42         Rectangle {
43             id: textInput
44             anchors.horizontalCenter: parent.horizontalCenter
45             height: 40
46             width: parent.width
47             color: "white"
48             radius: 5
49
50          TextInput {
51                 id: textInputField
52                 anchors.centerIn: parent
53                 width: parent.width
54                 height: parent.height * 0.75
55                 font.pixelSize: 24
56                 color: "black"
57                 text: replyValue
58                 horizontalAlignment: Text.AlignHCenter
59                 activeFocusOnPress: false
60             }
61         }
62
63         Row {
64             id: buttonGroup
65             anchors.horizontalCenter: parent.horizontalCenter
66             spacing: 10
67             width: parent.width
68             height: 50
69
70             Image {
71                 id: acceptButton
72                 source: "/usr/share/hfdialer/images/ivi_btn-incomingcall-accept.png"
73                 width: buttonGroup.width / 2 - 5
74                 height: parent.height
75
76                 MouseArea {
77                     anchors.fill: parent
78                     onClicked: {
79                         console.log(deviceName + " replying with key: " + textInputField.text)
80                         numPad.pidRequest = false
81                         replyRequestPidCode(textInputField.text);
82                     }
83                 }
84
85                 Text {
86                     id: acceptButtonText
87                     text: qsTr("Accept")
88                     anchors.centerIn:parent
89                     horizontalAlignment: Text.AlignHCenter
90                     font.pixelSize: 20
91                     color: "white"
92                 }
93             }
94
95             Image {
96                 id: rejectButton
97                 source: "/usr/share/hfdialer/images/ivi_btn-incomingcall-decline.png"
98                 width: buttonGroup.width / 2 - 5
99                 height: parent.height
100
101                 MouseArea {
102                     anchors.fill: parent
103                     onClicked: {
104                         console.log(deviceName + " replying with key: " + textInputField.text)
105                         numPad.pidRequest = false
106                         cancelRequest()
107                     }
108                 }
109
110                 Text {
111                     id: cancelButtonText
112                     text: qsTr("Cancel")
113                     anchors.centerIn:parent
114                     horizontalAlignment: Text.AlignHCenter
115                     font.pixelSize: 20
116                     color: "white"
117                 }
118             }
119
120
121         }
122
123     }
124     ///we do this because this property is actually set post onCompleted:
125     onLegacyPairingChanged: {
126         console.log("legacy pair? " + legacyPairing)
127         if(!legacyPairing) {
128             replyRequestPidCode(textInputField.text);
129             console.log(deviceName + " replying with key: " + replyValue)
130         }
131     }
132
133 }