1
0
Fork 0

Launcher: only submit a FP when requested

Add an explicit toggle switch to the planning page so we don’t
always set an empty plan.
This commit is contained in:
James Turner 2018-09-02 09:32:13 +01:00
parent 5312ed9071
commit 0bb67136ab
3 changed files with 28 additions and 1 deletions

View file

@ -204,6 +204,9 @@ void FlightPlanController::clearPlan()
_fp->addDelegate(_delegate.get());
_legs->setFlightPlan(fp);
emit infoChanged();
_enabled = false;
emit enabledChanged(_enabled);
}
bool FlightPlanController::loadFromPath(QString path)
@ -220,6 +223,9 @@ bool FlightPlanController::loadFromPath(QString path)
_fp->addDelegate(_delegate.get());
_legs->setFlightPlan(fp);
_enabled = true;
emit enabledChanged(_enabled);
// notify that everything changed
emit infoChanged();
return true;
@ -233,6 +239,9 @@ bool FlightPlanController::saveToPath(QString path) const
void FlightPlanController::onCollectConfig()
{
if (!_enabled)
return;
SGPath p = globals->get_fg_home() / "launcher.fgfp";
_fp->save(p);
@ -248,6 +257,9 @@ void FlightPlanController::onSave()
void FlightPlanController::onRestore()
{
_enabled = _config->getValueForKey("", "fp-enabled", false).toBool();
emit enabledChanged(_enabled);
std::string planXML = _config->getValueForKey("", "fp", QString()).toString().toStdString();
if (!planXML.empty()) {
std::istringstream ss(planXML);

View file

@ -18,6 +18,8 @@ class FlightPlanController : public QObject
{
Q_OBJECT
Q_PROPERTY(bool enabled MEMBER _enabled NOTIFY enabledChanged)
Q_PROPERTY(QString callsign READ callsign WRITE setCallsign NOTIFY infoChanged)
Q_PROPERTY(QString remarks READ remarks WRITE setRemarks NOTIFY infoChanged)
Q_PROPERTY(QString aircraftType READ aircraftType WRITE setAircraftType NOTIFY infoChanged)
@ -110,6 +112,8 @@ signals:
void infoChanged();
void waypointsChanged();
void enabledChanged(bool enabled);
public slots:
void setFlightType(FlightType ty);
@ -143,6 +147,7 @@ private:
LegsModel* _legs = nullptr;
std::unique_ptr<FPDelegate> _delegate;
LaunchConfig* _config = nullptr;
bool _enabled = false;
};
#endif // FLIGHTPLANCONTROLLER_HXX

View file

@ -36,9 +36,19 @@ Item {
Row {
width: parent.width
spacing: Style.margin
height: childrenRect.height
height: loadButton.height
ToggleSwitch {
label: qsTr("Fly with a flight-plan")
checked: _launcher.flightPlan.enabled
function toggle(newChecked) {
_launcher.flightPlan.enabled = newChecked
}
anchors.verticalCenter: parent.verticalCenter
}
Button {
id: loadButton
text: qsTr("Load");
onClicked: {
var ok = _launcher.flightPlan.loadPlan();