Browse Source

Add showErrorsInToolBar support

QGC4.4
Don Gagne 10 years ago
parent
commit
36d52d10e1
  1. 5
      src/uas/UASMessageHandler.cc
  2. 18
      src/uas/UASMessageHandler.h

5
src/uas/UASMessageHandler.cc

@ -60,6 +60,7 @@ UASMessageHandler::UASMessageHandler(QObject *parent) @@ -60,6 +60,7 @@ UASMessageHandler::UASMessageHandler(QObject *parent)
, _errorCountTotal(0)
, _warningCount(0)
, _normalCount(0)
, _showErrorsInToolbar(false)
{
connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), this, SLOT(setActiveUAS(UASInterface*)));
emit textMessageReceived(NULL);
@ -184,6 +185,10 @@ void UASMessageHandler::handleTextMessage(int, int compId, int severity, QString @@ -184,6 +185,10 @@ void UASMessageHandler::handleTextMessage(int, int compId, int severity, QString
_mutex.unlock();
emit textMessageReceived(message);
emit textMessageCountChanged(count);
if (_showErrorsInToolbar && message->severityIsError()) {
qgcApp()->showToolBarMessage(message->getText());
}
}
int UASMessageHandler::getErrorCountTotal() {

18
src/uas/UASMessageHandler.h

@ -81,6 +81,7 @@ class UASMessageHandler : public QGCSingleton @@ -81,6 +81,7 @@ class UASMessageHandler : public QGCSingleton
{
Q_OBJECT
DECLARE_QGC_SINGLETON(UASMessageHandler, UASMessageHandler)
public:
explicit UASMessageHandler(QObject *parent = 0);
~UASMessageHandler();
@ -120,6 +121,10 @@ public: @@ -120,6 +121,10 @@ public:
* @brief Get latest error message
*/
QString getLatestError() { return _latestError; }
/// Begin to show message which are errors in the toolbar
void showErrorsInToolbar(void) { _showErrorsInToolbar = true; }
public slots:
/**
* @brief Set currently active UAS
@ -134,6 +139,7 @@ public slots: @@ -134,6 +139,7 @@ public slots:
* @param text Message Text
*/
void handleTextMessage(int uasid, int componentid, int severity, QString text);
signals:
/**
* @brief Sent out when new message arrives
@ -145,16 +151,18 @@ signals: @@ -145,16 +151,18 @@ signals:
* @param count The new message count
*/
void textMessageCountChanged(int count);
private:
// Stores the UAS that we're currently receiving messages from.
UASInterface* _activeUAS;
QVector<UASMessage*> _messages;
QMutex _mutex;
int _errorCount;
int _errorCountTotal;
int _warningCount;
int _normalCount;
QMutex _mutex;
int _errorCount;
int _errorCountTotal;
int _warningCount;
int _normalCount;
QString _latestError;
bool _showErrorsInToolbar;
};
#endif // QGCMESSAGEHANDLER_H

Loading…
Cancel
Save