From 39c9615d1e2e589c7524b890d484d57c0fb00ad5 Mon Sep 17 00:00:00 2001 From: DonLakeFlyer Date: Mon, 24 May 2021 12:09:00 -0700 Subject: [PATCH] Fix calibration dialog sequence --- src/AutoPilotPlugins/PX4/PowerComponent.qml | 33 +++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/src/AutoPilotPlugins/PX4/PowerComponent.qml b/src/AutoPilotPlugins/PX4/PowerComponent.qml index c763ccd..a5df76c 100644 --- a/src/AutoPilotPlugins/PX4/PowerComponent.qml +++ b/src/AutoPilotPlugins/PX4/PowerComponent.qml @@ -57,11 +57,8 @@ SetupPage { id: controller onOldFirmware: mainWindow.showMessageDialog(qsTr("ESC Calibration"), qsTr("%1 cannot perform ESC Calibration with this version of firmware. You will need to upgrade to a newer firmware.").arg(QGroundControl.appName)) onNewerFirmware: mainWindow.showMessageDialog(qsTr("ESC Calibration"), qsTr("%1 cannot perform ESC Calibration with this version of firmware. You will need to upgrade %1.").arg(QGroundControl.appName)) - onBatteryConnected: mainWindow.showMessageDialog(qsTr("ESC Calibration"), qsTr("Performing calibration. This will take a few seconds..")) - onCalibrationFailed: mainWindow.showMessageDialog(qsTr("ESC Calibration failed"), errorMessage) - onCalibrationSuccess: mainWindow.showMessageDialog(qsTr("ESC Calibration"), qsTr("Calibration complete. You can disconnect your battery now if you like.")) - onConnectBattery: mainWindow.showMessageDialog(qsTr("ESC Calibration"), _highlightPrefix + qsTr("WARNING: Props must be removed from vehicle prior to performing ESC calibration.") + _highlightSuffix + qsTr(" Connect the battery now and calibration will begin.")) onDisconnectBattery: mainWindow.showMessageDialog(qsTr("ESC Calibration failed"), qsTr("You must disconnect the battery prior to performing ESC Calibration. Disconnect your battery and try again.")) + onConnectBattery: { var dialog = mainWindow.showPopupDialogFromComponent(escCalibrationDlgComponent); dialog.disableAcceptButton() } } ColumnLayout { @@ -524,6 +521,34 @@ SetupPage { } } } + + Component { + id: escCalibrationDlgComponent + + QGCPopupDialog { + id: popupDialog + title: qsTr("ESC Calibration") + buttons: StandardButton.Ok + + Connections { + target: controller + + onBatteryConnected: textLabel.text = qsTr("Performing calibration. This will take a few seconds..") + onCalibrationFailed: { popupDialog.enableAcceptButton(); textLabel.text = _highlightPrefix + qsTr("ESC Calibration failed. ") + _highlightSuffix + errorMessage } + onCalibrationSuccess: { popupDialog.enableAcceptButton(); textLabel.text = qsTr("Calibration complete. You can disconnect your battery now if you like.") } + } + + ColumnLayout { + QGCLabel { + id: textLabel + wrapMode: Text.WordWrap + text: _highlightPrefix + qsTr("WARNING: Props must be removed from vehicle prior to performing ESC calibration.") + _highlightSuffix + qsTr(" Connect the battery now and calibration will begin.") + Layout.fillWidth: true + Layout.maximumWidth: mainWindow.width / 2 + } + } + } + } } // Item } // Component } // SetupPage