Commit 36d52d10 authored by Don Gagne's avatar Don Gagne

Add showErrorsInToolBar support

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