Commit 72806be5 authored by Don Gagne's avatar Don Gagne

Summary button content now comes from QML

parent 5bfa227a
......@@ -235,7 +235,9 @@
<qresource prefix="/QLoggingCategory">
<file alias="qtlogging.ini">files/QLoggingCategory/qtlogging.ini</file>
</qresource>
<qresource prefix="/qml">
<file alias="test.qml">src/test.qml</file>
<file alias="QGroundControl/FactControls/qmldir">qml/QGroundControl/FactControls/qmldir</file>
......@@ -254,7 +256,15 @@
<file alias="SetupPane.qml">src/VehicleSetup/SetupPane.qml</file>
<file alias="SafetyComponent.qml">src/AutoPilotPlugins/PX4/SafetyComponent.qml</file>
<file alias="SafetyComponentSummary.qml">src/AutoPilotPlugins/PX4/SafetyComponentSummary.qml</file>
<file alias="SensorsComponentSummary.qml">src/AutoPilotPlugins/PX4/SensorsComponentSummary.qml</file>
<file alias="RadioComponentSummary.qml">src/AutoPilotPlugins/PX4/RadioComponentSummary.qml</file>
<file alias="FlightModesComponentSummary.qml">src/AutoPilotPlugins/PX4/FlightModesComponentSummary.qml</file>
<file alias="AirframeComponentSummary.qml">src/AutoPilotPlugins/PX4/AirframeComponentSummary.qml</file>
</qresource>
<qresource prefix="/AutoPilotPlugins/PX4">
<file alias="ParameterFactMetaData.xml">src/AutoPilotPlugins/PX4/ParameterFactMetaData.xml</file>
</qresource>
......
......@@ -162,65 +162,7 @@ QWidget* AirframeComponent::setupWidget(void) const
return new QGCPX4AirframeConfig;
}
const QVariantList& AirframeComponent::summaryItems(void)
QUrl AirframeComponent::summaryQmlSource(void) const
{
// Fill the items on first reference
// FIXME: These items are not live
if (!_summaryItems.count()) {
QString name;
QString state;
QVariant value;
name = "System ID:";
if (_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), "MAV_SYS_ID", value)) {
if (value.toInt() == 0) {
state = "Setup required";
} else {
state = value.toString();
}
} else {
// Why is the parameter missing?
Q_ASSERT(false);
}
VehicleComponentSummaryItem* item = new VehicleComponentSummaryItem(name, state, this);
_summaryItems.append(QVariant::fromValue(item));
name = "Airframe:";
if (_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), "SYS_AUTOSTART", value)) {
if (value.toInt() == 0) {
state = "Setup required";
} else {
state = value.toString();
}
} else {
// Why is the parameter missing?
Q_ASSERT(false);
}
item = new VehicleComponentSummaryItem(name, state, this);
_summaryItems.append(QVariant::fromValue(item));
name = "Type:";
if (_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), "MAV_TYPE", value)) {
int index = value.toInt();
if (index < 0 || index >= (int)cMavTypes) {
state = "Unknown";
} else {
state = mavTypeInfo[index].description;
}
} else {
// Why is the parameter missing?
Q_ASSERT(false);
state = "Unknown";
}
item = new VehicleComponentSummaryItem(name, state, this);
_summaryItems.append(QVariant::fromValue(item));
}
return _summaryItems;
return QUrl::fromUserInput("qrc:/qml/AirframeComponentSummary.qml");
}
......@@ -49,7 +49,7 @@ public:
virtual QString setupStateDescription(void) const;
virtual QWidget* setupWidget(void) const;
virtual QStringList paramFilterList(void) const;
virtual const QVariantList& summaryItems(void);
virtual QUrl summaryQmlSource(void) const;
private:
const QString _name;
......
import QtQuick 2.2
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
import QGroundControl.FactSystem 1.0
import QGroundControl.FactControls 1.0
Column {
anchors.fill: parent
anchors.margins: 8
Row {
width: parent.width
Text { id: systemId; text: "System ID:" }
Text {
horizontalAlignment: Text.AlignRight
width: parent.width - systemId.contentWidth
text: autopilot.parameters["MAV_SYS_ID"].value
}
}
Row {
width: parent.width
Text { id: airframe; text: "Airframe:" }
Text {
horizontalAlignment: Text.AlignRight
width: parent.width - airframe.contentWidth
text: autopilot.parameters["SYS_AUTOSTART"].value == 0 ? "Setup required" : autopilot.parameters["SYS_AUTOSTART"].value
}
}
}
......@@ -117,44 +117,7 @@ QWidget* FlightModesComponent::setupWidget(void) const
return new FlightModeConfig();
}
const QVariantList& FlightModesComponent::summaryItems(void)
QUrl FlightModesComponent::summaryQmlSource(void) const
{
if (!_summaryItems.count()) {
// Create summary items for each mode switch
for (size_t i=0; i<cSwitchList; i++) {
QString name;
QString state;
QVariant value;
name = switchList[i].name;
if (_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), switchList[i].param, value)) {
int chan = value.toInt();
if (chan == 0) {
// Switch is not mapped
if (i == 0) {
// Mode switch is required
Q_ASSERT(strcmp(switchList[0].param, "RC_MAP_MODE_SW") == 0);
state = "Setup required";
} else {
state = "None";
}
} else {
state = tr("Chan %1").arg(chan);
}
} else {
// Why is the parameter missing?
Q_ASSERT(false);
state = "Unknown";
}
VehicleComponentSummaryItem* item = new VehicleComponentSummaryItem(name, state, this);
_summaryItems.append(QVariant::fromValue(item));
}
}
return _summaryItems;
return QUrl::fromUserInput("qrc:/qml/FlightModesComponentSummary.qml");
}
......@@ -49,7 +49,7 @@ public:
virtual QString setupStateDescription(void) const;
virtual QWidget* setupWidget(void) const;
virtual QStringList paramFilterList(void) const;
virtual const QVariantList& summaryItems(void);
virtual QUrl summaryQmlSource(void) const;
private:
const QString _name;
......
import QtQuick 2.2
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
import QGroundControl.FactSystem 1.0
import QGroundControl.FactControls 1.0
Column {
anchors.fill: parent
anchors.margins: 8
Row {
width: parent.width
Text { id: mode; text: "Mode switch:" }
Text {
horizontalAlignment: Text.AlignRight
width: parent.width - mode.contentWidth
text: autopilot.parameters["RC_MAP_MODE_SW"].value == 0 ? "Setup required" : autopilot.parameters["RC_MAP_MODE_SW"].value
}
}
Row {
width: parent.width
Text { id: posctl; text: "Position Ctl switch:" }
Text {
horizontalAlignment: Text.AlignRight
width: parent.width - posctl.contentWidth
text: autopilot.parameters["RC_MAP_POSCTL_SW"].value == 0 ? "Not mapped" : autopilot.parameters["RC_MAP_POSCTL_SW"].value
}
}
Row {
width: parent.width
Text { id: loiter; text: "Loiter switch:" }
Text {
horizontalAlignment: Text.AlignRight
width: parent.width - loiter.contentWidth
text: autopilot.parameters["RC_MAP_LOITER_SW"].value == 0 ? "Not mapped" : autopilot.parameters["RC_MAP_LOITER_SW"].value
}
}
Row {
width: parent.width
Text { id: rtl; text: "Return switch:" }
Text {
horizontalAlignment: Text.AlignRight
width: parent.width - rtl.contentWidth
text: autopilot.parameters["RC_MAP_RETURN_SW"].value == 0 ? "Not mapped" : autopilot.parameters["RC_MAP_RETURN_SW"].value
}
}
}
......@@ -101,54 +101,7 @@ QWidget* RadioComponent::setupWidget(void) const
return new PX4RCCalibration;
}
const QVariantList& RadioComponent::summaryItems(void)
QUrl RadioComponent::summaryQmlSource(void) const
{
if (!_summaryItems.count()) {
QString name;
QString state;
// FIXME: Need to pull receiver type from RSSI value
name = "Receiver type:";
state = "n/a";
VehicleComponentSummaryItem* item = new VehicleComponentSummaryItem(name, state, this);
_summaryItems.append(QVariant::fromValue(item));
static const char* stickParams[] = { "RC_MAP_ROLL", "RC_MAP_PITCH", "RC_MAP_YAW", "RC_MAP_THROTTLE" };
QString summary("Chan ");
bool allSticksMapped = true;
for (size_t i=0; i<sizeof(stickParams)/sizeof(stickParams[0]); i++) {
QVariant value;
if (_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), stickParams[i], value)) {
if (value.toInt() == 0) {
allSticksMapped = false;
break;
} else {
if (i != 0) {
summary += ",";
}
summary += value.toString();
}
} else {
// Why is the parameter missing?
Q_ASSERT(false);
summary += "?";
}
}
if (!allSticksMapped) {
summary = "Not mapped";
}
name = "Ail, Ele, Rud, Throt:";
state = summary;
item = new VehicleComponentSummaryItem(name, state, this);
_summaryItems.append(QVariant::fromValue(item));
}
return _summaryItems;
return QUrl::fromUserInput("qrc:/qml/RadioComponentSummary.qml");
}
......@@ -50,7 +50,7 @@ public:
virtual QString setupStateDescription(void) const;
virtual QWidget* setupWidget(void) const;
virtual QStringList paramFilterList(void) const;
virtual const QVariantList& summaryItems(void);
virtual QUrl summaryQmlSource(void) const;
private:
const QString _name;
......
......@@ -100,37 +100,7 @@ QWidget* SafetyComponent::setupWidget(void) const
return holder;
}
const QVariantList& SafetyComponent::summaryItems(void)
QUrl SafetyComponent::summaryQmlSource(void) const
{
if (!_summaryItems.count()) {
QString name;
QString state;
name = "RTL min alt:";
VehicleComponentSummaryItem* item = new VehicleComponentSummaryItem(name, state, this);
_summaryItems.append(QVariant::fromValue(item));
name = "RTL home alt:";
item = new VehicleComponentSummaryItem(name, state, this);
_summaryItems.append(QVariant::fromValue(item));
name = "RTL home loiter:";
item = new VehicleComponentSummaryItem(name, state, this);
_summaryItems.append(QVariant::fromValue(item));
name = "Telemetry loss RTL:";
item = new VehicleComponentSummaryItem(name, state, this);
_summaryItems.append(QVariant::fromValue(item));
name = "RC loss RTL:";
item = new VehicleComponentSummaryItem(name, state, this);
_summaryItems.append(QVariant::fromValue(item));
}
return _summaryItems;
return QUrl::fromUserInput("qrc:/qml/SafetyComponentSummary.qml");
}
......@@ -50,7 +50,7 @@ public:
virtual QString setupStateDescription(void) const;
virtual QWidget* setupWidget(void) const;
virtual QStringList paramFilterList(void) const;
virtual const QVariantList& summaryItems(void);
virtual QUrl summaryQmlSource(void) const;
private:
const QString _name;
......
......@@ -32,7 +32,7 @@ Rectangle {
id: homeLoiterCheckbox
property Fact fact: autopilot.parameters["RTL_LAND_DELAY"]
checked: fact.value < 0
checked: fact.value > 0
text: "Loiter at Home altitude for "
onClicked: {
......
import QtQuick 2.2
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
import QGroundControl.FactSystem 1.0
import QGroundControl.FactControls 1.0
Column {
anchors.fill: parent
anchors.margins: 8
Row {
width: parent.width
Text { id: rtlMinAlt; text: "RTL min alt:" }
Text {
horizontalAlignment: Text.AlignRight;
width: parent.width - rtlMinAlt.contentWidth;
text: autopilot.parameters["RTL_RETURN_ALT"].valueString
}
}
Row {
width: parent.width
Text { id: rtlHomeAlt; text: "RTL home alt:" }
Text {
horizontalAlignment: Text.AlignRight;
width: parent.width - rtlHomeAlt.contentWidth;
text: autopilot.parameters["RTL_DESCEND_ALT"].valueString
}
}
Row {
width: parent.width
Text { id: rtlLoiter; text: "RTL loiter delay:" }
Text {
horizontalAlignment: Text.AlignRight;
width: parent.width - rtlLoiter.contentWidth;
text: autopilot.parameters["RTL_LAND_DELAY"].value < 0 ? "Disabled" : autopilot.parameters["RTL_LAND_DELAY"].valueString
}
}
Row {
width: parent.width
Text { id: commLoss; text: "Telemetry loss RTL:" }
Text {
horizontalAlignment: Text.AlignRight;
width: parent.width - commLoss.contentWidth;
text: autopilot.parameters["COM_DL_LOSS_EN"].value != 1 ? "Disabled" : autopilot.parameters["NAV_DLL_N"].valueString
}
}
Row {
width: parent.width
Text { id: rcLoss; text: "RC loss RTL (seconds):" }
Text {
horizontalAlignment: Text.AlignRight;
width: parent.width - rcLoss.contentWidth;
text: autopilot.parameters["COM_RC_LOSS_T"].valueString
}
}
}
......@@ -33,9 +33,6 @@
/// @brief Parameters which signal a change in setupComplete state
static const char* triggerParams[] = { "SENS_MAG_XOFF", "SENS_GYRO_XOFF", "SENS_ACC_XOFF", "SENS_DPRES_OFF", NULL };
/// @brief Used to translate from parameter name to user string
static const char* triggerSensors[] = { "Compass", "Gyro", "Acceleromter", "Airspeed", NULL };
SensorsComponent::SensorsComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent) :
PX4Component(uas, autopilot, parent),
_name(tr("Sensors"))
......@@ -117,108 +114,7 @@ QWidget* SensorsComponent::setupWidget(void) const
return new QGCPX4SensorCalibration;
}
const QVariantList& SensorsComponent::summaryItems(void)
QUrl SensorsComponent::summaryQmlSource(void) const
{
if (!_summaryItems.count()) {
QString name;
QString state;
// Summary item for each Sensor
int i = 0;
while (triggerParams[i] != NULL) {
QVariant value;
name = tr("%1:").arg(triggerSensors[i]);
if (_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), triggerParams[i], value)) {
if (value.toFloat() == 0.0f) {
state = "Setup required";
} else {
state = "Ready";
}
} else {
// Why is the parameter missing?
Q_ASSERT(false);
}
VehicleComponentSummaryItem* item = new VehicleComponentSummaryItem(name, state, this);
_summaryItems.append(QVariant::fromValue(item));
i++;
}
// Summary item for each orientation param
static const char* orientationSensors[] = { "Autopilot orientation:", "Compass orientation:" };
static const char* orientationParams[] = { "SENS_BOARD_ROT", "SENS_EXT_MAG_ROT" };
static const size_t cOrientationSensors = sizeof(orientationSensors)/sizeof(orientationSensors[0]);
static const char* orientationValues[] = {
"Line of flight",
"Yaw:45",
"Yaw:90",
"Yaw:135",
"Yaw:180",
"Yaw:225",
"Yaw:270",
"Yaw:315",
"Roll:180",
"Roll:180 Yaw:45",
"Roll:180 Yaw:90",
"Roll:180 Yaw:135",
"Pitch:180",
"Roll:180 Yaw:225",
"Roll:180 Yaw:270",
"Roll:180 Yaw:315",
"Roll:90",
"Roll:90 Yaw:45",
"Roll:90 Yaw:90",
"Roll:90 Yaw:135",
"Roll:270",
"Roll:270 Yaw:45",
"Roll:270 Yaw:90",
"Roll:270 Yaw:135",
"Pitch:90",
"Pitch:270",
"Pitch:180",
"Pitch:180 Yaw:90",
"Pitch:180 Yaw:270",
"Roll:90 Pitch:90",
"Roll:180 Pitch:90",
"Roll:270 Pitch:90",
"Roll:90 Pitch:180",
"Roll:270 Pitch:180",
"Roll:90 Pitch:270",
"Roll:180 Pitch:270",
"Roll:270 Pitch:270",
"Roll:90 Pitch:180 Yaw:90",
"Roll:90 Yaw:270"
};
static const size_t cOrientationValues = sizeof(orientationValues)/sizeof(orientationValues[0]);
for (size_t i=0; i<cOrientationSensors; i++) {
QVariant value;
name = orientationSensors[i];
if (_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), orientationParams[i], value)) {
int index = value.toInt();
if (index < 0 || index >= (int)cOrientationValues) {
state = "Setup required";
} else {
state = orientationValues[index];
}
} else {
// Why is the parameter missing?
Q_ASSERT(false);
state = "Unknown";
}
VehicleComponentSummaryItem* item = new VehicleComponentSummaryItem(name, state, this);
_summaryItems.append(QVariant::fromValue(item));
}
}
return _summaryItems;
return QUrl::fromUserInput("qrc:/qml/SensorsComponentSummary.qml");
}
......@@ -49,7 +49,7 @@ public:
virtual QString setupStateDescription(void) const;
virtual QWidget* setupWidget(void) const;
virtual QStringList paramFilterList(void) const;
virtual const QVariantList& summaryItems(void);
virtual QUrl summaryQmlSource(void) const;
private:
const QString _name;
......
import QtQuick 2.2
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
import QGroundControl.FactSystem 1.0
import QGroundControl.FactControls 1.0
Column {
anchors.fill: parent
anchors.margins: 8
Row {
width: parent.width
Text { id: compass; text: "Compass:" }
Text {
horizontalAlignment: Text.AlignRight;
width: parent.width - compass.contentWidth;
text: autopilot.parameters["SENS_MAG_XOFF"].value == 0.0 ? "Setup required" : "Ready"
}
}
Row {
width: parent.width
Text { id: gyro; text: "Gyro:" }
Text {
horizontalAlignment: Text.AlignRight;
width: parent.width - gyro.contentWidth;
text: autopilot.parameters["SENS_GYRO_XOFF"].value == 0.0 ? "Setup required" : "Ready"
}
}
Row {
width: parent.width
Text { id: accel; text: "Accelerometer:" }
Text {
horizontalAlignment: Text.AlignRight;
width: parent.width - accel.contentWidth;
text: autopilot.parameters["SENS_ACC_XOFF"].value == 0.0 ? "Setup required" : "Ready"
}
}
Row {
width: parent.width
Text { id: airspeed; text: "Airspeed:" }
Text {
horizontalAlignment: Text.AlignRight;
width: parent.width - airspeed.contentWidth;
text: autopilot.parameters["SENS_DPRES_OFF"].value == 0.0 ? "Setup required" : "Ready"
}
}
}
......@@ -27,7 +27,7 @@ Rectangle {
spacing: 5
Rectangle { id: header; color: "lightblue"; radius: 10.0; width: parent.width; height: titleText.height + 20; opacity: 0.8;
Text { id: titleText; anchors.centerIn: parent; font.pointSize: 24; text: "Vehicle Summary" }
Text { id: titleText; anchors.centerIn: parent; font.pointSize: 24; text: "Vehicle Setup" }
}
Flow {
......@@ -42,7 +42,7 @@ Rectangle {
width: 250
height: 200
property var summaryModel: modelData.summaryItems
property var summaryQmlSource: modelData.summaryQmlSource
text: modelData.name
property bool setupComplete: modelData.setupComplete
......@@ -100,15 +100,9 @@ Rectangle {
GradientStop { position: 1; color: "#000000" }
}
ListView {
id: summaryList
Loader {
anchors.fill: parent
anchors.margins: 4
model: control.summaryModel
delegate: Row { width: parent.width
Text { id: firstCol; text: modelData.name }
Text { horizontalAlignment: Text.AlignRight; width: parent.width - firstCol.contentWidth; text: modelData.state }
}
source: summaryQmlSource
}
}
}
......
......@@ -14,7 +14,7 @@ Rectangle {
anchors.fill: parent
Rectangle { id: header; color: "lightblue"; radius: 10.0; width: parent.width; height: titleText.height + 20; opacity: 0.8;
Text { id: titleText; anchors.centerIn: parent; font.pointSize: 24; text: "Vehicle Summary" }
Text { id: titleText; anchors.centerIn: parent; font.pointSize: 24; text: "Vehicle Setup" }
}
Text { width: parent.width; height: parent.height - header.height - footer.height;
......@@ -22,7 +22,7 @@ Rectangle {
color: palette.windowText
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
text: "No vehicle currently connected. Vehicle Setup is only available while vehicle is connected." }
text: "Vehicle Setup is only available while vehicle is connected." }
Rectangle { id: footer; anchors.bottom: parent.bottom; color: "lightblue"; radius: 10.0; width: parent.width; height: titleText.height + 20; opacity: 0.8;
......
......@@ -49,7 +49,7 @@ class VehicleComponent : public QObject
Q_PROPERTY(QString setupStateDescription READ setupStateDescription STORED false)
Q_PROPERTY(QString icon READ icon CONSTANT)
Q_PROPERTY(QWidget* setupWidget READ setupWidget STORED false)
Q_PROPERTY(QVariantList summaryItems READ summaryItems CONSTANT);
Q_PROPERTY(QUrl summaryQmlSource READ summaryQmlSource CONSTANT);
public:
VehicleComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent = NULL);
......@@ -63,7 +63,7 @@ public:
virtual QString setupStateDescription(void) const = 0;
virtual QWidget* setupWidget(void) const = 0;
virtual QStringList paramFilterList(void) const = 0;
virtual const QVariantList& summaryItems(void) = 0;
virtual QUrl summaryQmlSource(void) const = 0;
virtual void addSummaryQmlComponent(QQmlContext* context, QQuickItem* parent);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment