Check if bluetooth is enabled.
authorRuediger Gad <rgad@fb2.fh-frankfurt.de>
Sun, 15 Apr 2012 10:30:13 +0000 (12:30 +0200)
committerRuediger Gad <rgad@fb2.fh-frankfurt.de>
Sun, 15 Apr 2012 10:30:13 +0000 (12:30 +0200)
QZeeControl.pro.user
qml/QZeeControl/MainPage.qml

index 9d74cb7..59d9dff 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE QtCreatorProject>
-<!-- Written by Qt Creator 2.4.1, 2012-04-15T11:56:44. -->
+<!-- Written by Qt Creator 2.4.1, 2012-04-15T12:02:39. -->
 <qtcreator>
  <data>
   <variable>ProjectExplorer.Project.ActiveTarget</variable>
index 848babc..4021400 100644 (file)
@@ -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