From cdc273647468c1f36085281c2d6a957fbb8ff870 Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Mon, 6 Apr 2015 09:56:00 -0700 Subject: [PATCH] Use common control for summary rows --- qgroundcontrol.qrc | 2 + .../PX4/AirframeComponentSummary.qml | 43 +++------ .../PX4/FlightModesComponentSummary.qml | 59 ++++-------- .../PX4/PowerComponentSummary.qml | 50 +++-------- .../PX4/RadioComponentSummary.qml | 89 +++++++------------ .../PX4/SafetyComponentSummary.qml | 74 +++++---------- .../PX4/SensorsComponentSummaryFixedWing.qml | 54 ++++------- src/QmlControls/VehicleSummaryRow.qml | 20 +++++ src/QmlControls/qmldir | 1 + 9 files changed, 139 insertions(+), 253 deletions(-) create mode 100644 src/QmlControls/VehicleSummaryRow.qml diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc index 22297cd6d..38d3168b7 100644 --- a/qgroundcontrol.qrc +++ b/qgroundcontrol.qrc @@ -23,9 +23,11 @@ src/QmlControls/QGCComboBox.qml src/QmlControls/QGCColoredImage.qml src/QmlControls/QGCToolBarButton.qml + src/QmlControls/SubMenuButton.qml src/QmlControls/IndicatorButton.qml src/QmlControls/VehicleRotationCal.qml + src/QmlControls/VehicleSummaryRow.qml src/QmlControls/arrow-down.png src/VehicleSetup/SetupViewButtonsConnected.qml diff --git a/src/AutoPilotPlugins/PX4/AirframeComponentSummary.qml b/src/AutoPilotPlugins/PX4/AirframeComponentSummary.qml index d25a8f8f8..7677cb667 100644 --- a/src/AutoPilotPlugins/PX4/AirframeComponentSummary.qml +++ b/src/AutoPilotPlugins/PX4/AirframeComponentSummary.qml @@ -8,43 +8,28 @@ import QGroundControl.Controls 1.0 import QGroundControl.Controllers 1.0 Column { + Fact { id: sysIdFact; name: "MAV_SYS_ID" } + Fact { id: sysAutoStartFact; name: "SYS_AUTOSTART" } + + property bool autoStartSet: sysAutoStartFact.value != 0 + anchors.fill: parent anchors.margins: 8 AirframeComponentController { id: controller } - Row { - width: parent.width - - QGCLabel { id: systemId; text: "System ID:" } - FactLabel { - horizontalAlignment: Text.AlignRight - width: parent.width - systemId.contentWidth - fact: Fact { name: "MAV_SYS_ID" } - } + VehicleSummaryRow { + labelText: "System ID:" + valueText: sysIdFact.valueString } - Row { - width: parent.width - - QGCLabel { id: airframeType; text: "Airframe type:" } - QGCLabel { - property Fact fact: Fact { name: "SYS_AUTOSTART" } - horizontalAlignment: Text.AlignRight - width: parent.width - airframeType.contentWidth - text: fact.value == 0 ? "Setup required" : controller.currentAirframeType - } + VehicleSummaryRow { + labelText: "Airframe type:" + valueText: autoStartSet ? controller.currentAirframeType : "Setup required" } - Row { - width: parent.width - - QGCLabel { id: vehicle; text: "Vehicle:" } - QGCLabel { - property Fact fact: Fact { name: "SYS_AUTOSTART" } - horizontalAlignment: Text.AlignRight - width: parent.width - vehicle.contentWidth - text: fact.value == 0 ? "Setup required" : controller.currentVehicleName - } + VehicleSummaryRow { + labelText: "Vehicle:" + valueText: autoStartSet ? controller.currentVehicleName : "Setup required" } } diff --git a/src/AutoPilotPlugins/PX4/FlightModesComponentSummary.qml b/src/AutoPilotPlugins/PX4/FlightModesComponentSummary.qml index dfd4af9cd..324bcb8ba 100644 --- a/src/AutoPilotPlugins/PX4/FlightModesComponentSummary.qml +++ b/src/AutoPilotPlugins/PX4/FlightModesComponentSummary.qml @@ -6,54 +6,31 @@ import QGroundControl.FactSystem 1.0 import QGroundControl.Controls 1.0 Column { - anchors.fill: parent - anchors.margins: 8 + Fact { id: modeSwFact; name: "RC_MAP_MODE_SW" } + Fact { id: posCtlSwFact; name: "RC_MAP_POSCTL_SW" } + Fact { id: loiterSwFact; name: "RC_MAP_LOITER_SW" } + Fact { id: returnSwFact; name: "RC_MAP_RETURN_SW" } - Component { - id: component + anchors.fill: parent + anchors.margins: 8 - Row { - width: parent.width - - QGCLabel { id: label; text: labelText } - QGCLabel { - property Fact fact: Fact { name: factName } - horizontalAlignment: Text.AlignRight - width: parent.width - label.contentWidth - text: fact.value == 0 ? zeroText : fact.value - } - } - } - - Loader { - property string labelText: "Mode switch:" - property string zeroText: "Setup required" - property string factName: "RC_MAP_MODE_SW" - width: parent.width - sourceComponent: component + VehicleSummaryRow { + labelText: "Mode switch:" + valueText: modeSwFact.value == 0 ? "Setup required" : modeSwFact.valueString } - Loader { - property string labelText: "Position Ctl switch:" - property string zeroText: "Disabled" - property string factName: "RC_MAP_POSCTL_SW" - width: parent.width - sourceComponent: component + VehicleSummaryRow { + labelText: "Position Ctl switch:" + valueText: posCtlSwFact.value == 0 ? "Disabled" : fact.valueString } - Loader { - property string labelText: "Position Ctl switch:" - property string zeroText: "Disabled" - property string factName: "RC_MAP_LOITER_SW" - width: parent.width - sourceComponent: component + VehicleSummaryRow { + labelText: "Position Ctl switch:" + valueText: loiterSwFact.value == 0 ? "Disabled" : fact.valueString } - Loader { - property string labelText: "Return switch:" - property string zeroText: "Disabled" - property string factName: "RC_MAP_RETURN_SW" - width: parent.width - sourceComponent: component + VehicleSummaryRow { + labelText: "Return switch:" + valueText: returnSwFact.value == 0 ? "Disabled" : fact.valueString } } diff --git a/src/AutoPilotPlugins/PX4/PowerComponentSummary.qml b/src/AutoPilotPlugins/PX4/PowerComponentSummary.qml index f2cc77661..6577fe9bc 100644 --- a/src/AutoPilotPlugins/PX4/PowerComponentSummary.qml +++ b/src/AutoPilotPlugins/PX4/PowerComponentSummary.qml @@ -34,47 +34,25 @@ import QGroundControl.FactControls 1.0 import QGroundControl.Controls 1.0 Column { - anchors.fill: parent - anchors.margins: 8 + Fact { id: batVChargedFact; name: "BAT_V_CHARGED" } + Fact { id: batVEmptyFact; name: "BAT_V_EMPTY" } + Fact { id: batCellsFact; name: "BAT_N_CELLS" } - Row { - width: parent.width - QGCLabel { id: battFull; text: "Battery Full:" } - FactLabel { - fact: Fact { name: "BAT_V_CHARGED" } - horizontalAlignment: Text.AlignRight; - width: parent.width - battFull.contentWidth; - } - } + anchors.fill: parent + anchors.margins: 8 - Row { - width: parent.width - QGCLabel { id: battEmpty; text: "Battery Empty:" } - FactLabel { - fact: Fact { name: "BAT_V_EMPTY" } - horizontalAlignment: Text.AlignRight; - width: parent.width - battEmpty.contentWidth; - } + VehicleSummaryRow { + labelText: "Battery Full:" + valueText: batVChargedFact.valueString } - Row { - width: parent.width - QGCLabel { id: battCells; text: "Number of Cells:" } - FactLabel { - fact: Fact { name: "BAT_N_CELLS" } - horizontalAlignment: Text.AlignRight; - width: parent.width - battCells.contentWidth; - } + VehicleSummaryRow { + labelText: "Battery Empty:" + valueText: batVEmptyFact.valueString } - Row { - width: parent.width - QGCLabel { id: battDrop; text: "Voltage Drop:" } - FactLabel { - fact: Fact { name: "BAT_V_LOAD_DROP" } - horizontalAlignment: Text.AlignRight; - width: parent.width - battDrop.contentWidth; - } + VehicleSummaryRow { + labelText: "Number of Cells:" + valueText: batCellsFact.valueString } - } diff --git a/src/AutoPilotPlugins/PX4/RadioComponentSummary.qml b/src/AutoPilotPlugins/PX4/RadioComponentSummary.qml index d6951d586..4038a6161 100644 --- a/src/AutoPilotPlugins/PX4/RadioComponentSummary.qml +++ b/src/AutoPilotPlugins/PX4/RadioComponentSummary.qml @@ -6,78 +6,49 @@ import QGroundControl.FactSystem 1.0 import QGroundControl.Controls 1.0 Column { - anchors.fill: parent - anchors.margins: 8 + Fact { id: mapRollFact; name: "RC_MAP_ROLL" } + Fact { id: mapPitchFact; name: "RC_MAP_PITCH" } + Fact { id: mapYawFact; name: "RC_MAP_YAW" } + Fact { id: mapThrottleFact; name: "RC_MAP_THROTTLE" } + Fact { id: mapFlapsFact; name: "RC_MAP_FLAPS" } + Fact { id: mapAux1Fact; name: "RC_MAP_AUX1" } + Fact { id: mapAux2Fact; name: "RC_MAP_AUX2" } - Component { - id: component + anchors.fill: parent + anchors.margins: 8 - Row { - width: parent.width - - QGCLabel { id: label; text: labelText } - QGCLabel { - Fact { id: fact; name: factName } - horizontalAlignment: Text.AlignRight - width: parent.width - label.contentWidth - text: fact.value == 0 ? zeroText : fact.value - } - } - } - - Loader { - property string labelText: "Roll:" - property string zeroText: "Setup required" - property string factName: "RC_MAP_ROLL" - width: parent.width - sourceComponent: component + VehicleSummaryRow { + labelText: "Roll:" + valueText: mapRollFact.value == 0 ? "Setup required" : mapRollFact.valueString } - Loader { - property string labelText: "Pitch:" - property string zeroText: "Setup required" - property string factName: "RC_MAP_PITCH" - width: parent.width - sourceComponent: component + VehicleSummaryRow { + labelText: "Pitch:" + valueText: mapPitchFact.value == 0 ? "Setup required" : mapPitchFact.valueString } - Loader { - property string labelText: "Yaw:" - property string zeroText: "Setup required" - property string factName: "RC_MAP_YAW" - width: parent.width - sourceComponent: component + VehicleSummaryRow { + labelText: "Yaw:" + valueText: mapYawFact.value == 0 ? "Setup required" : mapYawFact.valueString } - Loader { - property string labelText: "Throttle:" - property string zeroText: "Setup required" - property string factName: "RC_MAP_THROTTLE" - width: parent.width - sourceComponent: component + VehicleSummaryRow { + labelText: "Throttle:" + valueText: mapThrottleFact.value == 0 ? "Setup required" : mapThrottleFact.valueString } - Loader { - property string labelText: "Flaps:" - property string zeroText: "Disabled" - property string factName: "RC_MAP_FLAPS" - width: parent.width - sourceComponent: component + VehicleSummaryRow { + labelText: "Flaps:" + valueText: mapFlapsFact.value == 0 ? "Disabled" : mapFlapsFact.valueString } - Loader { - property string labelText: "Aux1:" - property string zeroText: "Disabled" - property string factName: "RC_MAP_AUX1" - width: parent.width - sourceComponent: component + VehicleSummaryRow { + labelText: "Aux1:" + valueText: mapAux1Fact.value == 0 ? "Disabled" : mapAux1Fact.valueString } - Loader { - property string labelText: "Aux2:" - property string zeroText: "Disabled" - property string factName: "RC_MAP_AUX2" - width: parent.width - sourceComponent: component + VehicleSummaryRow { + labelText: "Aux2:" + valueText: mapAux2Fact.value == 0 ? "Disabled" : mapAux2Fact.valueString } } diff --git a/src/AutoPilotPlugins/PX4/SafetyComponentSummary.qml b/src/AutoPilotPlugins/PX4/SafetyComponentSummary.qml index ab50fbb22..f55be12b6 100644 --- a/src/AutoPilotPlugins/PX4/SafetyComponentSummary.qml +++ b/src/AutoPilotPlugins/PX4/SafetyComponentSummary.qml @@ -7,63 +7,37 @@ import QGroundControl.FactControls 1.0 import QGroundControl.Controls 1.0 Column { - anchors.fill: parent - anchors.margins: 8 - - Row { - width: parent.width - - QGCLabel { id: rtlMinAlt; text: "RTL min alt:" } - FactLabel { - fact: Fact { name: "RTL_RETURN_ALT" } - horizontalAlignment: Text.AlignRight; - width: parent.width - rtlMinAlt.contentWidth; - } + Fact { id: returnAltFact; name: "RTL_RETURN_ALT" } + Fact { id: descendAltFact; name: "RTL_DESCEND_ALT" } + Fact { id: landDelayFact; name: "RTL_LAND_DELAY" } + Fact { id: commDLLossFact; name: "COM_DL_LOSS_EN" } + Fact { id: commRCLossFact; name: "COM_RC_LOSS_T" } + + anchors.fill: parent + anchors.margins: 8 + + VehicleSummaryRow { + labelText: "RTL min alt:" + valueText: returnAltFact.valueString } - Row { - width: parent.width - - QGCLabel { id: rtlHomeAlt; text: "RTL home alt:" } - FactLabel { - fact: Fact { name: "RTL_DESCEND_ALT" } - horizontalAlignment: Text.AlignRight; - width: parent.width - rtlHomeAlt.contentWidth; - } + VehicleSummaryRow { + labelText: "RTL home alt:" + valueText: descendAltFact.valueString } - Row { - width: parent.width - - QGCLabel { id: rtlLoiter; text: "RTL loiter delay:" } - QGCLabel { - property Fact fact: Fact { name: "RTL_LAND_DELAY" } - horizontalAlignment: Text.AlignRight; - width: parent.width - rtlLoiter.contentWidth; - text: fact.value < 0 ? "Disabled" : fact.valueString - } + VehicleSummaryRow { + labelText: "RTL loiter delay:" + valueText: landDelayFact.value < 0 ? "Disabled" : landDelayFact.valueString } - Row { - width: parent.width - - QGCLabel { id: commLoss; text: "Telemetry loss RTL:" } - QGCLabel { - property Fact fact: Fact { name: "COM_DL_LOSS_EN" } - horizontalAlignment: Text.AlignRight; - width: parent.width - commLoss.contentWidth; - text: fact.value != 1 ? "Disabled" : fact.valueString - } + VehicleSummaryRow { + labelText: "Telemetry loss RTL:" + valueText: commDLLossFact.value != -1 ? "Disabled" : commDLLossFact.valueString } - Row { - width: parent.width - - QGCLabel { id: rcLoss; text: "RC loss RTL (seconds):" } - FactLabel { - fact: Fact { name: "COM_RC_LOSS_T" } - horizontalAlignment: Text.AlignRight; - width: parent.width - rcLoss.contentWidth; - } + VehicleSummaryRow { + labelText: "RC loss RTL (seconds):" + valueText: commRCLossFact.valueString } } diff --git a/src/AutoPilotPlugins/PX4/SensorsComponentSummaryFixedWing.qml b/src/AutoPilotPlugins/PX4/SensorsComponentSummaryFixedWing.qml index 680ffed87..c4d7f9303 100644 --- a/src/AutoPilotPlugins/PX4/SensorsComponentSummaryFixedWing.qml +++ b/src/AutoPilotPlugins/PX4/SensorsComponentSummaryFixedWing.qml @@ -10,54 +10,32 @@ import QGroundControl.Controls 1.0 */ Column { - anchors.fill: parent - anchors.margins: 8 + Fact { id: mag0IdFact; name: "CAL_MAG0_ID" } + Fact { id: gyro0IdFact; name: "CAL_GYRO0_ID" } + Fact { id: accel0IdFact; name: "CAL_ACC0_ID" } + Fact { id: dPressOffFact; name: "SENS_DPRES_OFF" } - Row { - width: parent.width - - QGCLabel { id: compass; text: "Compass:" } - QGCLabel { - property Fact fact: Fact { name: "CAL_MAG0_ID" } - horizontalAlignment: Text.AlignRight; - width: parent.width - compass.contentWidth; - text: fact.value == 0 ? "Setup required" : "Ready" + anchors.fill: parent + anchors.margins: 8 + + VehicleSummaryRow { + labelText: "Compass:" + valueText: mag0IdFact.value == 0 ? "Setup required" : "Ready" } } Row { - width: parent.width - - QGCLabel { id: gyro; text: "Gyro:" } - QGCLabel { - property Fact fact: Fact { name: "CAL_GYRO0_ID" } - horizontalAlignment: Text.AlignRight; - width: parent.width - compass.contentWidth; - text: fact.value == 0 ? "Setup required" : "Ready" - } + labelText: "Gyro:" + valueText: gyro0IdFact.value == 0 ? "Setup required" : "Ready" } Row { - width: parent.width - - QGCLabel { id: accel; text: "Accelerometer:" } - QGCLabel { - property Fact fact: Fact { name: "CAL_ACC0_ID" } - horizontalAlignment: Text.AlignRight; - width: parent.width - compass.contentWidth; - text: fact.value == 0 ? "Setup required" : "Ready" - } + labelText: "Accelerometer:" + valueText: accel0IdFact.value == 0 ? "Setup required" : "Ready" } Row { - width: parent.width - - QGCLabel { id: airspeed; text: "Airspeed:" } - QGCLabel { - property Fact fact: Fact { name: "SENS_DPRES_OFF" } - horizontalAlignment: Text.AlignRight; - width: parent.width - airspeed.contentWidth; - text: fact.value == 0.0 ? "Setup required" : "Ready" - } + labelText: "Airspeed:" + valueText: dPressOffFact.value == 0 ? "Setup required" : "Ready" } } diff --git a/src/QmlControls/VehicleSummaryRow.qml b/src/QmlControls/VehicleSummaryRow.qml new file mode 100644 index 000000000..cc2a035fb --- /dev/null +++ b/src/QmlControls/VehicleSummaryRow.qml @@ -0,0 +1,20 @@ +import QtQuick 2.2 +import QtQuick.Controls 1.2 +import QtQuick.Controls.Styles 1.2 + +Row { + property string labelText: "Label" + property string valueText: "value" + + width: parent.width + + QGCLabel { + id: label + text: labelText + } + QGCLabel { + width: parent.width - label.contentWidth + text: valueText + horizontalAlignment: Text.AlignRight; + } +} diff --git a/src/QmlControls/qmldir b/src/QmlControls/qmldir index ea2f99def..ba2a701c9 100644 --- a/src/QmlControls/qmldir +++ b/src/QmlControls/qmldir @@ -12,4 +12,5 @@ QGCToolBarButton 1.0 QGCToolBarButton.qml SubMenuButton 1.0 SubMenuButton.qml IndicatorButton 1.0 IndicatorButton.qml VehicleRotationCal 1.0 VehicleRotationCal.qml +VehicleSummaryRow 1.0 VehicleSummaryRow.qml -- 2.22.0