Commit 8448a75a authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #4886 from DonLakeFlyer/SafetySizing

Setup-Safety: sizing and positining for all font and screen size possibilities
parents c46b0b03 a2329358
......@@ -97,9 +97,12 @@ const QVariantList& PX4AutoPilotPlugin::vehicleComponents(void)
_tuningComponent->setupTriggerSignals();
_components.append(QVariant::fromValue((VehicleComponent*)_tuningComponent));
#if 0
// Coming soon
_mixersComponent = new MixersComponent(_vehicle, this);
_mixersComponent->setupTriggerSignals();
_components.append(QVariant::fromValue((VehicleComponent*)_mixersComponent));
#endif
//-- Is there support for cameras?
if(_vehicle->parameterManager()->parameterExists(_vehicle->id(), "TRIG_MODE")) {
......
......@@ -28,8 +28,8 @@ SetupPage {
id: pageComponent
Item {
width: Math.max(availableWidth, mainCol.width)
height: mainCol.height
width: Math.max(availableWidth, outerGrid.width)
height: outerGrid.height
FactPanelController {
id: controller
......@@ -37,8 +37,8 @@ SetupPage {
}
property real _margins: ScreenTools.defaultFontPixelHeight
property real _middleRowWidth: ScreenTools.defaultFontPixelWidth * 20
property real _editFieldWidth: ScreenTools.defaultFontPixelWidth * 14
property real _editFieldWidth: ScreenTools.defaultFontPixelWidth * 20
property real _imageWidth: ScreenTools.defaultFontPixelWidth * 20
property Fact _fenceAction: controller.getParameterFact(-1, "GF_ACTION")
property Fact _fenceRadius: controller.getParameterFact(-1, "GF_MAX_HOR_DIST")
......@@ -50,496 +50,413 @@ SetupPage {
property Fact _disarmLandDelay: controller.getParameterFact(-1, "COM_DISARM_LAND")
property Fact _landSpeedMC: controller.getParameterFact(-1, "MPC_LAND_SPEED", false)
property bool _showIcons: !ScreenTools.isTinyScreen
ExclusiveGroup { id: homeLoiterGroup }
Column {
id: mainCol
spacing: _margins
anchors.horizontalCenter: parent.horizontalCenter
Rectangle {
x: lowBattGrid.x + outerGrid.x - _margins
y: lowBattGrid.y + outerGrid.y - _margins
width: lowBattGrid.width + (_margins * 2)
height: lowBattGrid.height + (_margins * 2)
color: qgcPal.windowShade
}
Rectangle {
x: rcLossGrid.x + outerGrid.x - _margins
y: rcLossGrid.y + outerGrid.y - _margins
width: rcLossGrid.width + (_margins * 2)
height: rcLossGrid.height + (_margins * 2)
color: qgcPal.windowShade
}
Rectangle {
x: dataLinkLossGrid.x + outerGrid.x - _margins
y: dataLinkLossGrid.y + outerGrid.y - _margins
width: dataLinkLossGrid.width + (_margins * 2)
height: dataLinkLossGrid.height + (_margins * 2)
color: qgcPal.windowShade
}
Rectangle {
x: geoFenceGrid.x + outerGrid.x - _margins
y: geoFenceGrid.y + outerGrid.y - _margins
width: geoFenceGrid.width + (_margins * 2)
height: geoFenceGrid.height + (_margins * 2)
color: qgcPal.windowShade
}
Rectangle {
x: returnHomeGrid.x + outerGrid.x - _margins
y: returnHomeGrid.y + outerGrid.y - _margins
width: returnHomeGrid.width + (_margins * 2)
height: returnHomeGrid.height + (_margins * 2)
color: qgcPal.windowShade
}
Rectangle {
x: landModeGrid.x + outerGrid.x - _margins
y: landModeGrid.y + outerGrid.y - _margins
width: landModeGrid.width + (_margins * 2)
height: landModeGrid.height + (_margins * 2)
color: qgcPal.windowShade
}
GridLayout {
id: outerGrid
columns: 3
anchors.horizontalCenter: parent.horizontalCenter
/*
**** Low Battery ****
*/
Item { width: 1; height: _margins * 0.5; }
QGCLabel {
text: qsTr("Low Battery Failsafe Trigger")
font.family: ScreenTools.demiboldFontFamily
text: qsTr("Low Battery Failsafe Trigger")
Layout.columnSpan: 3
}
Rectangle {
color: qgcPal.windowShade
width: rtlSettings.width
height: lowBattRow.height + _margins * 2
Row {
id: lowBattRow
spacing: _margins
anchors.verticalCenter: parent.verticalCenter
Item { width: _margins * 0.5; height: 1; }
Image {
height: ScreenTools.defaultFontPixelWidth * 6
width: ScreenTools.defaultFontPixelWidth * 20
sourceSize.width: width
mipmap: true
fillMode: Image.PreserveAspectFit
source: qgcPal.globalTheme === qgcPal.Light ? "/qmlimages/LowBatteryLight.svg" : "/qmlimages/LowBattery.svg"
anchors.verticalCenter: parent.verticalCenter
visible: _showIcons
}
Item {
width: _margins * 0.5
height: 1
visible: _showIcons
}
Column {
spacing: _margins * 0.5
anchors.verticalCenter: parent.verticalCenter
Row {
QGCLabel {
anchors.baseline: lowBattCombo.baseline
width: _middleRowWidth
text: qsTr("Failsafe Action:")
}
FactComboBox {
id: lowBattCombo
width: _editFieldWidth
fact: _lowBattAction
indexModel: false
}
}
Row {
QGCLabel {
anchors.baseline: batLowLevelField.baseline
width: _middleRowWidth
text: qsTr("Battery Warn Level:")
}
FactTextField {
id: batLowLevelField
fact: controller.getParameterFact(-1, "BAT_LOW_THR")
showUnits: true
width: _editFieldWidth
}
}
Row {
QGCLabel {
anchors.baseline: batCritLevelField.baseline
width: _middleRowWidth
text: qsTr("Battery Failsafe Level:")
}
FactTextField {
id: batCritLevelField
fact: controller.getParameterFact(-1, "BAT_CRIT_THR")
showUnits: true
width: _editFieldWidth
}
}
}
Item { width: 1; height: _margins; Layout.columnSpan: 3 }
Item { width: _margins; height: 1 }
GridLayout {
id: lowBattGrid
columns: 3
Image {
height: ScreenTools.defaultFontPixelWidth * 6
sourceSize.height: height
mipmap: true
fillMode: Image.PreserveAspectFit
source: qgcPal.globalTheme === qgcPal.Light ? "/qmlimages/LowBatteryLight.svg" : "/qmlimages/LowBattery.svg"
Layout.rowSpan: 3
Layout.minimumWidth: _imageWidth
}
QGCLabel {
text: qsTr("Failsafe Action:")
Layout.fillWidth: true
}
FactComboBox {
fact: _lowBattAction
indexModel: false
Layout.minimumWidth: _editFieldWidth
}
QGCLabel {
text: qsTr("Battery Warn Level:")
Layout.fillWidth: true
}
FactTextField {
fact: controller.getParameterFact(-1, "BAT_LOW_THR")
Layout.minimumWidth: _editFieldWidth
}
QGCLabel {
text: qsTr("Battery Failsafe Level:")
Layout.fillWidth: true
}
FactTextField {
fact: controller.getParameterFact(-1, "BAT_CRIT_THR")
Layout.minimumWidth: _editFieldWidth
}
}
/*
**** RC Loss ****
*/
Item { width: 1; height: _margins; Layout.columnSpan: 3 }
QGCLabel {
text: qsTr("RC Loss Failsafe Trigger")
font.family: ScreenTools.demiboldFontFamily
text: qsTr("RC Loss Failsafe Trigger")
Layout.columnSpan: 3
}
Rectangle {
color: qgcPal.windowShade
width: rtlSettings.width
height: rcLossRow.height + _margins * 2
Row {
id: rcLossRow
spacing: _margins
anchors.verticalCenter: parent.verticalCenter
Item { width: _margins * 0.5; height: 1; }
Image {
height: ScreenTools.defaultFontPixelWidth * 6
width: ScreenTools.defaultFontPixelWidth * 20
sourceSize.width: width
mipmap: true
fillMode: Image.PreserveAspectFit
source: qgcPal.globalTheme === qgcPal.Light ? "/qmlimages/RCLossLight.svg" : "/qmlimages/RCLoss.svg"
anchors.verticalCenter: parent.verticalCenter
visible: _showIcons
}
Item {
width: _margins * 0.5
height: 1
visible: _showIcons
}
Column {
spacing: _margins * 0.5
anchors.verticalCenter: parent.verticalCenter
Row {
QGCLabel {
anchors.baseline: rcLossCombo.baseline
width: _middleRowWidth
text: qsTr("Failsafe Action:")
}
FactComboBox {
id: rcLossCombo
width: _editFieldWidth
fact: _rcLossAction
indexModel: false
}
}
Row {
QGCLabel {
anchors.baseline: rcLossField.baseline
width: _middleRowWidth
text: qsTr("RC Loss Timeout:")
}
FactTextField {
id: rcLossField
fact: controller.getParameterFact(-1, "COM_RC_LOSS_T")
showUnits: true
width: _editFieldWidth
}
}
}
Item { width: 1; height: _margins; Layout.columnSpan: 3 }
Item { width: _margins; height: 1 }
GridLayout {
id: rcLossGrid
columns: 3
Image {
height: ScreenTools.defaultFontPixelWidth * 6
sourceSize.height: height
mipmap: true
fillMode: Image.PreserveAspectFit
source: qgcPal.globalTheme === qgcPal.Light ? "/qmlimages/RCLossLight.svg" : "/qmlimages/RCLoss.svg"
Layout.rowSpan: 3
Layout.minimumWidth: _imageWidth
}
QGCLabel {
text: qsTr("Failsafe Action:")
Layout.fillWidth: true
}
FactComboBox {
fact: _rcLossAction
indexModel: false
Layout.minimumWidth: _editFieldWidth
}
QGCLabel {
text: qsTr("RC Loss Timeout:")
Layout.fillWidth: true
}
FactTextField {
fact: controller.getParameterFact(-1, "COM_RC_LOSS_T")
Layout.minimumWidth: _editFieldWidth
}
}
/*
**** Data Link Loss ****
*/
Item { width: 1; height: _margins; Layout.columnSpan: 3 }
QGCLabel {
text: qsTr("Data Link Loss Failsafe Trigger")
font.family: ScreenTools.demiboldFontFamily
text: qsTr("Data Link Loss Failsafe Trigger")
Layout.columnSpan: 3
}
Rectangle {
color: qgcPal.windowShade
width: rtlSettings.width
height: dlLossRow.height + _margins * 2
Row {
id: dlLossRow
spacing: _margins
anchors.verticalCenter: parent.verticalCenter
Item { width: _margins * 0.5; height: 1; }
Image {
height: ScreenTools.defaultFontPixelWidth * 6
width: ScreenTools.defaultFontPixelWidth * 20
sourceSize.width: width
mipmap: true
fillMode: Image.PreserveAspectFit
source: qgcPal.globalTheme === qgcPal.Light ? "/qmlimages/DatalinkLossLight.svg" : "/qmlimages/DatalinkLoss.svg"
anchors.verticalCenter: parent.verticalCenter
visible: _showIcons
}
Item {
width: _margins * 0.5
height: 1
visible: _showIcons
}
Column {
spacing: _margins * 0.5
anchors.verticalCenter: parent.verticalCenter
Row {
QGCLabel {
anchors.baseline: dlLossCombo.baseline
width: _middleRowWidth
text: qsTr("Failsafe Action:")
}
FactComboBox {
id: dlLossCombo
width: _editFieldWidth
fact: _dlLossAction
indexModel: false
}
}
Row {
QGCLabel {
anchors.baseline: dlLossField.baseline
width: _middleRowWidth
text: qsTr("Data Link Loss Timeout:")
}
FactTextField {
id: dlLossField
fact: controller.getParameterFact(-1, "COM_DL_LOSS_T")
showUnits: true
width: _editFieldWidth
}
}
}
Item { width: 1; height: _margins; Layout.columnSpan: 3 }
Item { width: _margins; height: 1 }
GridLayout {
id: dataLinkLossGrid
columns: 3
Image {
height: ScreenTools.defaultFontPixelWidth * 6
sourceSize.height: height
mipmap: true
fillMode: Image.PreserveAspectFit
source: qgcPal.globalTheme === qgcPal.Light ? "/qmlimages/DatalinkLossLight.svg" : "/qmlimages/DatalinkLoss.svg"
Layout.rowSpan: 3
Layout.minimumWidth: _imageWidth
}
QGCLabel {
text: qsTr("Failsafe Action:")
Layout.fillWidth: true
}
FactComboBox {
fact: _dlLossAction
indexModel: false
Layout.minimumWidth: _editFieldWidth
}
QGCLabel {
text: qsTr("Data Link Loss Timeout:")
Layout.fillWidth: true
}
FactTextField {
fact: controller.getParameterFact(-1, "COM_DL_LOSS_T")
Layout.minimumWidth: _editFieldWidth
}
}
/*
**** Geofence ****
*/
Item { width: 1; height: _margins; Layout.columnSpan: 3 }
QGCLabel {
text: qsTr("Geofence Failsafe Trigger")
font.family: ScreenTools.demiboldFontFamily
text: qsTr("Geofence Failsafe Trigger")
Layout.columnSpan: 3
}
Rectangle {
color: qgcPal.windowShade
width: rtlSettings.width
height: geofenceRow.height + _margins * 2
Row {
id: geofenceRow
spacing: _margins
anchors.verticalCenter: parent.verticalCenter
Item { width: _margins * 0.5; height: 1; }
Image {
height: ScreenTools.defaultFontPixelWidth * 8
width: ScreenTools.defaultFontPixelWidth * 20
sourceSize.width: width
mipmap: true
fillMode: Image.PreserveAspectFit
source: qgcPal.globalTheme === qgcPal.Light ? "/qmlimages/GeoFenceLight.svg" : "/qmlimages/GeoFence.svg"
anchors.verticalCenter: parent.verticalCenter
visible: _showIcons
}
Item {
width: _margins * 0.5
height: 1
visible: _showIcons
}
Column {
spacing: _margins * 0.5
anchors.verticalCenter: parent.verticalCenter
Row {
QGCLabel {
id: fenceActionLabel
anchors.baseline: fenceActionCombo.baseline
text: qsTr("Action on breach:")
width: _middleRowWidth
}
FactComboBox {
id: fenceActionCombo
width: _editFieldWidth
fact: _fenceAction
indexModel: false
}
}
Row {
QGCCheckBox {
id: fenceRadiusCheckBox
anchors.baseline: fenceRadiusField.baseline
text: qsTr("Max radius:")
checked: _fenceRadius.value > 0
onClicked: _fenceRadius.value = checked ? 100 : 0
width: _middleRowWidth
}
FactTextField {
id: fenceRadiusField
showUnits: true
fact: _fenceRadius
enabled: fenceRadiusCheckBox.checked
width: _editFieldWidth
}
}
Row {
QGCCheckBox {
id: fenceAltMaxCheckBox
anchors.baseline: fenceAltMaxField.baseline
text: qsTr("Max altitude:")
checked: _fenceAlt ? _fenceAlt.value > 0 : false
onClicked: _fenceAlt.value = checked ? 100 : 0
width: _middleRowWidth
}
FactTextField {
id: fenceAltMaxField
showUnits: true
fact: _fenceAlt
enabled: fenceAltMaxCheckBox.checked
width: _editFieldWidth
}
}
}
Item { width: 1; height: _margins; Layout.columnSpan: 3 }
Item { width: _margins; height: 1 }
GridLayout {
id: geoFenceGrid
columns: 3
Image {
height: ScreenTools.defaultFontPixelWidth * 10
sourceSize.height: height
mipmap: true
fillMode: Image.PreserveAspectFit
source: qgcPal.globalTheme === qgcPal.Light ? "/qmlimages/GeoFenceLight.svg" : "/qmlimages/GeoFence.svg"
Layout.rowSpan: 3
Layout.minimumWidth: _imageWidth
}
QGCLabel {
text: qsTr("Action on breach:")
Layout.fillWidth: true
}
FactComboBox {
fact: _fenceAction
indexModel: false
Layout.minimumWidth: _editFieldWidth
}
QGCCheckBox {
id: fenceRadiusCheckBox
text: qsTr("Max radius:")
checked: _fenceRadius.value > 0
onClicked: _fenceRadius.value = checked ? 100 : 0
Layout.fillWidth: true
}
FactTextField {
fact: _fenceRadius
enabled: fenceRadiusCheckBox.checked
Layout.minimumWidth: _editFieldWidth
}
QGCCheckBox {
id: fenceAltMaxCheckBox
text: qsTr("Max altitude:")
checked: _fenceAlt ? _fenceAlt.value > 0 : false
onClicked: _fenceAlt.value = checked ? 100 : 0
Layout.fillWidth: true
}
FactTextField {
fact: _fenceAlt
enabled: fenceAltMaxCheckBox.checked
Layout.minimumWidth: _editFieldWidth
}
}
/*
**** Return Home Settings ****
*/
Item { width: 1; height: _margins; Layout.columnSpan: 3 }
QGCLabel {
id: rtlLabel
text: qsTr("Return Home Settings")
font.family: ScreenTools.demiboldFontFamily
text: qsTr("Return Home Settings")
Layout.columnSpan: 3
}
Rectangle {
id: rtlSettings
color: qgcPal.windowShade
width: rtlRow.width + _margins * 2
height: rtlRow.height + _margins * 2
Item { width: 1; height: _margins; Layout.columnSpan: 3 }
Item { width: _margins; height: 1 }
GridLayout {
id: returnHomeGrid
columns: 3
QGCColoredImage {
color: qgcPal.text
height: ScreenTools.defaultFontPixelWidth * 10
sourceSize.height: height
mipmap: true
fillMode: Image.PreserveAspectFit
source: controller.vehicle.fixedWing ? "/qmlimages/ReturnToHomeAltitude.svg" : "/qmlimages/ReturnToHomeAltitudeCopter.svg"
Layout.rowSpan: 7
Layout.minimumWidth: _imageWidth
}
QGCLabel {
text: qsTr("Climb to altitude of:")
Layout.fillWidth: true
}
FactTextField {
fact: controller.getParameterFact(-1, "RTL_RETURN_ALT")
Layout.minimumWidth: _editFieldWidth
}
QGCLabel {
text: qsTr("Return home, then:")
Layout.columnSpan: 2
}
Row {
id: rtlRow
spacing: _margins
anchors.verticalCenter: parent.verticalCenter
Item { width: _margins * 0.5; height: 1; }
QGCColoredImage {
id: icon
color: qgcPal.text
height: ScreenTools.defaultFontPixelWidth * 10
width: ScreenTools.defaultFontPixelWidth * 20
sourceSize.width: width
mipmap: true
fillMode: Image.PreserveAspectFit
source: controller.vehicle.fixedWing ? "/qmlimages/ReturnToHomeAltitude.svg" : "/qmlimages/ReturnToHomeAltitudeCopter.svg"
anchors.verticalCenter: parent.verticalCenter
visible: _showIcons
Layout.columnSpan: 2
Item { width: ScreenTools.defaultFontPixelWidth; height: 1 }
QGCRadioButton {
id: homeLandRadio
checked: _rtlLandDelay ? _rtlLandDelay.value === 0 : false
exclusiveGroup: homeLoiterGroup
text: qsTr("Land immediately")
onClicked: _rtlLandDelay.value = 0
}
Item {
width: _margins * 0.5
height: 1
visible: _showIcons
}
Row {
Layout.columnSpan: 2
Item { width: ScreenTools.defaultFontPixelWidth; height: 1 }
QGCRadioButton {
id: homeLoiterNoLandRadio
checked: _rtlLandDelay ? _rtlLandDelay.value < 0 : false
exclusiveGroup: homeLoiterGroup
text: qsTr("Loiter and do not land")
onClicked: _rtlLandDelay.value = -1
}
Column {
spacing: _margins * 0.5
Row {
QGCLabel {
id: climbLabel
anchors.baseline: climbField.baseline
width: _middleRowWidth
text: qsTr("Climb to altitude of:")
}
FactTextField {
id: climbField
fact: controller.getParameterFact(-1, "RTL_RETURN_ALT")
showUnits: true
width: _editFieldWidth
}
}
Item { width: 1; height: _margins * 0.5; }
QGCLabel {
id: returnHomeLabel
text: "Return home, then:"
}
Row {
Item { height: 1; width: _margins; }
Column {
spacing: _margins * 0.5
ExclusiveGroup { id: homeLoiterGroup }
QGCRadioButton {
id: homeLandRadio
checked: _rtlLandDelay ? _rtlLandDelay.value === 0 : false
exclusiveGroup: homeLoiterGroup
text: "Land immediately"
onClicked: _rtlLandDelay.value = 0