Debian Codegraph @

src/GUI/qml/LocationCarrierView.qml

raw
1 import QtQuick 2.4
2 import FlightGear 1.0
3 import FlightGear.Launcher 1.0
4
5 Item {
6 property alias geod: diagram.geod
7
8 CarrierDiagram {
9 id: diagram
10 anchors.fill: parent
11
12 offsetEnabled: _location.useCarrierFLOLS
13 offsetDistance: _location.offsetDistance
14 abeam: _location.abeam
15 }
16
17 Component.onCompleted: {
18 syncUIFromController();
19 }
20
21 function syncUIFromController()
22 {
23 if (_location.abeam) {
24 abeamRadio.select()
25 } else if (_location.useCarrierFLOLS) {
26 flolsRadio.select()
27 } else {
28 parkingRadio.select();
29 parkingChoice.syncCurrentIndex();
30 }
31 }
32
33 Rectangle {
34 id: panel
35
36 color: "transparent"
37 border.width: 1
38 border.color: Style.frameColor
39
40 anchors {
41 left: parent.left
42 right: parent.right
43 bottom: parent.bottom
44 margins: Style.strutSize
45 }
46
47 height: selectionGrid.height + Style.margin * 2
48
49 // set opacity here only, so we don't make the whole summary panel translucent
50 Rectangle {
51 id: background
52 anchors.fill: parent
53 z: -1
54 opacity: Style.panelOpacity
55 color: Style.panelBackground
56 }
57
58 RadioButtonGroup {
59 id: radioGroup
60 }
61
62 Column {
63 id: selectionGrid
64 spacing: Style.margin
65 width: parent.width * 0.3
66
67 StyledText { // heading text
68 id: headingText
69 anchors {
70 left: parent.left
71 right: parent.right
72 margins: Style.margin
73 }
74
75 text: qsTr("Carrier: %1").arg(_location.carrier);
76 font.pixelSize: Style.headingFontPixelSize
77 }
78
79 // on final approach
80 Row {
81 anchors.left: parent.left
82 anchors.leftMargin: Style.margin
83 anchors.right: parent.right
84 anchors.rightMargin: Style.margin
85 spacing: Style.margin
86
87 RadioButton {
88 id: flolsRadio
89 anchors.verticalCenter: parent.verticalCenter
90 group: radioGroup
91 onClicked: {
92 if (selected) {
93 _location.useCarrierFLOLS = selected;
94 _location.abeam = false;
95 }
96 }
97 selected: _location.useCarrierFLOLS && (!_location.abeam)
98 }
99
100 StyledText {
101 text: qsTr("On final approach")
102 anchors.verticalCenter: parent.verticalCenter
103 enabled: flolsRadio.selected
104 }
105 }
106
107 // Abeam the FLOLS
108 Row {
109 anchors.left: parent.left
110 anchors.leftMargin: Style.margin
111 anchors.right: parent.right
112 anchors.rightMargin: Style.margin
113 spacing: Style.margin
114
115 RadioButton {
116 id: abeamRadio
117 anchors.verticalCenter: parent.verticalCenter
118 group: radioGroup
119 onClicked: {
120 if (selected) _location.abeam = _location.useCarrierFLOLS = true
121 }
122 selected: _location.abeam
123 }
124
125 StyledText {
126 text: qsTr("Abeam carrier at 180 degrees")
127 anchors.verticalCenter: parent.verticalCenter
128 enabled: abeamRadio.selected
129 }
130 }
131
132
133 // parking row
134 Row {
135 anchors.left: parent.left
136 anchors.leftMargin: Style.margin
137 anchors.right: parent.right
138 anchors.rightMargin: Style.margin
139 spacing: Style.margin
140
141 // hide if there's no parking locations defined for this carrier
142 visible: _location.carrierParkings.length > 0
143
144 RadioButton {
145 id: parkingRadio
146 anchors.verticalCenter: parent.verticalCenter
147 group: radioGroup
148 onClicked: {
149 if (selected) {
150 parkingChoice.setLocation();
151 _location.useCarrierFLOLS = false;
152 _location.abeam = false;
153 }
154 }
155 selected : (! _location.abeam) && (! _location.useCarrierFLOLS)
156 }
157
158 StyledText {
159 text: qsTr("On deck")
160 anchors.verticalCenter: parent.verticalCenter
161 enabled: parkingRadio.selected
162 }
163
164 PopupChoice {
165 id: parkingChoice
166 model: _location.carrierParkings
167 // displayRole: "modelData"
168 width: parent.width * 0.5
169 anchors.verticalCenter: parent.verticalCenter
170 enabled: parkingRadio.selected
171
172 onCurrentIndexChanged: {
173 setLocation();
174 }
175
176 function syncCurrentIndex()
177 {
178 for (var i=0; i < _location.carrierParkings.length; ++i) {
179 if (_location.carrierParkings[i] === _location.carrierParking) {
180 currentIndex = i;
181 return;
182 }
183 }
184
185 // not found, default to available
186 currentIndex = 0;
187 }
188
189 function setLocation()
190 {
191 _location.carrierParking = _location.carrierParkings[currentIndex]
192 //diagram.selection = _location.airportParkings[currentIndex]
193 }
194 }
195 }
196 }
197
198 Column {
199 id: offsetGrid
200 spacing: Style.margin
201 anchors.leftMargin: Style.margin
202 anchors.right: parent.right
203 anchors.rightMargin: Style.margin
204 width: parent.width * 0.7
205 anchors.verticalCenter: parent.verticalCenter
206
207 // Offset selection
208 readonly property bool offsetEnabled: (flolsRadio.selected || abeamRadio.selected)
209
210 Row {
211 anchors.right: parent.right
212 anchors.left: parent.left
213 anchors.leftMargin: Style.margin
214 anchors.rightMargin: Style.margin
215 width : parent.width * 0.7
216
217 NumericalEdit {
218 id: offsetNmEdit
219 quantity: _location.offsetDistance
220 onCommit: _location.offsetDistance = newValue;
221 label: qsTr("at")
222 unitsMode: Units.Distance
223 live: true
224 anchors.verticalCenter: parent.verticalCenter
225 enabled: offsetGrid.offsetEnabled
226 }
227
228 StyledText {
229 text: qsTr(" from the FLOLS (aka the ball)")
230 anchors.verticalCenter: parent.verticalCenter
231 enabled: offsetGrid.offsetEnabled
232 }
233 }
234
235 Row {
236 anchors.right: parent.right
237 anchors.left: parent.left
238 anchors.leftMargin: Style.margin
239 anchors.rightMargin: Style.margin
240 width : parent.width * 0.7
241
242 ToggleSwitch {
243 id: airspeedToggle
244 enabled: offsetGrid.offsetEnabled
245 checked: _location.speedEnabled
246 onCheckedChanged: _location.speedEnabled = checked;
247 anchors.verticalCenter: parent.verticalCenter
248 }
249
250 NumericalEdit {
251 id: airspeedSpinbox
252 label: qsTr("Airspeed:")
253 unitsMode: Units.SpeedWithoutMach
254 enabled: _location.speedEnabled && offsetGrid.offsetEnabled
255 quantity: _location.airspeed
256 onCommit: _location.airspeed = newValue
257 anchors.verticalCenter: parent.verticalCenter
258 }
259
260 Item {
261 height: 1; width: Style.strutSize
262 }
263
264 LocationAltitudeRow
265 {
266 enabled: offsetGrid.offsetEnabled
267 width: parent.width
268 }
269
270 } // of Offset selection
271
272 ToggleSwitch {
273 anchors.left: parent.left
274 anchors.right: parent.right
275 anchors.leftMargin: Style.margin
276 label: qsTr("Tune navigation radio (TACAN) to carrier")
277 checked: _location.tuneNAV1
278 onCheckedChanged: {
279 _location.tuneNAV1 = checked
280 }
281 }
282 } // main layout column
283 } // main panel rectangle
284 }