d3f719fa12a85f7e9f523c92a84fd93a6914cf80
[mardrone] / mardrone / ConfigDialogAndroid.qml
1 import QtQuick 1.0
2 import com.nokia.android 1.1
3 import JoyStick 1.0
4 Page {
5         property color textColor:"white"
6         property int textSize:30
7         id:dialog
8         tools:commonTools
9         Menu {
10             id:uiMenu
11             visualParent:pageStack
12             MenuLayout {
13                 MenuItem { text:"MeeGo/Harmattan 854x480";  onClicked: { drone.confActiveUI="ardrone_harmattan.qml" }}
14                 MenuItem { text:"Desktop";  onClicked: { drone.confActiveUI="ardrone_desktop.qml"}}
15            }
16         }
17         Component.onCompleted: {
18             console.debug("Appending items to choices",uiList.count())
19             for(var j = 0; j < uiList.count();++j ) {
20                 var data = {'name':uiList.get(j).name,'modelData':uiList.get(j).name,'file':uiList.get(j).file };
21                 console.debug("appending ",uiList.get(j).name,uiList.get(j).file);
22                 choices.append(data);
23                 if(uiList.get(j).file==drone.confActiveUI) { activeUIDialog.selectedIndex=j; uiDialogButton.text=uiList.get(j).name }
24             }
25         }
26
27         ListModel {
28              id: choices
29         }
30         SelectionDialog {
31             id: activeUIDialog;
32             model:choices
33
34             onSelectedIndexChanged: {
35                   console.debug("onSelectedIndexChanged " + model.get(selectedIndex).name + ", " + model.get(selectedIndex).file);
36                   drone.confActiveUI=choices.get(selectedIndex).file;
37                   uiDialogButton.text=uiList.get(selectedIndex).name
38                }
39             }
40         Flickable {
41           id: dialogscrolarea
42           anchors.fill: parent
43  //         anchors.leftMargin:50;anchors.rightMargin:50
44           contentHeight: dialogcontent.height
45           contentWidth: parent.width
46
47           Grid {
48               columns:2
49               id: dialogcontent
50               anchors.leftMargin:50;anchors.rightMargin:150
51               spacing: 20
52
53               Text {
54                   font.pixelSize  :textSize
55                   text:"UI Style"
56
57               }
58               Button {
59                   width:200
60                   id:uiDialogButton
61                   text:""
62                   anchors.right:parent.right
63                   onClicked:activeUIDialog.open()
64                 //  onClicked:uiMenu.open()
65               }
66           Text {
67               width:350
68               text: "Drone IP"
69               color:textColor
70               font.pixelSize  :textSize
71            }
72
73            TextField {
74                   id: droneip
75                   width: 300
76                   height: 40
77                   anchors.right: parent.right
78                   text: drone.confDroneIp
79                   onTextChanged:{drone.confDroneIp=text;}
80            }
81
82 //          }
83
84            Text {
85               text: "Video 640x480/Full Screen"
86               color:textColor
87               font.pixelSize  :textSize
88            }
89            Switch {
90               id: fullScreen
91               checked:drone.confFullScreen
92               anchors.right:parent.right
93               onCheckedChanged:{drone.confFullScreen=checked;}
94            }
95            Text {
96               text: "Acceleration Sensor controll"
97               color:textColor
98               font.pixelSize  :textSize
99            }
100            Switch {
101               id: useAccelSw
102               checked:drone.confUseAccel
103               anchors.right:parent.right
104               onCheckedChanged:{drone.confUseAccel=checked;}
105            }
106            Text {
107                text: "Joystick"
108               color:textColor
109               font.pixelSize  :textSize
110            }
111            Switch {
112               id: useJoySw
113               checked:drone.confUseJoyStick
114               anchors.right:parent.right
115               enabled:js.haveJoyStick
116               onCheckedChanged:{drone.confUseJoyStick=checked;}
117            }
118
119            Text {
120                visible:drone.confUseJoyStick
121                font.pixelSize  :textSize
122                text:"\"" + js.joyStickName + "\""
123
124            }
125            Button {
126                visible:drone.confUseJoyStick
127                text:"Calibrate"
128                anchors.right:parent.right
129                onClicked:{
130                    js.calibrate=true
131                    pageStack.push(calibrateDialog);
132                }
133            }
134            Text {
135                visible:drone.confUseJoyStick
136                font.pixelSize  :textSize
137                text:"Show JoyStick Indicators"
138
139            }
140             Switch {
141                visible:drone.confUseJoyStick
142                checked:drone.confShowJSIndicators
143                anchors.right:parent.right
144                enabled:js.haveJoyStick
145                onCheckedChanged:{drone.confShowJSIndicators=checked;}
146
147            }
148            Text {
149               color:textColor
150               text: "Show debug"
151               font.pixelSize  :textSize
152            }
153            Switch {
154               id: showDebug
155               checked:drone.confShowDebug
156               anchors.right:parent.right
157               onCheckedChanged:{drone.confShowDebug=checked;}
158            }
159
160            Text {
161               text: "Show engine gauges"
162               color:textColor
163               font.pixelSize  :textSize
164
165            }
166            Switch {
167               id: showGauges
168               checked:drone.confShowGauges
169               anchors.right:parent.right
170               onCheckedChanged:{drone.confShowGauges=checked;}
171            }
172
173            Text {
174               text: "Show horizon"
175               color:textColor
176               font.pixelSize  :textSize
177
178            }
179            Switch {
180               id: showHorizon
181               checked:drone.confShowHorizon
182               anchors.right:parent.right
183               onCheckedChanged:{drone.confShowHorizon=checked;}
184            }
185
186            Text {
187               text: "Forward/backward gain"
188               color:textColor
189               font.pixelSize  :textSize
190            }
191
192            Slider {
193               id: forwardGain
194               anchors.right:parent.right
195               maximumValue:1.0
196               stepSize:0.01
197               value:drone.confForwardGain
198               onValueChanged:{drone.confForwardGain=value;}
199            }
200            Text {
201               text: "Right/Left gain"
202               color:textColor
203               font.pixelSize  :textSize
204            }
205
206            Slider {
207               id: rightGain
208               anchors.right:parent.right
209               maximumValue:1.0
210               stepSize:0.01
211               value:drone.confRightGain
212               onValueChanged:{drone.confRightGain=value;}
213            }
214            Text {
215               text: "accel ctrl treshold"
216               color:textColor
217               font.pixelSize  :textSize
218            }
219
220            Slider {
221               id: ctrlTreshold
222               anchors.right:parent.right
223               maximumValue:25.0
224               value:drone.confCtrlTrsh
225               onValueChanged:{drone.confCtrlTrsh=value;}
226            }
227           }
228        }
229         Page {
230                 property color textColor:"black"
231                 property int textSize:30
232                 id:calibrateDialog
233                 tools:commonTools
234                 /*
235                 JoyStickCalibrator {
236                     id:jc
237                 //    jStick:js
238                     Component.onCompleted: {
239                         if (jc.status != Component.Ready)
240                                     console.log("Error loading component:", jc.errorString());
241                     }
242                 }
243 */
244         }
245      }
246