Skip to content

Commit

Permalink
Allow flight modes to differ from normal to advanced ui mode
Browse files Browse the repository at this point in the history
  • Loading branch information
DonLakeFlyer committed Apr 5, 2018
1 parent 9b7cfd2 commit e89e2de
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/FirmwarePlugin/FirmwarePlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ class FirmwarePlugin : public QObject
/// free when no longer needed.
virtual QList<VehicleComponent*> componentsForVehicle(AutoPilotPlugin* vehicle);

/// Returns the list of available flight modes
/// Returns the list of available flight modes. Flight modes can be different in normal/advanced ui mode.
/// Call will be made again if advanced mode changes.
virtual QStringList flightModes(Vehicle* vehicle) {
Q_UNUSED(vehicle);
return QStringList();
Expand Down
3 changes: 3 additions & 0 deletions src/Vehicle/Vehicle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,9 @@ void Vehicle::_commonInit(void)
connect(_settingsManager->appSettings()->offlineEditingCruiseSpeed(), &Fact::rawValueChanged, this, &Vehicle::_offlineCruiseSpeedSettingChanged);
connect(_settingsManager->appSettings()->offlineEditingHoverSpeed(), &Fact::rawValueChanged, this, &Vehicle::_offlineHoverSpeedSettingChanged);

// Flight modes can differ based on advanced mode
connect(_toolbox->corePlugin(), &QGCCorePlugin::showAdvancedUIChanged, this, &Vehicle::flightModesChanged);

// Build FactGroup object model

_addFact(&_rollFact, _rollFactName);
Expand Down
3 changes: 2 additions & 1 deletion src/Vehicle/Vehicle.h
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ class Vehicle : public FactGroup
Q_PROPERTY(bool armed READ armed WRITE setArmed NOTIFY armedChanged)
Q_PROPERTY(bool autoDisarm READ autoDisarm NOTIFY autoDisarmChanged)
Q_PROPERTY(bool flightModeSetAvailable READ flightModeSetAvailable CONSTANT)
Q_PROPERTY(QStringList flightModes READ flightModes CONSTANT)
Q_PROPERTY(QStringList flightModes READ flightModes NOTIFY flightModesChanged)
Q_PROPERTY(QString flightMode READ flightMode WRITE setFlightMode NOTIFY flightModeChanged)
Q_PROPERTY(bool hilMode READ hilMode WRITE setHilMode NOTIFY hilModeChanged)
Q_PROPERTY(QmlObjectListModel* trajectoryPoints READ trajectoryPoints CONSTANT)
Expand Down Expand Up @@ -860,6 +860,7 @@ class Vehicle : public FactGroup
void telemetryLNoiseChanged (int value);
void telemetryRNoiseChanged (int value);
void autoDisarmChanged (void);
void flightModesChanged (void);

void firmwareVersionChanged(void);
void firmwareCustomVersionChanged(void);
Expand Down
13 changes: 6 additions & 7 deletions src/ui/toolbar/ModeIndicator.qml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ Item {
anchors.bottom: parent.bottom
width: flightModeSelector.width

property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
property var _flightModes: _activeVehicle ? _activeVehicle.flightModes : [ ]

on_FlightModesChanged: flightModeSelector.updateFlightModesMenu()

QGCLabel {
id: flightModeSelector
Expand All @@ -50,18 +53,14 @@ Item {
}
flightModesMenuItems.length = 0
// Add new items
for (var i = 0; i < _activeVehicle.flightModes.length; i++) {
var menuItem = flightModeMenuItemComponent.createObject(null, { "text": _activeVehicle.flightModes[i] })
for (var i = 0; i < _flightModes.length; i++) {
var menuItem = flightModeMenuItemComponent.createObject(null, { "text": _flightModes[i] })
flightModesMenuItems.push(menuItem)
flightModesMenu.insertItem(i, menuItem)
}
}
}
Component.onCompleted: flightModeSelector.updateFlightModesMenu()
Connections {
target: QGroundControl.multiVehicleManager
onActiveVehicleChanged: flightModeSelector.updateFlightModesMenu()
}
MouseArea {
visible: _activeVehicle && _activeVehicle.flightModeSetAvailable
anchors.fill: parent
Expand Down

0 comments on commit e89e2de

Please sign in to comment.