Unverified Commit cc99ed6b authored by Gus Grubba's avatar Gus Grubba Committed by GitHub

Merge pull request #7485 from mavlink/customFirmware

Switch custom firmware file picker to QtQuick
parents fa92eced 5499e8c6
......@@ -79,6 +79,18 @@ SetupPage {
_defaultFirmwareIsPX4 = _defaultFirmwareFact.rawValue === _defaultFimwareTypePX4 // we don't want this to be bound and change as radios are selected
}
QGCFileDialog {
id: customFirmwareDialog
title: qsTr("Select Firmware File")
nameFilters: [qsTr("Firmware Files (*.px4 *.apj *.bin *.ihx)"), qsTr("All Files (*)")]
selectExisting: true
folder: QGroundControl.settingsManager.appSettings.logSavePath
onAcceptedForLoad: {
controller.flashFirmwareUrl(file)
close()
}
}
FirmwareUpgradeController {
id: controller
progressBar: progressBar
......@@ -117,8 +129,9 @@ SetupPage {
statusTextArea.append(highlightPrefix + qsTr("Multiple devices detected! Remove all detected devices to perform the firmware upgrade."))
statusTextArea.append(qsTr("Detected [%1]: ").arg(availableDevices.length) + availableDevices.join(", "))
}
QGroundControl.multiVehicleManager.activeVehicle.autoDisconnect = true
if(QGroundControl.multiVehicleManager.activeVehicle) {
QGroundControl.multiVehicleManager.activeVehicle.autoDisconnect = true
}
} else {
// We end up here when we detect a board plugged in after we've started upgrade
statusTextArea.append(highlightPrefix + qsTr("Found device") + highlightSuffix + ": " + controller.boardType)
......@@ -210,7 +223,12 @@ SetupPage {
}
}
}
controller.flash(stack, firmwareBuildType, vehicleType)
//-- If custom, get file path
if (firmwareBuildType === FirmwareUpgradeController.CustomFirmware) {
customFirmwareDialog.openForLoad()
} else {
controller.flash(stack, firmwareBuildType, vehicleType)
}
hideDialog()
}
}
......@@ -220,7 +238,6 @@ SetupPage {
cancelFlash()
}
Connections {
target: firmwarePage
onCancelDialog: reject()
......@@ -304,6 +321,13 @@ SetupPage {
Column {
Component.onCompleted: {
if(!QGroundControl.apmFirmwareSupported) {
_defaultFirmwareFact.rawValue = _defaultFimwareTypePX4
firmwareVersionChanged(firmwareBuildTypeList)
}
}
QGCRadioButton {
id: px4FlightStackRadio
text: qsTr("PX4 Pro ")
......@@ -371,7 +395,7 @@ SetupPage {
anchors.right: parent.right
wrapMode: Text.WordWrap
text: qsTr("No Firmware Available")
visible: !controller.downloadingFirmwareList && controller.apmFirmwareNames.length === 0
visible: !controller.downloadingFirmwareList && (QGroundControl.apmFirmwareSupported && controller.apmFirmwareNames.length === 0)
}
QGCComboBox {
......
......@@ -93,12 +93,17 @@ FirmwareUpgradeController::FirmwareUpgradeController(void)
connect(&_eraseTimer, &QTimer::timeout, this, &FirmwareUpgradeController::_eraseProgressTick);
#if !defined(NO_ARDUPILOT_DIALECT)
connect(_apmChibiOSSetting, &Fact::rawValueChanged, this, &FirmwareUpgradeController::_buildAPMFirmwareNames);
connect(_apmVehicleTypeSetting, &Fact::rawValueChanged, this, &FirmwareUpgradeController::_buildAPMFirmwareNames);
#endif
_initFirmwareHash();
_determinePX4StableVersion();
#if !defined(NO_ARDUPILOT_DIALECT)
_downloadArduPilotManifest();
#endif
}
FirmwareUpgradeController::~FirmwareUpgradeController()
......@@ -478,16 +483,12 @@ QHash<FirmwareUpgradeController::FirmwareIdentifier, QString>* FirmwareUpgradeCo
return &_rgFirmwareDynamic;
}
/// @brief Prompts the user to select a firmware file if needed and moves the state machine to the next state.
void FirmwareUpgradeController::_getFirmwareFile(FirmwareIdentifier firmwareId)
{
QHash<FirmwareIdentifier, QString>* prgFirmware = _firmwareHashForBoardId(static_cast<int>(_bootloaderBoardID));
if (firmwareId.firmwareType == CustomFirmware) {
_firmwareFilename = QString(); //-- TODO: QGCQFileDialog::getOpenFileName(nullptr, // Parent to main window
// tr("Select Firmware File"), // Dialog Caption
// QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), // Initial directory
// tr("Firmware Files (*.px4 *.apj *.bin *.ihx)")); // File filter
_firmwareFilename = QString();
_errorCancel(tr("Custom firmware selected but no filename given."));
} else {
if (prgFirmware->contains(firmwareId)) {
_firmwareFilename = prgFirmware->value(firmwareId);
......@@ -673,6 +674,7 @@ void FirmwareUpgradeController::setSelectedFirmwareBuildType(FirmwareBuildType_t
void FirmwareUpgradeController::_buildAPMFirmwareNames(void)
{
#if !defined(NO_ARDUPILOT_DIALECT)
qCDebug(FirmwareUpgradeLog) << "_buildAPMFirmwareNames";
bool chibios = _apmChibiOSSetting->rawValue().toInt() == 0;
......@@ -717,6 +719,7 @@ void FirmwareUpgradeController::_buildAPMFirmwareNames(void)
}
emit apmFirmwareNamesChanged();
#endif
}
FirmwareUpgradeController::FirmwareVehicleType_t FirmwareUpgradeController::vehicleTypeFromFirmwareSelectionIndex(int index)
......
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