From: Ruediger Gad Date: Sun, 15 Apr 2012 10:52:54 +0000 (+0200) Subject: Fix init. Fix button enabling. X-Git-Url: https://vcs.maemo.org/git/?p=qzeecontrol;a=commitdiff_plain;h=6aa84a4624b22f7e6343b7aa860c906bca0629a3 Fix init. Fix button enabling. --- diff --git a/qml/QZeeControl/MainPage.qml b/qml/QZeeControl/MainPage.qml index 4021400..0032145 100644 --- a/qml/QZeeControl/MainPage.qml +++ b/qml/QZeeControl/MainPage.qml @@ -25,6 +25,7 @@ import "settingsstorage.js" as SettingsStorage import qzeecontrol 1.0 Page { + id: mainPage tools: commonTools orientationLock: PageOrientation.LockPortrait @@ -77,11 +78,20 @@ 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." + function updateConnectAndScanButton(){ + if(!deviceInfo.currentBluetoothPowerState){ + scanButton.enabled = false + connectButton.enabled = false + infoText.text = "To get started please turn Bluetooth on." + return } + + scanButton.enabled = true + connectButton.enabled = (addressField.text !== "No device found yet.") + infoText = (addressField.text !== "No device found yet.") ? + "To enable remote control please press \"Connect\" when ready." : + "Please scan for a Zeemote first." + } states: [ @@ -236,7 +246,7 @@ Page { Button{ id: scanButton - enabled: deviceInfo.currentBluetoothPowerState + enabled: false anchors.horizontalCenter: parent.horizontalCenter text: "Scan" @@ -256,13 +266,13 @@ Page { text: "No device found yet." onTextChanged: { - if(initializing) + if(mainPage.initializing) return if(text === "No device found yet.") return - updateConnectButton(); + updateConnectAndScanButton(); console.log("Storing address in DB: " + text) SettingsStorage.setSetting("address", text) @@ -275,7 +285,7 @@ Page { validator: IntValidator{} onTextChanged: { - if(initializing) + if(mainPage.initializing) return if(text === "na") @@ -381,7 +391,7 @@ Page { monitorBluetoothStateChanges: true onBluetoothStateChanged: { - updateConnectButton() + updateConnectAndScanButton() } }