sync repository
[mardrone] / mardrone / ardrone.meegostyle.qml
1 import Qt 4.7
2 import com.nokia.meego 1.0
3 import Drone 1.0
4
5
6 Window {
7     id:mainWindow
8 //    fullscreen:true
9     property Component dialogComponent
10 // property alias m: mainPage
11       StatusBar {
12           id: statusBar
13           anchors.top: parent.top
14           anchors.bottom:myToolbar.top
15           orientation: screen.orientation
16           width: parent.width
17       }
18
19     ToolBar {
20         id: myToolbar
21         anchors.top: statusBar.bottom
22      // anchors.bottom: pageStack.top
23     }
24
25     PageStack {
26             id: pageStack
27              clip: true
28             anchors.top: toolBar.bottom
29             anchors.bottom: parent.bottom
30             width: parent.width
31             toolBar: myToolbar
32         }
33     ToolBarLayout {
34             id: commonTools
35             visible: false
36             ToolItem { iconId: "icon-m-toolbar-home"; onClicked: pageStack.pop(); }
37             ToolItem { iconId: "icon-m-toolbar-view-menu"; onClicked: myMenu.open(); }
38             ToolItem { iconId: "icon-m-toolbar-back"; onClicked: pageStack.pop(); }
39         }
40
41
42   DroneControl {
43         id:drone
44     }
45
46     Component {
47       id: mainpageComponent
48       Page {
49         id:mainPage
50         //onEntered:(mainWindow.fullscreen=true)
51
52         state:"Landscape"
53         DroneVideo {
54             y:0
55             x:0
56             anchors.horizontalCenter:parent.horizontalCenter
57             width:drone.confFullScreen? parent.width:640 ;height:480*width/640;
58         }
59
60         GaugeHorizon {
61             y:0
62             x:100
63             visible:drone.confShowHorizon
64             value:drone.droneRoll
65             value2:drone.dronePitch
66 //            value:lj.xv
67 //            value2:lj.yv
68             opacity:0.5
69             width:640;height:480;
70         }
71         Text {
72             y:100
73             visible:drone.confUseAccel
74             color: "#00FF00"
75             id: droneCtrlValues
76             font.pixelSize:20
77             text: "cmd:pitch=" + Math.round(drone.pitch) + " roll= " +  Math.round(drone.roll) + " yaw=" + Math.round(drone.yaw) + " vv= " +  Math.round(drone.vVelocity)
78         }
79
80         Text {
81             y:115
82             visible:drone.confShowDebug
83             color: "#00FF00"
84             id: droneNavData
85             font.pixelSize:20
86             text: "pitch=" + Math.round(drone.dronePitch) + " roll= " +  Math.round(drone.droneRoll) + "yaw=" + Math.round(drone.droneYaw) + " alt= " +  Math.round(drone.droneAltitude)
87         }
88
89         Text {
90             y:130
91             visible:drone.confShowDebug
92             color: "#00FF00"
93             id: droneStatus
94             font.pixelSize:20
95             text: drone.decodedStatus
96         }
97         Button {
98             y:150;x:0
99             height: 50
100             width: 50
101             text: "conf"
102             onClicked:{   //mainWindow.fullscreen = false ;
103                      pageStack.push(dialogComponent);
104             }
105         }
106         Image {
107             visible: !drone.confUseAccel
108             x:10;y:200
109             width:280;height:280;
110             source: "joybox.png"
111
112             JoyStick {
113                 id:lj
114                 anchors.fill:parent
115                 anchors.margins:50
116                 onYvChanged:{drone.pitch=yv;}
117                 onXvChanged:{drone.roll=xv;}
118
119
120             }
121         }
122         Image {
123             y:200
124             anchors.right:parent.right
125             width:280;height:280;
126             source: "joybox.png"
127             JoyStick {
128                 id:rj
129                 anchors.fill:parent
130                 anchors.margins:50
131                 onYvChanged:{drone.vVelocity=-1*yv;}
132                 onXvChanged:{drone.yaw=xv;}
133                 onPressedChanged: { drone.ctrlActive=pressed;}
134             }
135         }
136         Row {
137             spacing: 5
138             anchors.right:parent.right
139             anchors.rightMargin: 10
140             y:100
141             height:100
142         BarGauge {
143            val:drone.pwm_motor1;
144            max: 255
145            height:100
146         }
147         BarGauge {
148             val:drone.pwm_motor2;
149             max: 255
150             height:100
151         }
152         BarGauge {
153             val:drone.pwm_motor3;
154             max: 255
155             height:100
156         }
157         BarGauge {
158             val:drone.pwm_motor4;
159             max: 255
160             height:100
161         }
162         BarGauge {
163             val:drone.droneVBat
164             max: 100
165             height:100
166         }
167         }
168
169         Button {
170             x:400
171             width:60
172             id:flyButton
173             anchors.bottom:parent.bottom
174             anchors.margins:15
175             text:"Fly";
176             checkable:true
177             onClicked:{drone.fly=checked;
178             // mainWindow.fullsecreen=checked;
179             }
180         }
181         Button {
182             x:400;y:100
183             width:120
184             id:emergencyButton
185             anchors.top:parent.top
186             anchors.margins:15
187             text:"Energency";
188             checkable:true
189             onClicked:{drone.emergency=checked;}
190         }
191
192         } // Main page
193     }
194
195      Component.onCompleted: {
196          if (mainpageComponent.status == Component.Ready)
197                      pageStack.push(mainpageComponent);
198                else
199                      console.log("Error loading component:", mainpageComponent.errorString());
200          dialogComponent = Qt.createComponent("ConfigDialog.qml");
201         }
202 //      Component.onCompleted: {
203 //            mainWindow.fullscreen = true ;
204 //            dialogComponent = Qt.createComponent("ConfigDialog.qml");
205 //            mainWindow.nextPage(mainpageComponent)
206 //      }
207  }