Add dialog for setting key bindings.
[qzeecontrol] / qml / QZeeControl / KeyBindingSettings.qml
1 // import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
2 import QtQuick 1.1
3 import com.nokia.meego 1.0
4 import "settingsstorage.js" as SettingsStorage
5
6 Sheet {
7     id: keyBindingSettings
8     anchors.fill: parent
9     visualParent: mainPage
10
11     acceptButtonText: "Save"
12     rejectButtonText: "Cancel"
13
14     function loadBindings(){
15         console.log("Loading stored key bindings.")
16         fieldA.text = SettingsStorage.getSetting("A")
17         fieldB.text = SettingsStorage.getSetting("B")
18         fieldC.text = SettingsStorage.getSetting("C")
19         fieldD.text = SettingsStorage.getSetting("D")
20
21         fieldUp.text = SettingsStorage.getSetting("Up")
22         fieldDown.text = SettingsStorage.getSetting("Down")
23         fieldLeft.text = SettingsStorage.getSetting("Left")
24         fieldRight.text = SettingsStorage.getSetting("Right")
25     }
26
27     function saveBindings(){
28         console.log("Saving new key bindings.")
29         SettingsStorage.setSetting("A", fieldA.text)
30         SettingsStorage.setSetting("B", fieldB.text)
31         SettingsStorage.setSetting("C", fieldC.text)
32         SettingsStorage.setSetting("D", fieldD.text)
33
34         SettingsStorage.setSetting("Up", fieldUp.text)
35         SettingsStorage.setSetting("Down", fieldDown.text)
36         SettingsStorage.setSetting("Left", fieldLeft.text)
37         SettingsStorage.setSetting("Right", fieldRight.text)
38     }
39
40     onAccepted: saveBindings()
41
42     onStatusChanged:{
43         if(status === DialogStatus.Opening){
44             loadBindings()
45         }
46     }
47
48     content: Flickable{
49         anchors.fill: parent
50         anchors.margins: 10
51         contentHeight: contentGrid.height
52
53         Grid{
54             id: contentGrid
55
56             anchors{top: parent.top}
57             width: 300
58             spacing: 10
59
60             Label{
61                 text: "A"
62             }
63             TextField{
64                 id: fieldA
65                 text: "-"
66                 width: 150
67             }
68
69             Label{
70                 text: "B"
71             }
72             TextField{
73                 id: fieldB
74                 text: "-"
75                 width: 150
76             }
77
78             Label{
79                 text: "C"
80             }
81             TextField{
82                 id: fieldC
83                 text: "-"
84                 width: 150
85             }
86
87             Label{
88                 text: "D"
89             }
90             TextField{
91                 id: fieldD
92                 text: "-"
93                 width: 150
94             }
95
96             Label{
97                 text: "Up"
98             }
99             TextField{
100                 id: fieldUp
101                 text: "-"
102                 width: 150
103             }
104
105             Label{
106                 text: "Down"
107             }
108             TextField{
109                 id: fieldDown
110                 text: "-"
111                 width: 150
112             }
113
114             Label{
115                 text: "Left"
116             }
117             TextField{
118                 id: fieldLeft
119                 text: "-"
120                 width: 150
121             }
122
123             Label{
124                 text: "Right"
125             }
126             TextField{
127                 id: fieldRight
128                 text: "-"
129                 width: 150
130             }
131         }
132     }
133 }
134