Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 51 additions & 39 deletions src/FactSystem/FactControls/FactTextFieldSlider.qml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import QGroundControl
import QGroundControl.Controls
import QGroundControl.FactControls

ColumnLayout {
Rectangle {
property alias label: factTextField.label
property alias fact: factTextField.fact
property alias textFieldPreferredWidth: factTextField.textFieldPreferredWidth
Expand All @@ -16,15 +16,19 @@ ColumnLayout {
property alias textField: factTextField
property alias enableCheckBoxChecked: enableCheckbox.checked

property bool showEnableCheckbox: false ///< true: show enable/disable checkbox, false: hide
property bool showEnableCheckbox: false ///< true: show enable/disable checkbox, false: hide
property color backgroundColor: _ftfsBackgroundColor

signal enableCheckboxClicked

id: control
spacing: 0
id: control
implicitHeight: mainLayout.implicitHeight
color: backgroundColor
radius: ScreenTools.defaultBorderRadius

property bool _loadComplete: false
property bool _showSlider: fact.userMin !== undefined && fact.userMax !== undefined
property bool _loadComplete: false
property bool _showSlider: fact.userMin !== undefined && fact.userMax !== undefined
property color _ftfsBackgroundColor: Qt.rgba(qgcPal.windowShadeLight.r, qgcPal.windowShadeLight.g, qgcPal.windowShadeLight.b, 0.2)

function updateSliderToClampedValue() {
if (_showSlider && sliderLoader.item) {
Expand All @@ -47,50 +51,58 @@ ColumnLayout {
target: control.fact

function onValueChanged() {
updateSliderToClampedValue()
control.updateSliderToClampedValue()
}
}

RowLayout {
spacing: ScreenTools.defaultFontPixelWidth
QGCPalette { id: qgcPal; colorGroupEnabled: true }

QGCCheckBox {
id: enableCheckbox
visible: control.showEnableCheckbox
ColumnLayout {
id: mainLayout
width: parent.width
spacing: 0

onClicked: control.enableCheckboxClicked()
RowLayout {
spacing: ScreenTools.defaultFontPixelWidth

QGCCheckBox {
id: enableCheckbox
visible: control.showEnableCheckbox

onClicked: control.enableCheckboxClicked()
}

LabelledFactTextField {
id: factTextField
Layout.fillWidth: true
label: control.label
fact: control.fact
enabled: !control.showEnableCheckbox || enableCheckbox.checked
}
}

LabelledFactTextField {
id: factTextField
Loader {
id: sliderLoader
Layout.fillWidth: true
label: control.label
fact: control.fact
sourceComponent: control._showSlider ? sliderComponent : null
enabled: !control.showEnableCheckbox || enableCheckbox.checked
}
}

Loader {
id: sliderLoader
Layout.fillWidth: true
sourceComponent: control._showSlider ? sliderComponent : null
enabled: !control.showEnableCheckbox || enableCheckbox.checked
}

Component {
id: sliderComponent

QGCSlider {
id: slider
Layout.fillWidth: true
from: control.fact.userMin
to: control.fact.userMax
mouseWheelSupport: false
showBoundaryValues: true

onMoved: {
if (control._loadComplete) {
control.fact.value = slider.value
Component {
id: sliderComponent

QGCSlider {
id: slider
Layout.fillWidth: true
from: control.fact.userMin
to: control.fact.userMax
mouseWheelSupport: false
showBoundaryValues: true

onMoved: {
if (control._loadComplete) {
control.fact.value = slider.value
}
}
}
}
Expand Down
44 changes: 24 additions & 20 deletions src/MissionManager/CameraSection.FactMetaData.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,60 +4,64 @@
"QGC.MetaData.Facts":
[
{
"name": "CameraAction",
"shortDesc": "Specify whether the camera should take photos or video",
"type": "uint32",
"enumStrings": "No change,Take photo,Take photos (time),Take photos (distance),Stop taking photos,Start recording video,Stop recording video",
"enumValues": "0,6,1,2,3,4,5",
"default": 0
"name": "CameraAction",
"shortDesc": "Specify whether the camera should take photos or video",
"type": "uint32",
"enumStrings": "No change,Take photo,Take photos (time),Take photos (distance),Stop taking photos,Start recording video,Stop recording video",
"enumValues": "0,6,1,2,3,4,5",
"default": 0
},
{
"name": "CameraPhotoIntervalDistance",
"shortDesc": "Specify the distance between each photo",
"shortDesc": "Specify the distance between each photo",
"type": "double",
"units": "m",
"min": 0.1,
"decimalPlaces": 1,
"default": 1
"default": 1
},
{
"name": "CameraPhotoIntervalTime",
"shortDesc": "Specify the time between each photo",
"shortDesc": "Specify the time between each photo",
"type": "uint32",
"units": "secs",
"min": 1,
"decimalPlaces": 0,
"default": 10
"default": 10
},
{
"name": "GimbalPitch",
"shortDesc": "Gimbal pitch rotation.",
"shortDesc": "Gimbal pitch rotation.",
"type": "double",
"units": "gimbal-degrees",
"min": -90,
"max": 0,
"userMin": -90,
"userMax": 0,
"increment": 5,
"decimalPlaces": 0,
"default": 0
"default": 0
},
{
"name": "GimbalYaw",
"shortDesc": "Gimbal yaw rotation.",
"shortDesc": "Gimbal yaw rotation.",
"type": "double",
"units": "deg",
"min": -180.0,
"max": 180.0,
"userMin": -180.0,
"userMax": 180.0,
"increment": 5,
"decimalPlaces": 0,
"default": 0
"default": 0
},
{
"name": "CameraMode",
"shortDesc": "Specify whether the camera should switch to Photo, Video or Survey mode",
"type": "uint32",
"enumStrings": "Photo,Video,Survey",
"enumValues": "0,1,2",
"default": 0
"name": "CameraMode",
"shortDesc": "Specify whether the camera should switch to Photo, Video or Survey mode",
"type": "uint32",
"enumStrings": "Photo,Video,Survey",
"enumValues": "0,1,2",
"default": 0
}
]
}
125 changes: 46 additions & 79 deletions src/QmlControls/CameraSection.qml
Original file line number Diff line number Diff line change
Expand Up @@ -3,91 +3,67 @@ import QtQuick.Controls
import QtQuick.Layouts

import QGroundControl

import QGroundControl.Controls
import QGroundControl.FactControls


// Camera section for mission item editors
Column {
anchors.left: parent.left
anchors.right: parent.right
spacing: _margin
property alias buttonGroup: cameraSectionHeader.buttonGroup
property alias showSpacer: cameraSectionHeader.showSpacer
property alias checked: cameraSectionHeader.checked

property alias buttonGroup: cameraSectionHeader.buttonGroup
property alias showSpacer: cameraSectionHeader.showSpacer
property alias checked: cameraSectionHeader.checked
spacing: _margin

property var _camera: missionItem.cameraSection
property real _fieldWidth: ScreenTools.defaultFontPixelWidth * 16
property real _margin: ScreenTools.defaultFontPixelWidth / 2

SectionHeader {
id: cameraSectionHeader
anchors.left: parent.left
anchors.right: parent.right
width: parent.width
text: qsTr("Camera")
checked: false
}

Column {
anchors.left: parent.left
anchors.right: parent.right
spacing: _margin
visible: cameraSectionHeader.checked

FactComboBox {
id: cameraActionCombo
anchors.left: parent.left
anchors.right: parent.right
fact: _camera.cameraAction
indexModel: false
width: parent.width
spacing: _margin
visible: cameraSectionHeader.checked

LabelledFactComboBox {
id: cameraActionCombo
width: parent.width
label: qsTr("Action")
fact: _camera.cameraAction
indexModel: false
}

RowLayout {
anchors.left: parent.left
anchors.right: parent.right
spacing: ScreenTools.defaultFontPixelWidth
visible: _camera.cameraAction.rawValue === 1

QGCLabel {
text: qsTr("Time")
Layout.fillWidth: true
}
FactTextField {
fact: _camera.cameraPhotoIntervalTime
Layout.preferredWidth: _fieldWidth
}
LabelledFactTextField {
width: parent.width
label: qsTr("Time")
fact: _camera.cameraPhotoIntervalTime
visible: _camera.cameraAction.rawValue === 1
}

RowLayout {
anchors.left: parent.left
anchors.right: parent.right
spacing: ScreenTools.defaultFontPixelWidth
visible: _camera.cameraAction.rawValue === 2

QGCLabel {
text: qsTr("Distance")
Layout.fillWidth: true
}
FactTextField {
fact: _camera.cameraPhotoIntervalDistance
Layout.preferredWidth: _fieldWidth
}
LabelledFactTextField {
width: parent.width
label: qsTr("Distance")
fact: _camera.cameraPhotoIntervalDistance
visible: _camera.cameraAction.rawValue === 2
}

RowLayout {
anchors.left: parent.left
anchors.right: parent.right
spacing: ScreenTools.defaultFontPixelWidth
visible: _camera.cameraModeSupported
width: parent.width
spacing: ScreenTools.defaultFontPixelWidth
visible: _camera.cameraModeSupported

QGCCheckBox {
id: modeCheckBox
text: qsTr("Mode")
checked: _camera.specifyCameraMode
onClicked: _camera.specifyCameraMode = checked
}

FactComboBox {
fact: _camera.cameraMode
indexModel: false
Expand All @@ -96,34 +72,25 @@ Column {
}
}

GridLayout {
anchors.left: parent.left
anchors.right: parent.right
columnSpacing: ScreenTools.defaultFontPixelWidth / 2
rowSpacing: 0
columns: 3

QGCLabel { text: qsTr("Gimbal") }
QGCLabel { text: qsTr("Pitch") }
QGCLabel { text: qsTr("Yaw") }
QGCCheckBox {
id: gimbalCheckBox
text: qsTr("Gimbal")
checked: _camera.specifyGimbal
onClicked: _camera.specifyGimbal = checked
}

QGCCheckBox {
id: gimbalCheckBox
checked: _camera.specifyGimbal
onClicked: _camera.specifyGimbal = checked
Layout.fillWidth: true
}
FactTextField {
fact: _camera.gimbalPitch
implicitWidth: ScreenTools.defaultFontPixelWidth * 9
enabled: gimbalCheckBox.checked
}
FactTextFieldSlider {
width: parent.width
label: qsTr("Pitch")
fact: _camera.gimbalPitch
enabled: gimbalCheckBox.checked
}

FactTextField {
fact: _camera.gimbalYaw
implicitWidth: ScreenTools.defaultFontPixelWidth * 9
enabled: gimbalCheckBox.checked
}
FactTextFieldSlider {
width: parent.width
label: qsTr("Yaw")
fact: _camera.gimbalYaw
enabled: gimbalCheckBox.checked
}
}
}
Loading
Loading