Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Dialogs 1.2
import QtGraphicalEffects 1.0
import QGroundControl 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.Controls 1.0
import QGroundControl.Palette 1.0
import QGroundControl.Vehicle 1.0
import QGroundControl.Controllers 1.0
import QGroundControl.FactSystem 1.0
import QGroundControl.FactControls 1.0
Rectangle {
id: mainRect
height: mainRow.height + (ScreenTools.defaultFontPixelWidth * 2)
width: mainRow.width + (ScreenTools.defaultFontPixelWidth * 2)
radius: ScreenTools.defaultFontPixelWidth * 0.5
color: qgcPal.globalTheme === QGCPalette.Light ? Qt.rgba(1,1,1,0.95) : Qt.rgba(0,0,0,0.75)
border.width: 1
border.color: qgcPal.globalTheme === QGCPalette.Light ? Qt.rgba(0,0,0,0.35) : Qt.rgba(1,1,1,0.35)
QGCPalette { id: qgcPal; colorGroupEnabled: true }
property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
property var _dynamicCameras: _activeVehicle ? _activeVehicle.dynamicCameras : null
property bool _isCamera: _dynamicCameras ? _dynamicCameras.cameras.count > 0 : false
property bool _cameraModeUndefined: _isCamera ? _dynamicCameras.cameras.get(0).cameraMode === QGCCameraControl.CAMERA_MODE_UNDEFINED : true
property bool _cameraVideoMode: _isCamera ? _dynamicCameras.cameras.get(0).cameraMode === QGCCameraControl.CAMERA_MODE_VIDEO : false
property bool _cameraPhotoMode: _isCamera ? _dynamicCameras.cameras.get(0).cameraMode === QGCCameraControl.CAMERA_MODE_PHOTO : false
property var _camera: _isCamera ? _dynamicCameras.cameras.get(0) : null // Single camera support for the time being
property real _spacers: ScreenTools.defaultFontPixelHeight * 0.5
property real _labelFieldWidth: ScreenTools.defaultFontPixelWidth * 30
property real _editFieldWidth: ScreenTools.defaultFontPixelWidth * 30
property bool _communicationLost: _activeVehicle ? _activeVehicle.connectionLost : false
property bool _hasModes: _isCamera && _camera && _camera.hasModes
MouseArea {
anchors.fill: parent
onWheel: { wheel.accepted = true; }
onPressed: { mouse.accepted = true; }
onReleased: { mouse.accepted = true; }
}
Connections {
target: QGroundControl.multiVehicleManager.activeVehicle
onConnectionLostChanged: {
if(_communicationLost) {
if(rootLoader.sourceComponent === cameraSettingsComponent) {
rootLoader.sourceComponent = null
}
}
}
}
Row {
id: mainRow
spacing: _spacers
anchors.centerIn: parent
Column {
spacing: _spacers
anchors.verticalCenter: parent.verticalCenter
//-----------------------------------------------------------------
QGCLabel {
id: cameraLabel
text: _isCamera ? _dynamicCameras.cameras.get(0).modelName : qsTr("Camera")
font.pointSize: ScreenTools.smallFontPointSize
anchors.horizontalCenter: parent.horizontalCenter
}
//-- Camera Mode (visible only if camera has modes)
Rectangle {
width: _hasModes ? ScreenTools.defaultFontPixelWidth * 12 : 0
height: _hasModes ? ScreenTools.defaultFontPixelWidth * 4 : 0
color: qgcPal.window
radius: height * 0.5
visible: _hasModes
anchors.horizontalCenter: parent.horizontalCenter
//-- Video Mode
Rectangle {
width: parent.height * 0.9
height: parent.height * 0.9
color: qgcPal.windowShadeDark
radius: height * 0.5
anchors.left: parent.left
anchors.leftMargin: 4
anchors.verticalCenter: parent.verticalCenter
QGCColoredImage {
anchors.fill: parent
source: "/qmlimages/camera_video.svg"
fillMode: Image.PreserveAspectFit
sourceSize.height: height
color: _cameraVideoMode ? qgcPal.colorGreen : qgcPal.text
MouseArea {
anchors.fill: parent
enabled: _cameraPhotoMode
onClicked: {
_camera.setVideoMode()
}
}
}
}
//-- Photo Mode
Rectangle {
width: parent.height * 0.9
height: parent.height * 0.9
color: qgcPal.window
radius: height * 0.5
anchors.right: parent.right
anchors.rightMargin: 4
anchors.verticalCenter: parent.verticalCenter
QGCColoredImage {
anchors.fill: parent
source: "/qmlimages/camera_photo.svg"
fillMode: Image.PreserveAspectFit
sourceSize.height: height
color: _cameraPhotoMode ? qgcPal.colorGreen : qgcPal.text
MouseArea {
anchors.fill: parent
enabled: _cameraVideoMode
onClicked: {
_camera.setPhotoMode()
}
}
}
}
}
//-- Settings
QGCColoredImage {
width: ScreenTools.defaultFontPixelWidth * 3
height: width
sourceSize.width: width
source: "/qmlimages/camera_settings.svg"
fillMode: Image.PreserveAspectFit
color: _cameraModeUndefined ? qgcPal.colorGrey : qgcPal.text
anchors.horizontalCenter: parent.horizontalCenter
MouseArea {
anchors.fill: parent
enabled: !_cameraModeUndefined
onClicked: {
if(rootLoader.sourceComponent === null) {
rootLoader.sourceComponent = cameraSettingsComponent
} else {
rootLoader.sourceComponent = null
}
}
}
}
}
//-- Shutter
Rectangle {
color: Qt.rgba(0,0,0,0)
width: ScreenTools.defaultFontPixelWidth * 6
height: width
radius: width * 0.5
border.color: qgcPal.buttonText
border.width: 3
anchors.verticalCenter: parent.verticalCenter
Rectangle {
width: parent.width * 0.75
height: width
radius: width * 0.5
color: _cameraModeUndefined ? qgcPal.colorGrey : qgcPal.colorRed
anchors.centerIn: parent
}
MouseArea {
anchors.fill: parent
enabled: !_cameraModeUndefined
onClicked: {
if(_cameraVideoMode) {
//-- Start/Stop Video
} else {
_camera.takePhoto()
}
}
}
}
}
Component {
id: cameraSettingsComponent
Item {
id: cameraSettingsRect
width: mainWindow.width
height: mainWindow.height
anchors.centerIn: parent
MouseArea {
anchors.fill: parent
onClicked: {
rootLoader.sourceComponent = null
}
}
Rectangle {
id: camSettingsRect
width: _labelFieldWidth + _editFieldWidth + (ScreenTools.defaultFontPixelWidth * 8)
height: Math.max(mainWindow.height * 0.65, ScreenTools.defaultFontPixelHeight * 20)
radius: ScreenTools.defaultFontPixelWidth
color: qgcPal.globalTheme === QGCPalette.Light ? Qt.rgba(1,1,1,0.95) : Qt.rgba(0,0,0,0.75)
border.width: 1
border.color: qgcPal.globalTheme === QGCPalette.Light ? Qt.rgba(0,0,0,0.35) : Qt.rgba(1,1,1,0.35)
anchors.centerIn: parent
QGCLabel {
id: cameraSettingsLabel
text: _cameraVideoMode ? qsTr("Video Settings") : qsTr("Camera Settings")
font.family: ScreenTools.demiboldFontFamily
font.pointSize: ScreenTools.mediumFontPointSize
anchors.margins: ScreenTools.defaultFontPixelHeight * 0.5
anchors.top: parent.top
anchors.left: parent.left
}
QGCFlickable {
clip: true
anchors.top: cameraSettingsLabel.bottom
anchors.topMargin: ScreenTools.defaultFontPixelHeight
anchors.bottom: parent.bottom
width: cameraSettingsCol.width
contentHeight: cameraSettingsCol.height
contentWidth: cameraSettingsCol.width
anchors.horizontalCenter: parent.horizontalCenter
Column {
id: cameraSettingsCol
spacing: ScreenTools.defaultFontPixelHeight * 0.5
width: camSettingsRect.width
anchors.margins: ScreenTools.defaultFontPixelHeight
//-------------------------------------------
//-- Camera Settings
Repeater {
model: _camera ? _camera.activeSettings : []
Row {
spacing: ScreenTools.defaultFontPixelWidth
anchors.horizontalCenter: parent.horizontalCenter
QGCLabel {
text: _camera.getFact(modelData).shortDescription
width: _labelFieldWidth
anchors.verticalCenter: parent.verticalCenter
}
FactComboBox {
width: _editFieldWidth
fact: _camera.getFact(modelData)
indexModel: false
visible: !_camera.getFact(modelData).typeIsBool
anchors.verticalCenter: parent.verticalCenter
}
Item {
width: _editFieldWidth
height: factSwitch.height
visible: _camera.getFact(modelData).typeIsBool
anchors.verticalCenter: parent.verticalCenter
Switch {
id: factSwitch
anchors.left: parent.left
checked: fact ? fact.value : false
onClicked: fact.value = checked ? 1 : 0
property var fact: _camera.getFact(modelData)
}
}
}
}
//-------------------------------------------
//-- Reset Camera
Row {
spacing: ScreenTools.defaultFontPixelWidth
anchors.horizontalCenter: parent.horizontalCenter
QGCLabel {
text: qsTr("Reset Camera Defaults")
width: _labelFieldWidth
anchors.verticalCenter: parent.verticalCenter
}
QGCButton {
text: qsTr("Reset")
onClicked: resetPrompt.open()
width: _editFieldWidth
anchors.verticalCenter: parent.verticalCenter
MessageDialog {
id: resetPrompt
title: qsTr("Reset Camera to Factory Settings")
text: qsTr("Confirm resetting all settings?")
standardButtons: StandardButton.Yes | StandardButton.No
onNo: resetPrompt.close()
onYes: {
// TODO
resetPrompt.close()
}
}
}
}
//-------------------------------------------
//-- Format Storage
Row {
spacing: ScreenTools.defaultFontPixelWidth
anchors.horizontalCenter: parent.horizontalCenter
QGCLabel {
text: qsTr("Storage")
width: _labelFieldWidth
anchors.verticalCenter: parent.verticalCenter
}
QGCButton {
text: qsTr("Format")
enabled: false
onClicked: formatPrompt.open()
width: _editFieldWidth
anchors.verticalCenter: parent.verticalCenter
MessageDialog {
id: formatPrompt
title: qsTr("Format Camera Storage")
text: qsTr("Confirm erasing all files?")
standardButtons: StandardButton.Yes | StandardButton.No
onNo: formatPrompt.close()
onYes: {
// TODO
formatPrompt.close()
}
}
}
}
}
}
}
Component.onCompleted: {
rootLoader.width = cameraSettingsRect.width
rootLoader.height = cameraSettingsRect.height
}
Keys.onBackPressed: {
rootLoader.sourceComponent = null
}
Keys.onEscapePressed: {
rootLoader.sourceComponent = null
}
}
}
}