From a9f9063ea9d327d593f9ccaa82d5a19e43f534a1 Mon Sep 17 00:00:00 2001 From: Ruediger Gad Date: Sun, 15 Apr 2012 12:30:13 +0200 Subject: [PATCH] Check if bluetooth is enabled. --- QZeeControl.pro.user | 2 +- qml/QZeeControl/MainPage.qml | 24 +++++++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/QZeeControl.pro.user b/QZeeControl.pro.user index 9d74cb7..59d9dff 100644 --- a/QZeeControl.pro.user +++ b/QZeeControl.pro.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget diff --git a/qml/QZeeControl/MainPage.qml b/qml/QZeeControl/MainPage.qml index 848babc..4021400 100644 --- a/qml/QZeeControl/MainPage.qml +++ b/qml/QZeeControl/MainPage.qml @@ -20,6 +20,7 @@ import QtQuick 1.1 import com.nokia.meego 1.0 import QtMobility.connectivity 1.2 +import QtMobility.systeminfo 1.2 import "settingsstorage.js" as SettingsStorage import qzeecontrol 1.0 @@ -76,6 +77,13 @@ Page { btConn.keyBindingRight = SettingsStorage.getSetting("Right") } + function updateConnectButton(){ + if((addressField.text !== "No device found yet.") && deviceInfo.currentBluetoothPowerState){ + connectButton.enabled = true + infoText.text = "Press \"Connect\" to connect to the device." + } + } + states: [ State { name: "active" @@ -228,7 +236,7 @@ Page { Button{ id: scanButton - enabled: true + enabled: deviceInfo.currentBluetoothPowerState anchors.horizontalCenter: parent.horizontalCenter text: "Scan" @@ -254,8 +262,8 @@ Page { if(text === "No device found yet.") return - connectButton.enabled = true - infoText.text = "Press \"Connect\" to connect to the device." + updateConnectButton(); + console.log("Storing address in DB: " + text) SettingsStorage.setSetting("address", text) } @@ -367,6 +375,16 @@ Page { } } + DeviceInfo{ + id: deviceInfo + + monitorBluetoothStateChanges: true + + onBluetoothStateChanged: { + updateConnectButton() + } + } + BluetoothDiscoveryModel{ id: btDiscovery -- 1.7.9.5