Add dialog for setting key bindings.
authorRuediger Gad <rgad@fb2.fh-frankfurt.de>
Sun, 15 Apr 2012 00:03:27 +0000 (02:03 +0200)
committerRuediger Gad <rgad@fb2.fh-frankfurt.de>
Sun, 15 Apr 2012 00:03:27 +0000 (02:03 +0200)
QZeeControl.pro.user
qml/QZeeControl/KeyBindingSettings.qml [new file with mode: 0644]
qml/QZeeControl/main.qml

index 4f9a044..6d3288d 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE QtCreatorProject>
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE QtCreatorProject>
-<!-- Written by Qt Creator 2.4.1, 2012-04-15T01:35:21. -->
+<!-- Written by Qt Creator 2.4.1, 2012-04-15T01:54:17. -->
 <qtcreator>
  <data>
   <variable>ProjectExplorer.Project.ActiveTarget</variable>
 <qtcreator>
  <data>
   <variable>ProjectExplorer.Project.ActiveTarget</variable>
diff --git a/qml/QZeeControl/KeyBindingSettings.qml b/qml/QZeeControl/KeyBindingSettings.qml
new file mode 100644 (file)
index 0000000..732b5ad
--- /dev/null
@@ -0,0 +1,134 @@
+// import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
+import QtQuick 1.1
+import com.nokia.meego 1.0
+import "settingsstorage.js" as SettingsStorage
+
+Sheet {
+    id: keyBindingSettings
+    anchors.fill: parent
+    visualParent: mainPage
+
+    acceptButtonText: "Save"
+    rejectButtonText: "Cancel"
+
+    function loadBindings(){
+        console.log("Loading stored key bindings.")
+        fieldA.text = SettingsStorage.getSetting("A")
+        fieldB.text = SettingsStorage.getSetting("B")
+        fieldC.text = SettingsStorage.getSetting("C")
+        fieldD.text = SettingsStorage.getSetting("D")
+
+        fieldUp.text = SettingsStorage.getSetting("Up")
+        fieldDown.text = SettingsStorage.getSetting("Down")
+        fieldLeft.text = SettingsStorage.getSetting("Left")
+        fieldRight.text = SettingsStorage.getSetting("Right")
+    }
+
+    function saveBindings(){
+        console.log("Saving new key bindings.")
+        SettingsStorage.setSetting("A", fieldA.text)
+        SettingsStorage.setSetting("B", fieldB.text)
+        SettingsStorage.setSetting("C", fieldC.text)
+        SettingsStorage.setSetting("D", fieldD.text)
+
+        SettingsStorage.setSetting("Up", fieldUp.text)
+        SettingsStorage.setSetting("Down", fieldDown.text)
+        SettingsStorage.setSetting("Left", fieldLeft.text)
+        SettingsStorage.setSetting("Right", fieldRight.text)
+    }
+
+    onAccepted: saveBindings()
+
+    onStatusChanged:{
+        if(status === DialogStatus.Opening){
+            loadBindings()
+        }
+    }
+
+    content: Flickable{
+        anchors.fill: parent
+        anchors.margins: 10
+        contentHeight: contentGrid.height
+
+        Grid{
+            id: contentGrid
+
+            anchors{top: parent.top}
+            width: 300
+            spacing: 10
+
+            Label{
+                text: "A"
+            }
+            TextField{
+                id: fieldA
+                text: "-"
+                width: 150
+            }
+
+            Label{
+                text: "B"
+            }
+            TextField{
+                id: fieldB
+                text: "-"
+                width: 150
+            }
+
+            Label{
+                text: "C"
+            }
+            TextField{
+                id: fieldC
+                text: "-"
+                width: 150
+            }
+
+            Label{
+                text: "D"
+            }
+            TextField{
+                id: fieldD
+                text: "-"
+                width: 150
+            }
+
+            Label{
+                text: "Up"
+            }
+            TextField{
+                id: fieldUp
+                text: "-"
+                width: 150
+            }
+
+            Label{
+                text: "Down"
+            }
+            TextField{
+                id: fieldDown
+                text: "-"
+                width: 150
+            }
+
+            Label{
+                text: "Left"
+            }
+            TextField{
+                id: fieldLeft
+                text: "-"
+                width: 150
+            }
+
+            Label{
+                text: "Right"
+            }
+            TextField{
+                id: fieldRight
+                text: "-"
+                width: 150
+            }
+        }
+    }
+}
+
index 8e72fa9..f6076f6 100644 (file)
@@ -42,8 +42,14 @@ PageStackWindow {
     Menu {
         id: myMenu
         visualParent: pageStack
     Menu {
         id: myMenu
         visualParent: pageStack
+
         MenuLayout {
             MenuItem {
         MenuLayout {
             MenuItem {
+                text: "Edit Key Bindings"
+                onClicked: keyBindingsSettings.open()
+            }
+
+            MenuItem {
                 text: "About"
                 onClicked: aboutDialog.open()
             }
                 text: "About"
                 onClicked: aboutDialog.open()
             }
@@ -53,4 +59,9 @@ PageStackWindow {
     AboutDialog{
         id: aboutDialog
     }
     AboutDialog{
         id: aboutDialog
     }
+
+    KeyBindingSettings{
+        id: keyBindingsSettings
+        onAccepted: mainPage.loadKeyBindings()
+    }
 }
 }