Commit 8ce31541 authored by Don Gagne's avatar Don Gagne

Add reconnectAfterWait API

parent a5341222
......@@ -581,3 +581,26 @@ void QGCApplication::_loadCurrentStyle(void)
// Finally restore the cursor before returning.
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 = linkManager->getLinks()[0]->getLinkConfiguration();
// Disconnect and wait
linkManager->disconnectLink(link);
QTimer::singleShot(waitSeconds * 1000, this, &QGCApplication::_reconnect);
}
void QGCApplication::_reconnect(void)
{
qgcApp()->restoreOverrideCursor();
LinkManager::instance()->createConnectedLink(_reconnectLinkConfig);
}
\ No newline at end of file
......@@ -34,6 +34,8 @@
#include <QApplication>
#include "LinkConfiguration.h"
#ifdef QGC_RTLAB_ENABLED
#include "OpalLink.h"
#endif
......@@ -93,6 +95,9 @@ 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);
public slots:
/// You can connect to this slot to show an information message box from a different thread.
void informationMessageBoxOnMainThread(const QString& title, const QString& msg);
......@@ -132,6 +137,9 @@ public:
static QGCApplication* _app; ///< Our own singleton. Should be reference directly by qgcApp
private slots:
void _reconnect(void);
private:
void _createSingletons(void);
void _destroySingletons(void);
......@@ -153,6 +161,8 @@ private:
static const char* _lightStyleFile;
bool _styleIsDark; ///< true: dark style, false: light style
LinkConfiguration* _reconnectLinkConfig; ///< Configuration to reconnect for reconnectAfterWai
/// Unit Test have access to creating and destroying singletons
friend class UnitTest;
};
......
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