From 20664925b024179ceec7b491bda86098e319f2b5 Mon Sep 17 00:00:00 2001 From: DoinLakeFlyer Date: Fri, 15 May 2020 09:42:36 -0700 Subject: [PATCH] Modified support for multiple first run pages. Added first run for offline vehicle settings. --- custom-example/qgroundcontrol.qrc | 28 +++-- .../FirmwarePlugin/CustomFirmwarePlugin.cc | 10 +- .../src/FirmwarePlugin/CustomFirmwarePlugin.h | 8 +- qgroundcontrol.qrc | 11 +- src/FirstRunPromptDialogs/FirstRunPrompt.qml | 28 +++++ .../OfflineVehicleFirstRunPrompt.qml | 105 ++++++++++++++++ .../UnitsFirstRunPrompt.qml | 115 ++++++++++++++++++ src/QmlControls/HorizontalFactValueGrid.qml | 2 +- src/QmlControls/InstrumentValueEditDialog.qml | 6 +- src/QmlControls/ParameterEditorDialog.qml | 2 +- src/QmlControls/QGCPopupDialogContainer.qml | 12 +- .../QGroundControl/Controls/qmldir | 1 + .../Specific/BaseStartupWizardPage.qml | 10 -- .../QGroundControl/Specific/StartupWizard.qml | 87 ------------- .../Specific/UnitsWizardPage.qml | 81 ------------ .../QGroundControl/Specific/qmldir | 5 - src/QmlControls/VerticalFactValueGrid.qml | 2 +- src/Settings/App.SettingsGroup.json | 13 +- src/Settings/AppSettings.cc | 30 ++++- src/Settings/AppSettings.h | 7 +- src/api/QGCCorePlugin.cc | 52 +++++++- src/api/QGCCorePlugin.h | 56 ++++++--- src/ui/MainRootWindow.qml | 81 ++++++------ 23 files changed, 462 insertions(+), 290 deletions(-) create mode 100644 src/FirstRunPromptDialogs/FirstRunPrompt.qml create mode 100644 src/FirstRunPromptDialogs/OfflineVehicleFirstRunPrompt.qml create mode 100644 src/FirstRunPromptDialogs/UnitsFirstRunPrompt.qml delete mode 100644 src/QmlControls/QGroundControl/Specific/BaseStartupWizardPage.qml delete mode 100644 src/QmlControls/QGroundControl/Specific/StartupWizard.qml delete mode 100644 src/QmlControls/QGroundControl/Specific/UnitsWizardPage.qml delete mode 100644 src/QmlControls/QGroundControl/Specific/qmldir diff --git a/custom-example/qgroundcontrol.qrc b/custom-example/qgroundcontrol.qrc index df70d13a4..17049b348 100644 --- a/custom-example/qgroundcontrol.qrc +++ b/custom-example/qgroundcontrol.qrc @@ -92,15 +92,17 @@ ../src/QmlControls/EditPositionDialog.qml ../src/QmlControls/ExclusiveGroupItem.qml ../src/QmlControls/FactSliderPanel.qml + ../src/FirstRunPromptDialogs/FirstRunPrompt.qml ../src/QmlControls/FileButton.qml ../src/QmlControls/FlightModeDropdown.qml ../src/QmlControls/FlightModeMenu.qml ../src/PlanView/FWLandingPatternMapVisual.qml ../src/PlanView/GeoFenceEditor.qml ../src/PlanView/GeoFenceMapVisuals.qml + ../src/QmlControls/HorizontalFactValueGrid.qml ../src/QmlControls/IndicatorButton.qml - ../src/QmlControls/InstrumentValue.qml - ../src/QmlControls/InstrumentValueArea.qml + ../src/QmlControls/InstrumentValueLabel.qml + ../src/QmlControls/InstrumentValueValue.qml ../src/QmlControls/InstrumentValueEditDialog.qml ../src/QmlControls/JoystickThumbPad.qml ../src/QmlControls/KMLOrSHPFileDialog.qml @@ -177,11 +179,14 @@ ../src/PlanView/SurveyMapVisual.qml ../src/PlanView/TerrainStatus.qml ../src/PlanView/TakeoffItemMapVisual.qml + ../src/ui/toolbar/ToolBarBase.qml ../src/QmlControls/ToolStrip.qml ../src/PlanView/TransectStyleComplexItemStats.qml ../src/QmlControls/VehicleRotationCal.qml ../src/QmlControls/VehicleSummaryRow.qml + ../src/QmlControls/VerticalFactValueGrid.qml ../src/ViewWidgets/ViewWidget.qml + ../src/PlanView/VTOLLandingPatternMapVisual.qml ../src/FactSystem/FactControls/AltitudeFactTextField.qml ../src/FactSystem/FactControls/FactBitmask.qml ../src/FactSystem/FactControls/FactCheckBox.qml @@ -203,12 +208,19 @@ ../src/FlightDisplay/FlyViewMissionCompleteDialog.qml ../src/FlightDisplay/FlyViewPreFlightChecklistPopup.qml ../src/FlightDisplay/FlyViewToolStrip.qml + ../src/FlightDisplay/FlyViewToolStripActionList.qml ../src/FlightDisplay/FlyViewVideo.qml ../src/FlightDisplay/FlyViewWidgetLayer.qml + ../src/FlightDisplay/GuidedActionActionList.qml ../src/FlightDisplay/GuidedActionConfirm.qml - ../src/FlightDisplay/GuidedActionList.qml ../src/FlightDisplay/GuidedActionsController.qml + ../src/FlightDisplay/GuidedActionLand.qml + ../src/FlightDisplay/GuidedActionList.qml + ../src/FlightDisplay/GuidedActionTakeoff.qml + ../src/FlightDisplay/GuidedActionPause.qml + ../src/FlightDisplay/GuidedActionRTL.qml ../src/FlightDisplay/GuidedAltitudeSlider.qml + ../src/FlightDisplay/GuidedToolStripAction.qml ../src/FlightDisplay/MultiVehicleList.qml ../src/FlightDisplay/MultiVehiclePanel.qml ../src/FlightDisplay/PreFlightBatteryCheck.qml @@ -216,6 +228,7 @@ ../src/FlightDisplay/PreFlightRCCheck.qml ../src/FlightDisplay/PreFlightSensorsHealthCheck.qml ../src/FlightDisplay/PreFlightSoundCheck.qml + ../src/FlightDisplay/PreFlightCheckListShowAction.qml ../src/FlightDisplay/TerrainProgress.qml ../src/FlightDisplay/VehicleWarnings.qml ../src/QmlControls/QGroundControl/FlightDisplay/qmldir @@ -262,12 +275,11 @@ ../src/FlightMap/Widgets/VibrationPageWidget.qml ../src/FlightMap/Widgets/VideoPageWidget.qml ../src/FlightDisplay/VirtualJoystick.qml - ../src/PlanView/VTOLLandingPatternMapVisual.qml ../src/PlanView/VTOLLandingPatternEditor.qml - ../src/QmlControls/QGroundControl/Specific/qmldir - ../src/QmlControls/QGroundControl/Specific/StartupWizard.qml - ../src/QmlControls/QGroundControl/Specific/BaseStartupWizardPage.qml - ../src/QmlControls/QGroundControl/Specific/UnitsWizardPage.qml + + + ../src/FirstRunPromptDialogs/UnitsFirstRunPrompt.qml + ../src/FirstRunPromptDialogs/OfflineVehicleFirstRunPrompt.qml ../src/Settings/ADSBVehicleManager.SettingsGroup.json diff --git a/custom-example/src/FirmwarePlugin/CustomFirmwarePlugin.cc b/custom-example/src/FirmwarePlugin/CustomFirmwarePlugin.cc index bc5747cb3..6d0a30adc 100644 --- a/custom-example/src/FirmwarePlugin/CustomFirmwarePlugin.cc +++ b/custom-example/src/FirmwarePlugin/CustomFirmwarePlugin.cc @@ -33,16 +33,16 @@ AutoPilotPlugin* CustomFirmwarePlugin::autopilotPlugin(Vehicle* vehicle) return new CustomAutoPilotPlugin(vehicle, vehicle); } -const QVariantList& CustomFirmwarePlugin::toolBarIndicators(const Vehicle* vehicle) +const QVariantList& CustomFirmwarePlugin::toolIndicators(const Vehicle* vehicle) { - if (_toolBarIndicatorList.size() == 0) { + if (_toolIndicatorList.size() == 0) { // First call the base class to get the standard QGC list. This way we are guaranteed to always get // any new toolbar indicators which are added upstream in our custom build. - _toolBarIndicatorList = FirmwarePlugin::toolBarIndicators(vehicle); + _toolIndicatorList = FirmwarePlugin::toolIndicators(vehicle); // Then specifically remove the RC RSSI indicator. - _toolBarIndicatorList.removeOne(QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/RCRSSIIndicator.qml"))); + _toolIndicatorList.removeOne(QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/RCRSSIIndicator.qml"))); } - return _toolBarIndicatorList; + return _toolIndicatorList; } // Tells QGC that your vehicle has a gimbal on it. This will in turn cause thing like gimbal commands to point diff --git a/custom-example/src/FirmwarePlugin/CustomFirmwarePlugin.h b/custom-example/src/FirmwarePlugin/CustomFirmwarePlugin.h index 5162e8a8e..69fad0281 100644 --- a/custom-example/src/FirmwarePlugin/CustomFirmwarePlugin.h +++ b/custom-example/src/FirmwarePlugin/CustomFirmwarePlugin.h @@ -25,10 +25,10 @@ public: CustomFirmwarePlugin(); // FirmwarePlugin overrides - AutoPilotPlugin* autopilotPlugin (Vehicle* vehicle) final; - const QVariantList& toolBarIndicators (const Vehicle* vehicle) final; - bool hasGimbal (Vehicle* vehicle, bool& rollSupported, bool& pitchSupported, bool& yawSupported) final; + AutoPilotPlugin* autopilotPlugin (Vehicle* vehicle) final; + const QVariantList& toolIndicators (const Vehicle* vehicle) final; + bool hasGimbal (Vehicle* vehicle, bool& rollSupported, bool& pitchSupported, bool& yawSupported) final; private: - QVariantList _toolBarIndicatorList; + QVariantList _toolIndicatorList; }; diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc index 409b814bc..025b53fc0 100644 --- a/qgroundcontrol.qrc +++ b/qgroundcontrol.qrc @@ -92,6 +92,7 @@ src/QmlControls/EditPositionDialog.qml src/QmlControls/ExclusiveGroupItem.qml src/QmlControls/FactSliderPanel.qml + src/FirstRunPromptDialogs/FirstRunPrompt.qml src/QmlControls/FileButton.qml src/QmlControls/FlightModeDropdown.qml src/QmlControls/FlightModeMenu.qml @@ -185,6 +186,7 @@ src/QmlControls/VehicleSummaryRow.qml src/QmlControls/VerticalFactValueGrid.qml src/ViewWidgets/ViewWidget.qml + src/PlanView/VTOLLandingPatternMapVisual.qml src/FactSystem/FactControls/AltitudeFactTextField.qml src/FactSystem/FactControls/FactBitmask.qml src/FactSystem/FactControls/FactCheckBox.qml @@ -273,12 +275,11 @@ src/FlightMap/Widgets/VibrationPageWidget.qml src/FlightMap/Widgets/VideoPageWidget.qml src/FlightDisplay/VirtualJoystick.qml - src/PlanView/VTOLLandingPatternMapVisual.qml src/PlanView/VTOLLandingPatternEditor.qml - src/QmlControls/QGroundControl/Specific/qmldir - src/QmlControls/QGroundControl/Specific/StartupWizard.qml - src/QmlControls/QGroundControl/Specific/BaseStartupWizardPage.qml - src/QmlControls/QGroundControl/Specific/UnitsWizardPage.qml + + + src/FirstRunPromptDialogs/UnitsFirstRunPrompt.qml + src/FirstRunPromptDialogs/OfflineVehicleFirstRunPrompt.qml src/Settings/ADSBVehicleManager.SettingsGroup.json diff --git a/src/FirstRunPromptDialogs/FirstRunPrompt.qml b/src/FirstRunPromptDialogs/FirstRunPrompt.qml new file mode 100644 index 000000000..63b4fe176 --- /dev/null +++ b/src/FirstRunPromptDialogs/FirstRunPrompt.qml @@ -0,0 +1,28 @@ +/**************************************************************************** + * + * (c) 2009-2020 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + +import QtQuick 2.12 +import QtQuick.Dialogs 1.3 + +import QGroundControl 1.0 +import QGroundControl.Controls 1.0 + +// Base class for all first run prompt dialogs +QGCPopupDialog { + buttons: StandardButton.Ok + + property int promptId + property bool markAsShownOnClose: true + + onHideDialog: { + if (markAsShownOnClose) { + QGroundControl.settingsManager.appSettings.firstRunPromptIdsMarkIdAsShown(promptId) + } + } +} diff --git a/src/FirstRunPromptDialogs/OfflineVehicleFirstRunPrompt.qml b/src/FirstRunPromptDialogs/OfflineVehicleFirstRunPrompt.qml new file mode 100644 index 000000000..cffa6ab24 --- /dev/null +++ b/src/FirstRunPromptDialogs/OfflineVehicleFirstRunPrompt.qml @@ -0,0 +1,105 @@ +/**************************************************************************** + * + * (c) 2009-2020 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + +import QtQuick 2.12 +import QtQuick.Layouts 1.12 + +import QGroundControl 1.0 +import QGroundControl.FactSystem 1.0 +import QGroundControl.FactControls 1.0 +import QGroundControl.ScreenTools 1.0 +import QGroundControl.SettingsManager 1.0 +import QGroundControl.Controls 1.0 + +FirstRunPrompt { + title: qsTr("Vehicle Information") + promptId: QGroundControl.corePlugin.offlineVehicleFirstRunPromptId + + property real _margins: ScreenTools.defaultFontPixelWidth + property var _appSettings: QGroundControl.settingsManager.appSettings + property var _offlineVehicle: QGroundControl.multiVehicleManager.offlineEditingVehicle + property bool _showCruiseSpeed: !_offlineVehicle.multiRotor + property bool _showHoverSpeed: _offlineVehicle.multiRotor || _offlineVehicle.vtol + property bool _multipleFirmware: QGroundControl.supportedFirmwareCount > 2 + property bool _multipleVehicleTypes: QGroundControl.supportedVehicleCount > 1 + property real _fieldWidth: ScreenTools.defaultFontPixelWidth * 16 + + ColumnLayout { + spacing: ScreenTools.defaultFontPixelHeight + + QGCLabel { + id: unitsSectionLabel + Layout.preferredWidth: valueRect.width + text: qsTr("Specify information about the vehicle you plan to fly. If you are unsure of the correct values leave them as is.") + wrapMode: Text.WordWrap + } + + Rectangle { + id: valueRect + Layout.preferredHeight: valueGrid.height + (_margins * 2) + Layout.preferredWidth: valueGrid.width + (_margins * 2) + color: qgcPal.windowShade + Layout.fillWidth: true + + GridLayout { + id: valueGrid + anchors.margins: _margins + anchors.top: parent.top + anchors.left: parent.left + columns: 2 + + QGCLabel { + Layout.fillWidth: true + text: qsTr("Firmware") + visible: _multipleFirmware + } + FactComboBox { + Layout.preferredWidth: _fieldWidth + fact: QGroundControl.settingsManager.appSettings.offlineEditingFirmwareType + indexModel: false + visible: _multipleFirmware + } + + QGCLabel { + Layout.fillWidth: true + text: qsTr("Vehicle") + visible: _multipleVehicleTypes + } + FactComboBox { + Layout.preferredWidth: _fieldWidth + fact: QGroundControl.settingsManager.appSettings.offlineEditingVehicleType + indexModel: false + visible: _multipleVehicleTypes + } + + QGCLabel { + Layout.fillWidth: true + text: qsTr("Mission Cruise Speed") + visible: _showCruiseSpeed + } + FactTextField { + Layout.preferredWidth: _fieldWidth + fact: QGroundControl.settingsManager.appSettings.offlineEditingCruiseSpeed + visible: _showCruiseSpeed + } + + QGCLabel { + Layout.fillWidth: true + text: qsTr("Mission Hover Speed") + visible: _showHoverSpeed + } + FactTextField { + Layout.preferredWidth: _fieldWidth + fact: QGroundControl.settingsManager.appSettings.offlineEditingHoverSpeed + visible: _showHoverSpeed + } + } + } + } +} diff --git a/src/FirstRunPromptDialogs/UnitsFirstRunPrompt.qml b/src/FirstRunPromptDialogs/UnitsFirstRunPrompt.qml new file mode 100644 index 000000000..65fd41922 --- /dev/null +++ b/src/FirstRunPromptDialogs/UnitsFirstRunPrompt.qml @@ -0,0 +1,115 @@ +/**************************************************************************** + * + * (c) 2009-2020 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + +import QtQuick 2.12 +import QtQuick.Layouts 1.12 + +import QGroundControl 1.0 +import QGroundControl.FactSystem 1.0 +import QGroundControl.FactControls 1.0 +import QGroundControl.ScreenTools 1.0 +import QGroundControl.SettingsManager 1.0 +import QGroundControl.Controls 1.0 + +FirstRunPrompt { + title: qsTr("Measurement Units") + promptId: QGroundControl.corePlugin.unitsFirstRunPromptId + + property real _margins: ScreenTools.defaultFontPixelHeight / 2 + property var _unitsSettings: QGroundControl.settingsManager.unitsSettings + property var _rgFacts: [ _unitsSettings.horizontalDistanceUnits, _unitsSettings.verticalDistanceUnits, _unitsSettings.areaUnits, _unitsSettings.speedUnits, _unitsSettings.temperatureUnits ] + property var _rgLabels: [ qsTr("Horizontal Distance"), qsTr("Vertical Distance"), qsTr("Area"), qsTr("Speed"), qsTr("Temperature") ] + property int _cVisibleFacts: 0 + + Component.onCompleted: { + var cVisibleFacts = 0 + for (var i=0; i<_rgFacts.length; i++) { + if (_rgFacts[i].visible) { + cVisibleFacts++ + } + } + _cVisibleFacts = cVisibleFacts + } + + function changeSystemOfUnits(metric) { + if (_unitsSettings.horizontalDistanceUnits.visible) { + _unitsSettings.horizontalDistanceUnits.value = metric ? UnitsSettings.HorizontalDistanceUnitsMeters : UnitsSettings.HorizontalDistanceUnitsFeet + } + if (_unitsSettings.verticalDistanceUnits.visible) { + _unitsSettings.verticalDistanceUnits.value = metric ? UnitsSettings.VerticalDistanceUnitsMeters : UnitsSettings.VerticalDistanceUnitsFeet + } + if (_unitsSettings.areaUnits.visible) { + _unitsSettings.areaUnits.value = metric ? UnitsSettings.AreaUnitsSquareMeters : UnitsSettings.AreaUnitsSquareFeet + } + if (_unitsSettings.speedUnits.visible) { + _unitsSettings.speedUnits.value = metric ? UnitsSettings.SpeedUnitsMetersPerSecond : UnitsSettings.SpeedUnitsFeetPerSecond + } + if (_unitsSettings.temperatureUnits.visible) { + _unitsSettings.temperatureUnits.value = metric ? UnitsSettings.TemperatureUnitsCelsius : UnitsSettings.TemperatureUnitsFarenheit + } + } + + ColumnLayout { + id: settingsColumn + spacing: ScreenTools.defaultFontPixelHeight + + QGCLabel { + id: unitsSectionLabel + text: qsTr("Choose the measurement units you want to use. You can also change it later in General Settings.") + + Layout.preferredWidth: unitsGrid.width + wrapMode: Text.WordWrap + } + + Rectangle { + Layout.preferredHeight: unitsGrid.height + (_margins * 2) + Layout.preferredWidth: unitsGrid.width + (_margins * 2) + color: qgcPal.windowShade + Layout.fillWidth: true + + GridLayout { + id: unitsGrid + anchors.margins: _margins + anchors.top: parent.top + anchors.left: parent.left + rows: _cVisibleFacts + 1 + flow: GridLayout.TopToBottom + + QGCLabel { text: qsTr("System of units") } + + Repeater { + model: _rgFacts.length + QGCLabel { + text: _rgLabels[index] + visible: _rgFacts[index].visible + } + } + + QGCComboBox { + Layout.fillWidth: true + sizeToContents: true + model: [ qsTr("Metric System"), qsTr("Imperial System") ] + currentIndex: _unitsSettings.horizontalDistanceUnits.value === UnitsSettings.HorizontalDistanceUnitsMeters ? 0 : 1 + onActivated: changeSystemOfUnits(currentIndex === 0 /* metric */) + } + + Repeater { + model: _rgFacts.length + FactComboBox { + Layout.fillWidth: true + sizeToContents: true + fact: _rgFacts[index] + indexModel: false + visible: _rgFacts[index].visible + } + } + } + } + } +} diff --git a/src/QmlControls/HorizontalFactValueGrid.qml b/src/QmlControls/HorizontalFactValueGrid.qml index 21ba635bf..2c89391d5 100644 --- a/src/QmlControls/HorizontalFactValueGrid.qml +++ b/src/QmlControls/HorizontalFactValueGrid.qml @@ -176,7 +176,7 @@ T.HorizontalFactValueGrid { var item = valueGrid.childAt(mouse.x, mouse.y) //console.log(item, item ? item.instrumentValueData : "null", item && item.parent ? item.parent.instrumentValueData : "null") if (item && item.instrumentValueData !== undefined) { - mainWindow.showPopupDialog(valueEditDialog, { instrumentValueData: item.instrumentValueData }) + mainWindow.showPopupDialogFromComponent(valueEditDialog, { instrumentValueData: item.instrumentValueData }) } } diff --git a/src/QmlControls/InstrumentValueEditDialog.qml b/src/QmlControls/InstrumentValueEditDialog.qml index 13d891efe..def76a108 100644 --- a/src/QmlControls/InstrumentValueEditDialog.qml +++ b/src/QmlControls/InstrumentValueEditDialog.qml @@ -77,7 +77,7 @@ QGCPopupDialog { instrumentValueData.text = "" instrumentValueData.icon = instrumentValueData.factValueGrid.iconNames[0] var updateFunction = function(icon){ instrumentValueData.icon = icon } - mainWindow.showPopupDialog(iconPickerDialog, { iconNames: instrumentValueData.factValueGrid.iconNames, icon: instrumentValueData.icon, updateIconFunction: updateFunction }) + mainWindow.showPopupDialogFromComponent(iconPickerDialog, { iconNames: instrumentValueData.factValueGrid.iconNames, icon: instrumentValueData.icon, updateIconFunction: updateFunction }) } } @@ -98,7 +98,7 @@ QGCPopupDialog { anchors.fill: parent onClicked: { var updateFunction = function(icon){ instrumentValueData.icon = icon } - mainWindow.showPopupDialog(iconPickerDialog, { iconNames: instrumentValueData.factValueGrid.iconNames, icon: instrumentValueData.icon, updateIconFunction: updateFunction }) + mainWindow.showPopupDialogFromComponent(iconPickerDialog, { iconNames: instrumentValueData.factValueGrid.iconNames, icon: instrumentValueData.icon, updateIconFunction: updateFunction }) } } @@ -392,7 +392,7 @@ QGCPopupDialog { anchors.fill: parent onClicked: { var updateFunction = function(icon){ updateIconValue(index, icon) } - mainWindow.showPopupDialog(iconPickerDialog, { iconNames: instrumentValueData.factValueGrid.iconNames, icon: modelData, updateIconFunction: updateFunction }) + mainWindow.showPopupDialogFromComponent(iconPickerDialog, { iconNames: instrumentValueData.factValueGrid.iconNames, icon: modelData, updateIconFunction: updateFunction }) } } } diff --git a/src/QmlControls/ParameterEditorDialog.qml b/src/QmlControls/ParameterEditorDialog.qml index 7104fb88d..4d5138114 100644 --- a/src/QmlControls/ParameterEditorDialog.qml +++ b/src/QmlControls/ParameterEditorDialog.qml @@ -290,7 +290,7 @@ QGCViewDialog { text: qsTr("Set RC to Param") width: _editFieldWidth visible: _advanced.checked && !validate && showRCToParam - onClicked: mainWindow.showPopupDialog(rcToParamDialog) + onClicked: mainWindow.showPopupDialogFromComponent(rcToParamDialog) } } // Column } diff --git a/src/QmlControls/QGCPopupDialogContainer.qml b/src/QmlControls/QGCPopupDialogContainer.qml index 9cc11803c..828c7eff0 100644 --- a/src/QmlControls/QGCPopupDialogContainer.qml +++ b/src/QmlControls/QGCPopupDialogContainer.qml @@ -18,10 +18,11 @@ import QGroundControl.Palette 1.0 import QGroundControl.ScreenTools 1.0 Popup { - property var dialogComponent - property var dialogProperties + property var dialogComponent + property string dialogSource + property var dialogProperties - id: popupRoot + id: _root anchors.centerIn: parent width: mainColumnLayout.width + (padding * 2) height: mainColumnLayout.y + mainColumnLayout.height + padding @@ -75,7 +76,7 @@ Popup { } Rectangle { - anchors.margins: popupRoot.padding + anchors.margins: _root.padding anchors.fill: parent color: _pal.window } @@ -209,10 +210,11 @@ Popup { Loader { id: dialogComponentLoader x: _contentMargin + source: dialogSource sourceComponent: dialogComponent focus: true - property var dialogProperties: popupRoot.dialogProperties + property var dialogProperties: _root.dialogProperties property bool acceptAllowed: acceptButton.visible property bool rejectAllowed: rejectButton.visible } diff --git a/src/QmlControls/QGroundControl/Controls/qmldir b/src/QmlControls/QGroundControl/Controls/qmldir index 3fd6b4b58..03cf60439 100644 --- a/src/QmlControls/QGroundControl/Controls/qmldir +++ b/src/QmlControls/QGroundControl/Controls/qmldir @@ -15,6 +15,7 @@ DropPanel 1.0 DropPanel.qml EditPositionDialog 1.0 EditPositionDialog.qml ExclusiveGroupItem 1.0 ExclusiveGroupItem.qml FactSliderPanel 1.0 FactSliderPanel.qml +FirstRunPrompt 1.0 FirstRunPrompt.qml FileButton 1.0 FileButton.qml FlightModeDropdown 1.0 FlightModeDropdown.qml FlightModeMenu 1.0 FlightModeMenu.qml diff --git a/src/QmlControls/QGroundControl/Specific/BaseStartupWizardPage.qml b/src/QmlControls/QGroundControl/Specific/BaseStartupWizardPage.qml deleted file mode 100644 index 2e902f6d3..000000000 --- a/src/QmlControls/QGroundControl/Specific/BaseStartupWizardPage.qml +++ /dev/null @@ -1,10 +0,0 @@ -import QtQuick 2.12 - -Item { - // `null` for default which makes the wizzard display one of the buttons: "Next" if more pages or "Done" if the last - property string doneText: null - // Blocks user from closing the wizard or going to the next page until this becomes true - property bool forceConfirmation: false - - signal closeView() -} diff --git a/src/QmlControls/QGroundControl/Specific/StartupWizard.qml b/src/QmlControls/QGroundControl/Specific/StartupWizard.qml deleted file mode 100644 index a4656d5e4..000000000 --- a/src/QmlControls/QGroundControl/Specific/StartupWizard.qml +++ /dev/null @@ -1,87 +0,0 @@ -import QtQuick 2.11 -import QtQuick.Layouts 1.11 - -import QGroundControl.ScreenTools 1.0 -import QGroundControl.Controls 1.0 -import QGroundControl.Palette 1.0 -import QGroundControl 1.0 -import QGroundControl.Specific 1.0 - - -Item { - id: _root - - implicitWidth: contentColumn.implicitWidth + contentColumn.anchors.margins * 2.5 - implicitHeight: contentColumn.implicitHeight + contentColumn.anchors.margins * 2 + contentColumn.spacing * 3 - - property bool forceKeepingOpen: _pageReady && pageLoader.item.forceConfirmation && !_armed - - signal closeView() - - property bool _pageReady: pageLoader.status === Loader.Ready - property int _currentIndex: 0 - property int _pagesCount: QGroundControl.corePlugin.startupPages.length - property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle - property bool _armed: _activeVehicle && _activeVehicle.armed - - function doneOrJumpToNext() { - if(_currentIndex < _pagesCount - 1) - _currentIndex += 1 - else { - _root.closeView() - QGroundControl.settingsManager.appSettings.firstTimeStart.value = false - } - } - - Connections { - target: _pageReady ? pageLoader.item : null - onCloseView: doneOrJumpToNext() - } - - ColumnLayout { - id: contentColumn - anchors.fill: parent - anchors.margins: ScreenTools.defaultFontPixelHeight - spacing: ScreenTools.defaultFontPixelHeight * 0.5 - - QGCLabel { - id: titleLabel - text: qsTr("Welcome to " + QGroundControl.appName) - color: qgcPal.text - font.family: ScreenTools.demiboldFontFamily - font.pointSize: ScreenTools.mediumFontPointSize - } - - Rectangle { - id: separatorRect - height: 1 - color: qgcPal.windowShade - Layout.fillWidth: true - } - - Flickable { - id: flickablePage - clip: true - - contentWidth: pageLoader.item ? pageLoader.item.width : 0 - contentHeight: pageLoader.item ? pageLoader.item.height : 0 - - Layout.fillHeight: true - Layout.preferredWidth: contentWidth - Layout.preferredHeight: contentHeight - - Loader { - id: pageLoader - source: QGroundControl.corePlugin.startupPages[_currentIndex] - } - } - - QGCButton { - id: confirmButton - property string _acknowledgeText: _pagesCount <= 1 ? qsTr("Next") : qsTr("Done") - - text: (_pageReady && pageLoader.item && pageLoader.item.doneText) ? pageLoader.item.doneText : _acknowledgeText - onClicked: doneOrJumpToNext() - } - } -} diff --git a/src/QmlControls/QGroundControl/Specific/UnitsWizardPage.qml b/src/QmlControls/QGroundControl/Specific/UnitsWizardPage.qml deleted file mode 100644 index 893406500..000000000 --- a/src/QmlControls/QGroundControl/Specific/UnitsWizardPage.qml +++ /dev/null @@ -1,81 +0,0 @@ -import QtQuick 2.12 -import QtQuick.Layouts 1.12 - -import QGroundControl 1.0 -import QGroundControl.FactSystem 1.0 -import QGroundControl.FactControls 1.0 -import QGroundControl.ScreenTools 1.0 -import QGroundControl.SettingsManager 1.0 -import QGroundControl.Controls 1.0 -import QGroundControl.Specific 1.0 - -BaseStartupWizardPage { - width: settingsColumn.width - height: settingsColumn.height - - property real _margins: ScreenTools.defaultFontPixelWidth - property real _comboFieldWidth: ScreenTools.defaultFontPixelWidth * 20 - - doneText: qsTr("Confirm") - - ColumnLayout { - id: settingsColumn - anchors.horizontalCenter: parent.horizontalCenter - spacing: ScreenTools.defaultFontPixelHeight - - QGCLabel { - id: unitsSectionLabel - text: qsTr("Choose the measurement units you want to use in the application. You can change it later on in General Settings.") - - Layout.preferredWidth: unitsGrid.width - wrapMode: Text.WordWrap - } - - Rectangle { - Layout.preferredHeight: unitsGrid.height + (_margins * 2) - Layout.preferredWidth: unitsGrid.width + (_margins * 2) - color: qgcPal.windowShade - Layout.fillWidth: true - - GridLayout { - id: unitsGrid - anchors.topMargin: _margins - anchors.top: parent.top - Layout.fillWidth: false - anchors.horizontalCenter: parent.horizontalCenter - flow: GridLayout.TopToBottom - rows: 5 - - QGCLabel { text: qsTr("System of units") } - - Repeater { - model: [ qsTr("Distance"), qsTr("Area"), qsTr("Speed"), qsTr("Temperature") ] - QGCLabel { text: modelData } - } - - QGCComboBox { - model: [qsTr("Metric System"), qsTr("Imperial System")] - Layout.preferredWidth: _comboFieldWidth - - currentIndex: QGroundControl.settingsManager.unitsSettings.horizontalDistanceUnits.value === UnitsSettings.HorizontalDistanceUnitsMeters ? 0 : 1 - - onActivated: { - var metric = (currentIndex === 0); - QGroundControl.settingsManager.unitsSettings.horizontalDistanceUnits.value = metric ? UnitsSettings.HorizontalDistanceUnitsMeters : UnitsSettings.HorizontalDistanceUnitsFeet - QGroundControl.settingsManager.unitsSettings.areaUnits.value = metric ? UnitsSettings.AreaUnitsSquareMeters : UnitsSettings.AreaUnitsSquareFeet - QGroundControl.settingsManager.unitsSettings.speedUnits.value = metric ? UnitsSettings.SpeedUnitsMetersPerSecond : UnitsSettings.SpeedUnitsFeetPerSecond - QGroundControl.settingsManager.unitsSettings.temperatureUnits.value = metric ? UnitsSettings.TemperatureUnitsCelsius : UnitsSettings.TemperatureUnitsFarenheit - } - } - Repeater { - model: [ QGroundControl.settingsManager.unitsSettings.horizontalDistanceUnits, QGroundControl.settingsManager.unitsSettings.areaUnits, QGroundControl.settingsManager.unitsSettings.speedUnits, QGroundControl.settingsManager.unitsSettings.temperatureUnits ] - FactComboBox { - Layout.preferredWidth: _comboFieldWidth - fact: modelData - indexModel: false - } - } - } - } - } -} diff --git a/src/QmlControls/QGroundControl/Specific/qmldir b/src/QmlControls/QGroundControl/Specific/qmldir deleted file mode 100644 index ab4932968..000000000 --- a/src/QmlControls/QGroundControl/Specific/qmldir +++ /dev/null @@ -1,5 +0,0 @@ -module QGroundControl.Specific - -BaseStartupWizardPage 1.0 BaseStartupWizardPage.qml -StartupWizard 1.0 StartupWizard.qml -UnitsWizardPage 1.0 UnitsWizardPage.qml diff --git a/src/QmlControls/VerticalFactValueGrid.qml b/src/QmlControls/VerticalFactValueGrid.qml index ea9fbbcfc..07cc5da46 100644 --- a/src/QmlControls/VerticalFactValueGrid.qml +++ b/src/QmlControls/VerticalFactValueGrid.qml @@ -144,7 +144,7 @@ T.VerticalFactValueGrid { var item = valueGrid.childAt(mouse.x, mouse.y) //console.log(item, item ? item.instrumentValueData : "null", item && item.parent ? item.parent.instrumentValueData : "null") if (item && item.instrumentValueData !== undefined) { - mainWindow.showPopupDialog(valueEditDialog, { instrumentValueData: item.instrumentValueData }) + mainWindow.showPopupDialogFromComponent(valueEditDialog, { instrumentValueData: item.instrumentValueData }) } } diff --git a/src/Settings/App.SettingsGroup.json b/src/Settings/App.SettingsGroup.json index 3f212dd79..3fc6fc578 100644 --- a/src/Settings/App.SettingsGroup.json +++ b/src/Settings/App.SettingsGroup.json @@ -22,7 +22,7 @@ { "name": "offlineEditingCruiseSpeed", "shortDescription": "Offline editing cruise speed", - "longDescription": "This value defines the default cruising speed for forward flight vehicles for use in calculating mission statistics. It does not modify the flight speed for a specific flight plan.", + "longDescription": "This value defines the default speed for calculating mission statistics for vehicles which do not support hover or VTOL vehicles in fixed wing mode. It does not modify the flight speed for a specific flight plan.", "type": "double", "defaultValue": 15.0, "min": 1.0, @@ -32,7 +32,7 @@ { "name": "offlineEditingHoverSpeed", "shortDescription": "Offline editing hover speed", - "longDescription": "This value defines the default cruising speed for multi-rotor vehicles for use in calculating mission statistics. It does not modify the flight speed for a specific flight plan.", + "longDescription": "This value defines the default speed for calculating mission statistics for multi-rotor vehicles or VTOL vehicle in multi-rotor mode. It does not modify the flight speed for a specific flight plan.", "type": "double", "defaultValue": 5.0, "min": 1.0, @@ -282,11 +282,10 @@ "defaultValue": false }, { - "name": "firstTimeStart", - "shortDescription": "True if we should popup first time wizard", - "longDescription": "If this option is enabled, the first time startup wizard will prompt the user at first application start on a new system.", - "type": "bool", - "defaultValue": true + "name": "firstRunPromptIdsShown", + "shortDescription": "Comma separated list of first run prompt ids which have already been shown.", + "type": "string", + "defaultValue": "" } ] } diff --git a/src/Settings/AppSettings.cc b/src/Settings/AppSettings.cc index a77836e5e..5d898229a 100644 --- a/src/Settings/AppSettings.cc +++ b/src/Settings/AppSettings.cc @@ -105,7 +105,7 @@ DECLARE_SETTINGSFACT(AppSettings, language) DECLARE_SETTINGSFACT(AppSettings, disableAllPersistence) DECLARE_SETTINGSFACT(AppSettings, usePairing) DECLARE_SETTINGSFACT(AppSettings, saveCsvTelemetry) -DECLARE_SETTINGSFACT(AppSettings, firstTimeStart) +DECLARE_SETTINGSFACT(AppSettings, firstRunPromptIdsShown) DECLARE_SETTINGSFACT_NO_FUNC(AppSettings, indoorPalette) { @@ -224,3 +224,31 @@ MAV_TYPE AppSettings::offlineEditingVehicleTypeFromVehicleType(MAV_TYPE vehicleT return MAV_TYPE_QUADROTOR; } } + +QList AppSettings::firstRunPromptsIdsVariantToList(const QVariant& firstRunPromptIds) +{ + QList rgIds; + QStringList strIdList = firstRunPromptIds.toString().split(",", QString::SkipEmptyParts); + for (const QString& strId: strIdList) { + rgIds.append(strId.toInt()); + } + return rgIds; +} + +QVariant AppSettings::firstRunPromptsIdsListToVariant(const QList& rgIds) +{ + QStringList strList; + for (int id: rgIds) { + strList.append(QString::number(id)); + } + return QVariant(strList.join(",")); +} + +void AppSettings::firstRunPromptIdsMarkIdAsShown(int id) +{ + QList rgIds = firstRunPromptsIdsVariantToList(firstRunPromptIdsShown()->rawValue()); + if (!rgIds.contains(id)) { + rgIds.append(id); + firstRunPromptIdsShown()->setRawValue(firstRunPromptsIdsListToVariant(rgIds)); + } +} diff --git a/src/Settings/AppSettings.h b/src/Settings/AppSettings.h index 9c2a2b6a5..db5f0f9fc 100644 --- a/src/Settings/AppSettings.h +++ b/src/Settings/AppSettings.h @@ -59,7 +59,7 @@ public: DEFINE_SETTINGFACT(disableAllPersistence) DEFINE_SETTINGFACT(usePairing) DEFINE_SETTINGFACT(saveCsvTelemetry) - DEFINE_SETTINGFACT(firstTimeStart) + DEFINE_SETTINGFACT(firstRunPromptIdsShown) // Although this is a global setting it only affects ArduPilot vehicle since PX4 automatically starts the stream from the vehicle side @@ -88,6 +88,11 @@ public: QString videoSavePath (); QString crashSavePath (); + // Helper methods for working with firstRunPromptIds QVariant settings string list + static QList firstRunPromptsIdsVariantToList (const QVariant& firstRunPromptIds); + static QVariant firstRunPromptsIdsListToVariant (const QList& rgIds); + Q_INVOKABLE void firstRunPromptIdsMarkIdAsShown (int id); + static MAV_AUTOPILOT offlineEditingFirmwareTypeFromFirmwareType (MAV_AUTOPILOT firmwareType); static MAV_TYPE offlineEditingVehicleTypeFromVehicleType (MAV_TYPE vehicleType); diff --git a/src/api/QGCCorePlugin.cc b/src/api/QGCCorePlugin.cc index b72625ade..43857410a 100644 --- a/src/api/QGCCorePlugin.cc +++ b/src/api/QGCCorePlugin.cc @@ -533,12 +533,7 @@ QString QGCCorePlugin::stableVersionCheckFileUrl() const #endif } -QStringList QGCCorePlugin::startupPages() -{ - return { "/qml/QGroundControl/Specific/UnitsWizardPage.qml" }; -} - -const QVariantList &QGCCorePlugin::toolBarIndicators(void) +const QVariantList& QGCCorePlugin::toolBarIndicators(void) { //-- Default list of indicators for all vehicles. if(_toolBarIndicatorList.size() == 0) { @@ -548,3 +543,48 @@ const QVariantList &QGCCorePlugin::toolBarIndicators(void) } return _toolBarIndicatorList; } + +QList QGCCorePlugin::firstRunPromptStdIds(void) +{ + QList rgStdIds = { unitsFirstRunPromptId, offlineVehicleFirstRunPromptId }; + return rgStdIds; +} + +QList QGCCorePlugin::firstRunPromptCustomIds(void) +{ + return QList(); +} + +QVariantList QGCCorePlugin::firstRunPromptsToShow(void) +{ + QList rgIdsToShow; + + rgIdsToShow.append(firstRunPromptStdIds()); + rgIdsToShow.append(firstRunPromptCustomIds()); + + QList rgAlreadyShownIds = AppSettings::firstRunPromptsIdsVariantToList(_toolbox->settingsManager()->appSettings()->firstRunPromptIdsShown()->rawValue()); + + for (int idToRemove: rgAlreadyShownIds) { + rgIdsToShow.removeOne(idToRemove); + } + + QVariantList rgVarIdsToShow; + for (int id: rgIdsToShow) { + rgVarIdsToShow.append(id); + } + + return rgVarIdsToShow; +} + +QString QGCCorePlugin::firstRunPromptResource(int id) +{ + switch (id) { + case unitsFirstRunPromptId: + return "/FirstRunPromptDialogs/UnitsFirstRunPrompt.qml"; + case offlineVehicleFirstRunPromptId: + return "/FirstRunPromptDialogs/OfflineVehicleFirstRunPrompt.qml"; + break; + } + + return QString(); +} diff --git a/src/api/QGCCorePlugin.h b/src/api/QGCCorePlugin.h index 3aca7e694..ed92b158f 100644 --- a/src/api/QGCCorePlugin.h +++ b/src/api/QGCCorePlugin.h @@ -46,19 +46,20 @@ public: QGCCorePlugin(QGCApplication* app, QGCToolbox* toolbox); ~QGCCorePlugin(); - Q_PROPERTY(QVariantList settingsPages READ settingsPages NOTIFY settingsPagesChanged) - Q_PROPERTY(QVariantList analyzePages READ analyzePages NOTIFY analyzePagesChanged) - Q_PROPERTY(QVariantList instrumentPages READ instrumentPages NOTIFY instrumentPagesChanged) - Q_PROPERTY(int defaultSettings READ defaultSettings CONSTANT) - Q_PROPERTY(QGCOptions* options READ options CONSTANT) - Q_PROPERTY(bool showTouchAreas READ showTouchAreas WRITE setShowTouchAreas NOTIFY showTouchAreasChanged) - Q_PROPERTY(bool showAdvancedUI READ showAdvancedUI WRITE setShowAdvancedUI NOTIFY showAdvancedUIChanged) - Q_PROPERTY(QString showAdvancedUIMessage READ showAdvancedUIMessage CONSTANT) - Q_PROPERTY(QString brandImageIndoor READ brandImageIndoor CONSTANT) - Q_PROPERTY(QString brandImageOutdoor READ brandImageOutdoor CONSTANT) - Q_PROPERTY(QmlObjectListModel* customMapItems READ customMapItems CONSTANT) - Q_PROPERTY(QStringList startupPages READ startupPages NOTIFY startupPagesChanged) - Q_PROPERTY(QVariantList toolBarIndicators READ toolBarIndicators NOTIFY toolBarIndicatorsChanged) + Q_PROPERTY(QVariantList settingsPages READ settingsPages NOTIFY settingsPagesChanged) + Q_PROPERTY(QVariantList analyzePages READ analyzePages NOTIFY analyzePagesChanged) + Q_PROPERTY(QVariantList instrumentPages READ instrumentPages NOTIFY instrumentPagesChanged) + Q_PROPERTY(int defaultSettings READ defaultSettings CONSTANT) + Q_PROPERTY(QGCOptions* options READ options CONSTANT) + Q_PROPERTY(bool showTouchAreas READ showTouchAreas WRITE setShowTouchAreas NOTIFY showTouchAreasChanged) + Q_PROPERTY(bool showAdvancedUI READ showAdvancedUI WRITE setShowAdvancedUI NOTIFY showAdvancedUIChanged) + Q_PROPERTY(QString showAdvancedUIMessage READ showAdvancedUIMessage CONSTANT) + Q_PROPERTY(QString brandImageIndoor READ brandImageIndoor CONSTANT) + Q_PROPERTY(QString brandImageOutdoor READ brandImageOutdoor CONSTANT) + Q_PROPERTY(QmlObjectListModel* customMapItems READ customMapItems CONSTANT) + Q_PROPERTY(QVariantList toolBarIndicators READ toolBarIndicators NOTIFY toolBarIndicatorsChanged) + Q_PROPERTY(int unitsFirstRunPromptId MEMBER unitsFirstRunPromptId CONSTANT) + Q_PROPERTY(int offlineVehicleFirstRunPromptId MEMBER offlineVehicleFirstRunPromptId CONSTANT) Q_INVOKABLE bool guidedActionsControllerLogging() const; @@ -165,18 +166,27 @@ public: /// @return Complex items to be made available to user virtual QStringList complexMissionItemNames(Vehicle* /*vehicle*/, const QStringList& complexMissionItemNames) { return complexMissionItemNames; } - /// Use it to customize the pages that are shown on startup. This will be queried - /// only if AppSettings::firstTimeStart Fact is true, that is reset to false when the user - /// goes for the fist time through all the pages. - /// Insert pages only if they are required to be displayed at start for a good user experience. - /// @return QML files paths that will be loaded using the StartupWizard control - virtual QStringList startupPages(); + /// Returns the standard list of first run prompt ids for possible display. Actual display is based on the + /// current AppSettings::firstRunPromptIds value. The order of this list also determines the order the prompts + /// will be displayed in. + virtual QList firstRunPromptStdIds(void); + + /// Returns the custom build list of first run prompt ids for possible display. Actual display is based on the + /// current AppSettings::firstRunPromptIds value. The order of this list also determines the order the prompts + /// will be displayed in. + virtual QList firstRunPromptCustomIds(void); + + /// Returns the resource which contains the specified first run prompt for display + Q_INVOKABLE virtual QString firstRunPromptResource(int id); /// Returns the list of toolbar indicators which are not related to a vehicle /// signals toolbarIndicatorsChanged /// @return A list of QUrl with the indicators virtual const QVariantList& toolBarIndicators(void); + /// Returns the list of first run prompt ids which need to be displayed according to current settings + Q_INVOKABLE QVariantList firstRunPromptsToShow(void); + bool showTouchAreas() const { return _showTouchAreas; } bool showAdvancedUI() const { return _showAdvancedUI; } void setShowTouchAreas(bool show); @@ -185,13 +195,19 @@ public: // Override from QGCTool void setToolbox (QGCToolbox* toolbox); + // Standard first run prompt ids + static const int unitsFirstRunPromptId = 1; + static const int offlineVehicleFirstRunPromptId = 2; + + // Custom builds can start there first run prompt ids from here + static const int firstRunPromptIdsFirstCustomId = 10000; + signals: void settingsPagesChanged (); void analyzePagesChanged (); void instrumentPagesChanged (); void showTouchAreasChanged (bool showTouchAreas); void showAdvancedUIChanged (bool showAdvancedUI); - void startupPagesChanged (); void toolBarIndicatorsChanged (); protected slots: diff --git a/src/ui/MainRootWindow.qml b/src/ui/MainRootWindow.qml index a3645d2e3..010ec2660 100644 --- a/src/ui/MainRootWindow.qml +++ b/src/ui/MainRootWindow.qml @@ -19,7 +19,6 @@ import QGroundControl.Controls 1.0 import QGroundControl.ScreenTools 1.0 import QGroundControl.FlightDisplay 1.0 import QGroundControl.FlightMap 1.0 -import QGroundControl.Specific 1.0 /// @brief Native QML top level window /// All properties defined here are visible to all QML pages. @@ -38,11 +37,34 @@ ApplicationWindow { height = ScreenTools.isMobile ? Screen.height : Math.min(150 * Screen.pixelDensity, Screen.height) } - // Startup experience wizard and provide the source using QGCCorePlugin - if (QGroundControl.settingsManager.appSettings.firstTimeStart.value) { - startupPopup.open() - } else { - showPreFlightChecklistIfNeeded() + // Start the sequence of first run prompt(s) + firstRunPromptManager.nextPrompt() + } + + QtObject { + id: firstRunPromptManager + + property var currentDialog: null + property var rgPromptIds: QGroundControl.corePlugin.firstRunPromptsToShow() + property int nextPromptIdIndex: 0 + + onRgPromptIdsChanged: console.log(QGroundControl.corePlugin, QGroundControl.corePlugin.firstRunPromptsToShow()) + + function clearNextPromptSignal() { + if (currentDialog) { + currentDialog.closed.disconnect(nextPrompt) + } + } + + function nextPrompt() { + if (nextPromptIdIndex < rgPromptIds.length) { + currentDialog = showPopupDialogFromSource(QGroundControl.corePlugin.firstRunPromptResource(rgPromptIds[nextPromptIdIndex])) + currentDialog.closed.connect(nextPrompt) + nextPromptIdIndex++ + } else { + currentDialog = null + showPreFlightChecklistIfNeeded() + } } } @@ -228,9 +250,18 @@ ApplicationWindow { } } - function showPopupDialog(component, properties) { + // Dialogs based on QGCPopupDialog + + function showPopupDialogFromComponent(component, properties) { var dialog = popupDialogContainerComponent.createObject(mainWindow, { dialogComponent: component, dialogProperties: properties }) dialog.open() + return dialog + } + + function showPopupDialogFromSource(source, properties) { + var dialog = popupDialogContainerComponent.createObject(mainWindow, { dialogSource: source, dialogProperties: properties }) + dialog.open() + return dialog } Component { @@ -241,9 +272,12 @@ ApplicationWindow { property bool _forceClose: false function finishCloseProcess() { + _forceClose = true + // For some reason on the Qml side Qt doesn't automatically disconnect a signal when an object is destroyed. + // So we have to do it ourselves otherwise the signal flows through on app shutdown to an object which no longer exists. + firstRunPromptManager.clearNextPromptSignal() QGroundControl.linkManager.shutdown() QGroundControl.videoManager.stopVideo(); - _forceClose = true mainWindow.close() } @@ -684,35 +718,4 @@ ApplicationWindow { indicatorDropdown.currentIndicator = null } } - - //-- Startup PopUp wizard - Popup { - id: startupPopup - anchors.centerIn: parent - width: Math.min(startupWizard.implicitWidth, mainWindow.width - 2 * startupPopup._horizontalSpacing) - height: Math.min(startupWizard.implicitHeight, mainWindow.availableHeight - 2 * startupPopup._verticalSpacing) - modal: true - focus: true - closePolicy: (startupWizard && startupWizard.forceKeepingOpen !== undefined && startupWizard.forceKeepingOpen) ? Popup.NoAutoClose : Popup.CloseOnEscape | Popup.CloseOnPressOutside - - onClosed: mainWindow.showPreFlightChecklistIfNeeded() - - property real _horizontalSpacing: ScreenTools.defaultFontPixelWidth * 5 - property real _verticalSpacing: ScreenTools.defaultFontPixelHeight * 2 - - Connections { - target: startupWizard - onCloseView: startupPopup.close() - } - - background: Rectangle { - radius: ScreenTools.defaultFontPixelHeight * 0.5 - color: qgcPal.window - } - - StartupWizard { - id: startupWizard - anchors.fill: parent - } - } } -- 2.22.0