Initial commit.
[qzeecontrol] / qml / QZeeControl / MainPage.qml
1 import QtQuick 1.1
2 import com.nokia.meego 1.0
3 import QtMobility.connectivity 1.2
4 import qzeecontrol 1.0
5
6 Page {
7     tools: commonTools
8
9     Label {
10         id: label
11         anchors.centerIn: parent
12         text: "Click to Scan"
13     }
14
15     Button{
16         id: scanButton
17
18         anchors {
19             horizontalCenter: parent.horizontalCenter
20             top: label.bottom
21             topMargin: 10
22         }
23
24         text: "Connect"
25
26         onClicked: {
27             btDiscovery.discovery = true
28         }
29     }
30
31     BluetoothDiscoveryModel{
32         id: btDiscovery
33
34         discovery: false
35         minimalDiscovery: true
36
37         onDiscoveryChanged: {
38             if(discovery){
39                 label.text = "Scanning for devices..."
40                 scanButton.enabled = false
41             }else{
42                 label.text = "Scan finished."
43                 scanButton.enabled = true
44             }
45         }
46
47         onNewServiceDiscovered: {
48             console.log("Service " + service.serviceName + " found on " + service.deviceName + " at address " + service.deviceAddress + " on port " + service.servicePort + ".")
49             //btSocket.service = service
50             btConn.connect(service.deviceAddress, service.servicePort)
51         }
52     }
53
54     /*
55     BluetoothSocket{
56         id: btSocket
57
58         onDataAvailable: {
59             console.log("Data available: " + stringData.charCodeAt(0) + data)
60         }
61
62         onServiceChanged: {
63             console.log("Service changed. Connecting...")
64             connected = true
65         }
66
67         onConnectedChanged: {
68             console.log("Connected.")
69         }
70     }*/
71
72     BtConnector{
73         id: btConn
74     }
75 }