diff --git a/src/AutoPilotPlugins/PX4/AirframeComponent.qml b/src/AutoPilotPlugins/PX4/AirframeComponent.qml index 277458be031cc5cb28f7d99d2f150c7dd56a67e6..8cc94555937abeafd6cf15cb84ce81eeabc32905 100644 --- a/src/AutoPilotPlugins/PX4/AirframeComponent.qml +++ b/src/AutoPilotPlugins/PX4/AirframeComponent.qml @@ -51,7 +51,7 @@ QGCView { onCompleted: { if (controller.showCustomConfigPanel) { - panel.showDialog(customConfigDialog, "Custom Airframe Config", 50, StandardButton.Reset) + panel.showDialog(customConfigDialogComponent, "Custom Airframe Config", 50, StandardButton.Reset) } } } @@ -62,23 +62,45 @@ QGCView { } Component { - id: customConfigDialog + id: customConfigDialogComponent - QGCLabel { - id: customConfigPanel - anchors.fill: parent - wrapMode: Text.WordWrap - text: "Your vehicle is using a custom airframe configuration. " + - "This configuration can only be modified through the Parameter Editor.\n\n" + - "If you want to Reset your airframe configuration and select a standard configuration, click 'Reset' above." - - signal hideDialog + QGCViewDialog { + id: customConfigDialog Fact { id: sys_autostart; name: "SYS_AUTOSTART" } function accept() { sys_autostart.value = 0 - customConfigPanel.hideDialog() + customConfigDialog.hideDialog() + } + + QGCLabel { + anchors.fill: parent + wrapMode: Text.WordWrap + text: "Your vehicle is using a custom airframe configuration. " + + "This configuration can only be modified through the Parameter Editor.\n\n" + + "If you want to Reset your airframe configuration and select a standard configuration, click 'Reset' above." + } + } + } + + Component { + id: applyRestartDialogComponent + + QGCViewDialog { + id: applyRestartDialog + + function accept() { + controller.changeAutostart() + applyRestartDialog.hideDialog() + } + + QGCLabel { + anchors.fill: parent + wrapMode: Text.WordWrap + text: "Clicking Apply will save the changes you have made to your aiframe configuration. " + + "Your vehicle will also be rebooted in order to complete the process. " + + "After your vehicle reboots, you can reconnect it to QGroundControl." } } } @@ -117,7 +139,7 @@ QGCView { anchors.right: parent.right text: "Apply and Restart" - onClicked: { controller.changeAutostart() } + onClicked: panel.showDialog(applyRestartDialogComponent, "Apply and Restart", 50, StandardButton.Apply | StandardButton.Cancel) } Item { diff --git a/src/AutoPilotPlugins/PX4/AirframeComponentController.cc b/src/AutoPilotPlugins/PX4/AirframeComponentController.cc index 2cc1386f495f8e507e68f9e59310695ae2c91bd0..8f96cacfd4446119649abfb45dbcc5d7b3fb4c1e 100644 --- a/src/AutoPilotPlugins/PX4/AirframeComponentController.cc +++ b/src/AutoPilotPlugins/PX4/AirframeComponentController.cc @@ -101,24 +101,26 @@ void AirframeComponentController::changeAutostart(void) return; } + qgcApp()->setOverrideCursor(Qt::WaitCursor); + _autopilot->getParameterFact("SYS_AUTOSTART")->setValue(_autostartId); _autopilot->getParameterFact("SYS_AUTOCONFIG")->setValue(1); - qgcApp()->setOverrideCursor(Qt::WaitCursor); // Wait for the parameters to flow through system qgcApp()->processEvents(QEventLoop::ExcludeUserInputEvents); QGC::SLEEP::sleep(1); qgcApp()->processEvents(QEventLoop::ExcludeUserInputEvents); - // Reboot board and reconnect + // Reboot board _uas->executeCommand(MAV_CMD_PREFLIGHT_REBOOT_SHUTDOWN, 1, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0); qgcApp()->processEvents(QEventLoop::ExcludeUserInputEvents); QGC::SLEEP::sleep(1); qgcApp()->processEvents(QEventLoop::ExcludeUserInputEvents); + LinkManager::instance()->disconnectAll(); - qgcApp()->reconnectAfterWait(5); + qgcApp()->restoreOverrideCursor(); } AirframeType::AirframeType(const QString& name, const QString& imageResource, QObject* parent) : diff --git a/src/QGCApplication.cc b/src/QGCApplication.cc index a3f4b68eef54b84b000f4d35206eac62529e7f27..2850fea9f9ced09684084a23f0671d6e20264d2d 100644 --- a/src/QGCApplication.cc +++ b/src/QGCApplication.cc @@ -655,32 +655,6 @@ void QGCApplication::_loadCurrentStyle(void) restoreOverrideCursor(); } -void QGCApplication::reconnectAfterWait(int waitSeconds) -{ - LinkManager* linkManager = LinkManager::instance(); - Q_ASSERT(linkManager); - - Q_ASSERT(linkManager->getLinks().count() == 1); - LinkInterface* link = linkManager->getLinks()[0]; - - // Save the link configuration so we can restart the link laster - _reconnectLinkConfig = LinkConfiguration::duplicateSettings(linkManager->getLinks()[0]->getLinkConfiguration()); - - // Disconnect and wait - - linkManager->disconnectLink(link); - QTimer::singleShot(waitSeconds * 1000, this, &QGCApplication::_reconnect); -} - -void QGCApplication::_reconnect(void) -{ - Q_ASSERT(_reconnectLinkConfig); - - qgcApp()->restoreOverrideCursor(); - LinkManager::instance()->createConnectedLink(_reconnectLinkConfig); - _reconnectLinkConfig = NULL; -} - void QGCApplication::reportMissingFact(const QString& name) { _missingFacts += name; diff --git a/src/QGCApplication.h b/src/QGCApplication.h index 481f88319ca9f96d126b945595333fee2fbb4d47..44e52c73c09a180beb11055f8a85bc4b4bae47cf 100644 --- a/src/QGCApplication.h +++ b/src/QGCApplication.h @@ -96,9 +96,6 @@ public: /// Set the current UI style void setStyle(bool styleIsDark); - /// Disconnects the current link and waits for the specified number of seconds before reconnecting. - void reconnectAfterWait(int waitSeconds); - /// Used to report a missing Fact. Warning will be displayed to user. Method may be called /// multiple times. void reportMissingFact(const QString& name); @@ -143,7 +140,6 @@ public: static QGCApplication* _app; ///< Our own singleton. Should be reference directly by qgcApp private slots: - void _reconnect(void); void _missingFactsDisplay(void); private: @@ -167,8 +163,6 @@ private: static const char* _lightStyleFile; bool _styleIsDark; ///< true: dark style, false: light style - LinkConfiguration* _reconnectLinkConfig; ///< Configuration to reconnect for reconnectAfterWait - static const int _missingFactDelayedDisplayTimerTimeout = 1000; ///< Timeout to wait for next missing fact to come in before display QTimer _missingFactDelayedDisplayTimer; ///< Timer use to delay missing fact display QStringList _missingFacts; ///< List of missing facts to be displayed