Fix DB. Suspend test output when inactive.
authorRuediger Gad <rgad@fb2.fh-frankfurt.de>
Thu, 12 Apr 2012 17:43:58 +0000 (19:43 +0200)
committerRuediger Gad <rgad@fb2.fh-frankfurt.de>
Thu, 12 Apr 2012 17:43:58 +0000 (19:43 +0200)
QZeeControl.pro.user
qml/QZeeControl/MainPage.qml

index 64a2f6c..9df03b1 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE QtCreatorProject>
-<!-- Written by Qt Creator 2.4.1, 2012-04-12T12:18:50. -->
+<!-- Written by Qt Creator 2.4.1, 2012-04-12T19:09:09. -->
 <qtcreator>
  <data>
   <variable>ProjectExplorer.Project.ActiveTarget</variable>
index 54ef7ed..05bfb23 100644 (file)
 import QtQuick 1.1
 import com.nokia.meego 1.0
 import QtMobility.connectivity 1.2
+import "settingsstorage.js" as SettingsStorage
 import qzeecontrol 1.0
 
 Page {
     tools: commonTools
 
+    Component.onCompleted: {
+        SettingsStorage.initialize();
+
+        var address = SettingsStorage.getSetting("address");
+        var port = SettingsStorage.getSetting("port");
+        if(address !== "Unknown" && port !== "Unknown"){
+            console.log("Loaded address " + address + " and port " + port + " from DB.")
+            addressField.text = address
+            portField.text = port
+        }
+    }
+
+    states: [
+        State {
+            name: "active"
+            PropertyChanges {
+                target: cursorRectangle
+                x: moveArea.x + (moveArea.width * 0.5) + btConn.x - (cursorRectangle.width * 0.5)
+                y: moveArea.y + (moveArea.height * 0.5) + btConn.y - (cursorRectangle.height * 0.5)
+            }
+            PropertyChanges {
+                target: labelA
+                color: btConn.a ? "red" : "blue"
+            }
+            PropertyChanges {
+                target: labelB
+                color: btConn.b ? "red" : "blue"
+            }
+            PropertyChanges {
+                target: labelC
+                color: btConn.c ? "red" : "blue"
+            }
+            PropertyChanges {
+                target: labelD
+                color: btConn.d ? "red" : "blue"
+            }
+        },
+        State {
+            name: "inactive"
+            PropertyChanges {
+                target: cursorRectangle
+                x: moveArea.x + (moveArea.width * 0.5) - (cursorRectangle.width * 0.5)
+                y: moveArea.y + (moveArea.height * 0.5) - (cursorRectangle.height * 0.5)
+            }
+            PropertyChanges {
+                target: labelA
+                color: "blue"
+            }
+            PropertyChanges {
+                target: labelB
+                color: "blue"
+            }
+            PropertyChanges {
+                target: labelC
+                color: "blue"
+            }
+            PropertyChanges {
+                target: labelD
+                color: "blue"
+            }
+        }
+
+    ]
+
+    Connections {
+        target: platformWindow
+
+        onActiveChanged: {
+            if(platformWindow.active){
+                state = "active"
+            }else{
+                state = "inactive"
+            }
+        }
+    }
+
     Button{
         id: scanButton
         anchors{bottom: addressRow.top; bottomMargin: 10; horizontalCenter: parent.horizontalCenter}
@@ -47,15 +124,28 @@ Page {
             text: "No device found yet."
 
             onTextChanged: {
+                if(text === "No device found yet.")
+                    return
+
                 connectButton.enabled = true
                 infoText.text = "Press \"Connect\" to connect to the device."
+                console.log("Storing address in DB: " + text)
+                SettingsStorage.setSetting("address", text)
             }
         }
         TextField{
             id: portField
-            text: "-"
+            text: "na"
             width: 60
             validator: IntValidator{}
+
+            onTextChanged: {
+                if(text === "na")
+                    return
+
+                console.log("Storing port in DB: " + text)
+                SettingsStorage.setSetting("port", text)
+            }
         }
     }