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