Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
8ce31541
Commit
8ce31541
authored
Mar 31, 2015
by
Don Gagne
Browse files
Add reconnectAfterWait API
parent
a5341222
Changes
2
Show whitespace changes
Inline
Side-by-side
src/QGCApplication.cc
View file @
8ce31541
...
...
@@ -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
src/QGCApplication.h
View file @
8ce31541
...
...
@@ -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
;
};
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment