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