improved desktop UI
[mardrone] / mardrone / ardrone_symbian.qml
1 // uiName:Symbian
2 import QtQuick 1.0
3 import com.nokia.symbian 1.1
4 import Drone 1.0
5 //import gauges 1.0
6 import JoyStick 1.0
7
8 PageStackWindow {
9     id:mainWindow
10     initialPage: mainpageComponent
11     showStatusBar: false
12 //    fullscreen:true
13     property Component dialogComponent
14 // property alias m: mainPage
15
16     /*
17     ToolBarLayout {
18             id: commonTools
19             visible: false
20             ToolItem { iconId: "icon-m-toolbar-back"; onClicked: pageStack.pop(); }
21         //    ToolItem { iconId: "icon-m-toolbar-home"; onClicked: pageStack.pop(); }
22             ToolItem { iconId: "icon-m-toolbar-view-menu"; onClicked: myMenu.open(); }
23         }
24         */
25     ToolBarLayout {
26         id: commonTools
27         ToolButton {
28             flat: true
29             iconSource: "toolbar-back"
30             onClicked: mainWindow.pageStack.depth <= 1 ? Qt.quit() : mainWindow.pageStack.pop()
31         }
32    }
33   DroneControl {
34         id:drone
35     }
36   JoyStick {
37       id:js
38       onElevatorChanged:{if(drone.confUseJoyStick) drone.pitch=elevator;}
39       onAileronChanged: {if(drone.confUseJoyStick) drone.roll=-1.0*aileron;}
40       onThrotleChanged: {if(drone.confUseJoyStick) drone.vVelocity=throtle;}
41       onRudderChanged:  {if(drone.confUseJoyStick) drone.yaw=rudder;}
42
43   }
44
45     Component {
46       id: mainpageComponent
47
48       Page {
49         id:mainPage
50         property bool connectingBoxVisible:true
51         //onEntered:(mainWindow.fullscreen=true)
52
53         state:"Landscape"
54         DroneVideo {
55             y:0
56             x:0
57            // anchors.horizontalCenter:parent.horizontalCenter
58             width:drone.confFullScreen? parent.width:640 ;height:480*width/640;
59         }
60
61         EfisPFD {
62             id:hudPDF
63             y:0
64             anchors.horizontalCenter: parent.horizontalCenter
65             visible:drone.confShowHorizon
66             roll:drone.droneRoll
67             pitch:drone.dronePitch
68             ias:drone.droneSpeed
69             alt:drone.droneAltitude
70             indicatorColor:"#00FF00"
71             skyColor:"#00000000"
72             groundColor:"#00000000"
73             width:500;height:400;
74         }
75
76         Text {
77             y:50
78             visible:drone.confShowDebug
79             color: "#00FF00"
80             id: droneCtrlValues
81             font.pixelSize:25
82             text: "cmd:pitch=" + drone.pitch.toFixed(2) + " roll= " +  drone.roll.toFixed(2) + " yaw=" + drone.yaw.toFixed(2) + " vv= " + drone.vVelocity.toFixed(2)
83         }
84
85
86         Text {
87             y:70
88             visible:drone.confShowDebug
89             color: "#00FF00"
90             id: droneNavData
91             font.pixelSize:25
92             text: "pitch=" + drone.dronePitch.toFixed(2) + " roll= " +  drone.droneRoll.toFixed(2) + "yaw=" + drone.droneYaw.toFixed(2) + " alt= " +  drone.droneAltitude.toFixed(2)
93         }
94
95         Text {
96             y:100
97             visible:drone.confShowDebug
98             color: "#00FF00"
99             id: droneStatus
100             font.pixelSize:20
101             text: drone.decodedStatus
102         }
103         Button {
104             y:150;x:0
105             height: 50
106             width: 50
107             z:2 // This is visible even connecting to drone
108             iconSource: "gear32x32.png"
109             onClicked:{   //mainWindow.fullscreen = false ;
110                      pageStack.push(dialogComponent);
111             }
112         }
113
114         JoyStickIndicator {
115             x:200;y:350
116             visible:drone.confShowJSIndicators&js.haveJoyStick&drone.confUseJoyStick
117             border.width:1
118             color:"transparent"
119             width:100;height:100
120             xvalue:js.axis4
121             yvalue:js.axis3
122             Text {
123                 anchors.bottom: parent.bottom
124                 font.pixelSize: 10
125                 text:"       rudder"
126             }
127             Text {
128                 x:-10;y:50
129                 rotation:90
130                 font.pixelSize: 10
131                 text:"Throtle"
132             }
133         }
134
135
136         JoyStickIndicator {
137             x:500;y:350
138             visible:drone.confShowJSIndicators&js.haveJoyStick&drone.confUseJoyStick
139             border.width:1
140             color:"transparent"
141             width:100;height:100
142             xvalue:js.axis1
143             yvalue:js.axis2
144             Text {
145                 anchors.bottom: parent.bottom
146                 font.pixelSize: 10
147                 text:"      Aileron"
148             }
149             Text {
150                 x:-15;y:50
151                 rotation:90
152                 font.pixelSize: 10
153                 text:"Elevator"
154             }
155         }
156
157         JoyStickTouch {
158             id:lj
159             width:200;height:200;
160
161             visible: !drone.confUseAccel & !drone.confUseJoyStick
162             anchors.left:parent.left
163             anchors.bottom:parent.bottom
164             anchors.margins:10
165             joyBackground: ""
166             onYvChanged:{drone.vVelocity=-1*yv/200.0;}
167             onXvChanged:{drone.yaw=xv/200.0;}
168             onPressedChanged: { drone.ctrlActive=pressed;}
169         }
170
171         JoyStickTouch {
172              visible: !drone.confUseJoyStick
173             id:rj
174             joyBackground: ""
175             anchors.right:parent.right
176             anchors.bottom:parent.bottom
177             width:200;height:200;
178             anchors.margins:10
179             onYvChanged:{drone.pitch=yv/200.0;}
180             onXvChanged:{drone.roll=xv/200.0;}
181         }
182
183         Row {
184             spacing: 5
185             anchors.right:parent.right
186             anchors.rightMargin: 10
187             y:100
188             height:100
189         BarGauge {
190            val:drone.pwm_motor1;
191            max: 255
192            height:100
193         }
194         BarGauge {
195             val:drone.pwm_motor2;
196             max: 255
197             height:100
198         }
199         BarGauge {
200             val:drone.pwm_motor3;
201             max: 255
202             height:100
203         }
204         BarGauge {
205             val:drone.pwm_motor4;
206             max: 255
207             height:100
208         }
209         BarGauge {
210             val:drone.droneVBat
211             max: 100
212             height:100
213         }
214         }
215
216         Button {
217             x:400
218             width:60
219             height:50
220             id:flyButton
221             anchors.bottom:parent.bottom
222             anchors.margins:15
223             text:"Fly";
224             checkable:true
225             onClicked:{drone.fly=checked;
226             // mainWindow.fullsecreen=checked;
227             }
228         }
229         Button {
230             x:500;
231             width:80
232             height:50
233             id:emergencyButton
234             anchors.bottom:parent.bottom
235             anchors.margins:15
236             text:"Emrg";
237             checkable:true
238             onClicked:{drone.emergency=checked;}
239         }
240         Button {
241             x:600;
242             width:100
243             height:50
244             id:recordButton
245             anchors.bottom:parent.bottom
246             anchors.margins:15
247             text:"Rec";
248             checkable:true
249             onClicked:{droneVideo.recVideo=checked; drone.logFileName=droneVideo.videoFileName; drone.recordLog=checked;}
250         }
251         Text {
252             y:700
253             anchors.bottom:parent.bottom
254        //     visible:droneVideo.recVideo
255             color: "#00FF00"
256             id: droneFrameSeq
257             font.pixelSize:25
258             text: droneVideo.videoFileName+ " "+droneVideo.frameSeq
259         }
260
261             Connections {
262                 target:drone
263                 onConnectedChanged:{
264                     console.log("Connected to drone");
265                     connectingDialog.accept();}
266             }
267             QueryDialog {
268                 id:connectingDialog
269                 titleText:"Connecting to Drone"
270                 message:"Connecting to Drone "+ drone.confDroneIp
271                 acceptButtonText:"OK"
272                 Component.onCompleted: {
273                     console.log("ConectionDialog Opened");
274                     if(!drone.connected) open(); }
275             }
276         } // Main page
277     }
278
279      Component.onCompleted: {
280          if (mainpageComponent.status != Component.Ready)
281              //        pageStack.push(mainpageComponent);
282              //  else
283                      console.log("Error loading component:", mainpageComponent.errorString());
284          dialogComponent = Qt.createComponent("ConfigDialogSymbian.qml");
285
286         }
287  }