From: Ruediger Gad Date: Thu, 12 Apr 2012 16:52:59 +0000 (+0200) Subject: Rework UI. X-Git-Url: https://vcs.maemo.org/git/?p=qzeecontrol;a=commitdiff_plain;h=f6327a8c9aaa80c337a7cc3cbb1a55333efe954c Rework UI. --- diff --git a/qml/QZeeControl/MainPage.qml b/qml/QZeeControl/MainPage.qml index 4d78f44..54ef7ed 100644 --- a/qml/QZeeControl/MainPage.qml +++ b/qml/QZeeControl/MainPage.qml @@ -25,21 +25,60 @@ import qzeecontrol 1.0 Page { tools: commonTools + Button{ + id: scanButton + anchors{bottom: addressRow.top; bottomMargin: 10; horizontalCenter: parent.horizontalCenter} + enabled: true + + text: "Scan" + + onClicked: { + btDiscovery.discovery = true + } + } + + Row{ + id: addressRow + spacing: 5 + anchors{bottom: infoText.top; bottomMargin: 10; horizontalCenter: parent.horizontalCenter} + + TextField{ + id: addressField + text: "No device found yet." + + onTextChanged: { + connectButton.enabled = true + infoText.text = "Press \"Connect\" to connect to the device." + } + } + TextField{ + id: portField + text: "-" + width: 60 + validator: IntValidator{} + } + } + Label { - id: label + id: infoText anchors{bottom: connectButton.top; bottomMargin: 10; horizontalCenter: parent.horizontalCenter} + width: parent.width - text: "Press to connect." + text: "Please scan for a device first." + horizontalAlignment: Text.AlignHCenter + wrapMode: Text.WordWrap } Button{ id: connectButton anchors{bottom: disconnectButton.top; bottomMargin: 10; horizontalCenter: parent.horizontalCenter} + enabled: false text: "Connect" onClicked: { - btDiscovery.discovery = true + enabled = false + btConn.connect(addressField.text, parseInt(portField.text)) } } @@ -51,6 +90,7 @@ Page { onClicked: { btConn.disconnect() + } } @@ -108,55 +148,41 @@ Page { onDiscoveryChanged: { if(discovery){ - label.text = "Scanning for devices..." + infoText.text = "Scanning for devices..." + scanButton.enabled = false connectButton.enabled = false disconnectButton.enabled = false }else{ - connectButton.enabled = true + scanButton.enabled = true disconnectButton.enabled = false } } onNewServiceDiscovered: { - console.log("Service " + service.serviceName + " found on " + service.deviceName + " at address " + service.deviceAddress + " on port " + service.servicePort + ".") - //btSocket.service = service - btConn.connect(service.deviceAddress, service.servicePort) + console.log("Service " + service.serviceName + " found on " + + service.deviceName + " at address " + service.deviceAddress + + " on port " + service.servicePort + ".") + if(service.serviceName === "Zeemote"){ + addressField.text = service.deviceAddress + portField.text = service.servicePort + } } } - /* - BluetoothSocket{ - id: btSocket - - onDataAvailable: { - console.log("Data available: " + stringData.charCodeAt(0) + data) - } - - onServiceChanged: { - console.log("Service changed. Connecting...") - connected = true - } - - onConnectedChanged: { - console.log("Connected.") - } - }*/ - BtConnector{ id: btConn property int joystickThreshold: 50 onConnected: { - connectButton.enabled = false disconnectButton.enabled = true - label.text = "Connected." + infoText.text = "Connected. Have fun." } onDisconnected: { connectButton.enabled = true disconnectButton.enabled = false - label.text = "Press to connect." + infoText.text = "Press \"Connect\" to connect to the device." } // onStickMoved: {