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