diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc
index 575b191..13c465a 100644
--- a/qgroundcontrol.qrc
+++ b/qgroundcontrol.qrc
@@ -112,40 +112,41 @@
src/ui/flightdisplay/FlightDisplay.qml
src/ui/mapdisplay/MapDisplay.qml
- src/ui/qmlcommon/qmldir
src/ui/qmlcommon/QGCAltitudeWidget.qml
- src/ui/qmlcommon/QGCAttitudeWidget.qml
+ src/ui/qmlcommon/QGCArtificialHorizon.qml
src/ui/qmlcommon/QGCAttitudeInstrument.qml
+ src/ui/qmlcommon/QGCAttitudeWidget.qml
src/ui/qmlcommon/QGCCompass.qml
src/ui/qmlcommon/QGCCompassInstrument.qml
src/ui/qmlcommon/QGCCurrentAltitude.qml
src/ui/qmlcommon/QGCCurrentSpeed.qml
+ src/ui/qmlcommon/QGCHudMessage.qml
src/ui/qmlcommon/QGCMapBackground.qml
+ src/ui/qmlcommon/QGCMapToolButton.qml
src/ui/qmlcommon/QGCPitchWidget.qml
- src/ui/qmlcommon/QGCSpeedWidget.qml
src/ui/qmlcommon/QGCSlider.qml
+ src/ui/qmlcommon/QGCSpeedWidget.qml
src/ui/qmlcommon/QGCWaypointEditor.qml
- src/ui/qmlcommon/QGCMapToolButton.qml
- src/ui/qmlcommon/QGCArtificialHorizon.qml
+ src/ui/qmlcommon/qmldir
src/ui/qmlcommon/QGCWaypoint.qml
+ src/ui/qmlcommon/attitudeDial.svg
+ src/ui/qmlcommon/attitudeInstrument.svg
+ src/ui/qmlcommon/attitudePointer.svg
+ src/ui/qmlcommon/buttonHome.svg
+ src/ui/qmlcommon/buttonLeft.svg
+ src/ui/qmlcommon/buttonMore.svg
+ src/ui/qmlcommon/buttonRight.svg
src/ui/qmlcommon/compass.svg
+ src/ui/qmlcommon/compassInstrumentAirplane.svg
+ src/ui/qmlcommon/compassInstrumentDial.svg
src/ui/qmlcommon/compassNeedle.svg
src/ui/qmlcommon/crossHair.svg
src/ui/qmlcommon/rollDialWhite.svg
src/ui/qmlcommon/rollPointerWhite.svg
src/ui/qmlcommon/scale.png
src/ui/qmlcommon/scale_end.png
- src/ui/qmlcommon/buttonLeft.svg
- src/ui/qmlcommon/buttonRight.svg
- src/ui/qmlcommon/buttonHome.svg
- src/ui/qmlcommon/buttonMore.svg
- src/ui/qmlcommon/attitudeInstrument.svg
- src/ui/qmlcommon/attitudeDial.svg
- src/ui/qmlcommon/attitudePointer.svg
- src/ui/qmlcommon/compassInstrumentAirplane.svg
- src/ui/qmlcommon/compassInstrumentDial.svg
diff --git a/src/QGCApplication.cc b/src/QGCApplication.cc
index 6759af2..ef97e5b 100644
--- a/src/QGCApplication.cc
+++ b/src/QGCApplication.cc
@@ -119,6 +119,7 @@ static QObject* screenToolsSingletonFactory(QQmlEngine*, QJSEngine*)
static QObject* mavManagerSingletonFactory(QQmlEngine*, QJSEngine*)
{
MavManager* mavManager = new MavManager;
+ qgcApp()->setMavManager(mavManager);
return mavManager;
}
@@ -133,10 +134,11 @@ static QObject* mavManagerSingletonFactory(QQmlEngine*, QJSEngine*)
**/
-QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting) :
- QApplication(argc, argv),
- _runningUnitTests(unitTesting),
- _styleIsDark(true)
+QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting)
+ : QApplication(argc, argv)
+ , _runningUnitTests(unitTesting)
+ , _styleIsDark(true)
+ , _pMavManager(NULL)
{
Q_ASSERT(_app == NULL);
_app = this;
@@ -341,7 +343,7 @@ void QGCApplication::_initCommon(void)
//-- Create QML Singleton Interfaces
qmlRegisterSingletonType("QGroundControl.ScreenTools", 1, 0, "ScreenTools", screenToolsSingletonFactory);
qmlRegisterSingletonType("QGroundControl.MavManager", 1, 0, "MavManager", mavManagerSingletonFactory);
-
+
//-- Register Waypoint Interface
qmlRegisterInterface("Waypoint");
}
@@ -709,7 +711,19 @@ void QGCApplication::_missingParamsDisplay(void)
}
_missingParams.clear();
- QGCMessageBox::critical("Missing Parameters",
- QString("Parameters missing from firmware: %1.\n\n"
- "You should quit QGroundControl immediately and update your firmware.").arg(params));
+ QGCMessageBox::critical(
+ "Missing Parameters",
+ QString("Parameters missing from firmware: %1.\n\n"
+ "You should quit QGroundControl immediately and update your firmware.").arg(params));
+}
+
+void QGCApplication::setMavManager(MavManager* pMgr)
+{
+ if(!_pMavManager)
+ _pMavManager = pMgr;
+}
+
+MavManager* QGCApplication::getMavManager()
+{
+ return _pMavManager;
}
diff --git a/src/QGCApplication.h b/src/QGCApplication.h
index 0e86dc6..8b01ce2 100644
--- a/src/QGCApplication.h
+++ b/src/QGCApplication.h
@@ -44,6 +44,7 @@
// Work around circular header includes
class QGCSingleton;
class MainWindow;
+class MavManager;
/**
* @brief The main application and management class.
@@ -99,6 +100,12 @@ public:
/// Used to report a missing Parameter. Warning will be displayed to user. Method may be called
/// multiple times.
void reportMissingParameter(int componentId, const QString& name);
+
+ /// When the singleton is created, it sets a pointer for subsequent use
+ void setMavManager(MavManager* pMgr);
+
+ /// MavManager accessor
+ MavManager* getMavManager();
public slots:
/// You can connect to this slot to show an information message box from a different thread.
@@ -166,7 +173,8 @@ private:
static const int _missingParamsDelayedDisplayTimerTimeout = 1000; ///< Timeout to wait for next missing fact to come in before display
QTimer _missingParamsDelayedDisplayTimer; ///< Timer use to delay missing fact display
QStringList _missingParams; ///< List of missing facts to be displayed
-
+ MavManager* _pMavManager;
+
/// Unit Test have access to creating and destroying singletons
friend class UnitTest;
};
diff --git a/src/QmlControls/MavManager.cc b/src/QmlControls/MavManager.cc
index 5b2ab4e..7c042ca 100644
--- a/src/QmlControls/MavManager.cc
+++ b/src/QmlControls/MavManager.cc
@@ -32,6 +32,7 @@ This file is part of the QGROUNDCONTROL project
#include "UASManager.h"
#include "Waypoint.h"
#include "MavManager.h"
+#include "UASMessageHandler.h"
#define UPDATE_TIMER 50
#define DEFAULT_LAT 38.965767f
@@ -40,6 +41,12 @@ This file is part of the QGROUNDCONTROL project
MavManager::MavManager(QObject *parent)
: QObject(parent)
, _mav(NULL)
+ , _currentMessageCount(0)
+ , _messageCount(0)
+ , _currentErrorCount(0)
+ , _currentWarningCount(0)
+ , _currentNormalCount(0)
+ , _currentMessageType(MessageNone)
, _roll(0.0f)
, _pitch(0.0f)
, _heading(0.0f)
@@ -99,6 +106,8 @@ QString MavManager::loadSetting(const QString &name, const QString& defaultValue
void MavManager::_forgetUAS(UASInterface* uas)
{
if (_mav != NULL && _mav == uas) {
+ // Stop listening for system messages
+ disconnect(UASMessageHandler::instance(), &UASMessageHandler::textMessageCountChanged, this, &MavManager::_handleTextMessage);
// Disconnect any previously connected active MAV
disconnect(_mav, SIGNAL(attitudeChanged (UASInterface*, double,double,double,quint64)), this, SLOT(_updateAttitude(UASInterface*, double, double, double, quint64)));
disconnect(_mav, SIGNAL(attitudeChanged (UASInterface*, int,double,double,double,quint64)), this, SLOT(_updateAttitude(UASInterface*,int,double, double, double, quint64)));
@@ -149,6 +158,8 @@ void MavManager::_setActiveUAS(UASInterface* uas)
emit heartbeatTimeoutChanged();
// Set new UAS
_mav = uas;
+ // Listen for system messages
+ connect(UASMessageHandler::instance(), &UASMessageHandler::textMessageCountChanged, this, &MavManager::_handleTextMessage);
// Now connect the new UAS
connect(_mav, SIGNAL(attitudeChanged (UASInterface*,double,double,double,quint64)), this, SLOT(_updateAttitude(UASInterface*, double, double, double, quint64)));
connect(_mav, SIGNAL(attitudeChanged (UASInterface*,int,double,double,double,quint64)), this, SLOT(_updateAttitude(UASInterface*,int,double, double, double, quint64)));
@@ -637,3 +648,87 @@ void MavManager::_waypointViewOnlyListChanged()
*/
}
}
+
+void MavManager::_handleTextMessage(int newCount)
+{
+ // Reset?
+ if(!newCount) {
+ _currentMessageCount = 0;
+ _currentNormalCount = 0;
+ _currentWarningCount = 0;
+ _currentErrorCount = 0;
+ _messageCount = 0;
+ _currentMessageType = MessageNone;
+ emit newMessageCountChanged();
+ emit messageTypeChanged();
+ emit messageCountChanged();
+ return;
+ }
+
+ UASMessageHandler* pMh = UASMessageHandler::instance();
+ Q_ASSERT(pMh);
+ MessageType_t type = newCount ? _currentMessageType : MessageNone;
+ int errorCount = _currentErrorCount;
+ int warnCount = _currentWarningCount;
+ int normalCount = _currentNormalCount;
+ //-- Add current message counts
+ errorCount += pMh->getErrorCount();
+ warnCount += pMh->getWarningCount();
+ normalCount += pMh->getNormalCount();
+ //-- See if we have a higher level
+ if(errorCount != _currentErrorCount) {
+ _currentErrorCount = errorCount;
+ type = MessageError;
+ }
+ if(warnCount != _currentWarningCount) {
+ _currentWarningCount = warnCount;
+ if(_currentMessageType != MessageError) {
+ type = MessageWarning;
+ }
+ }
+ if(normalCount != _currentNormalCount) {
+ _currentNormalCount = normalCount;
+ if(_currentMessageType != MessageError && _currentMessageType != MessageWarning) {
+ type = MessageNormal;
+ }
+ }
+ int count = _currentErrorCount + _currentWarningCount + _currentNormalCount;
+ if(count != _currentMessageCount) {
+ _currentMessageCount = count;
+ // Display current total new messages count
+ emit newMessageCountChanged();
+ }
+ if(type != _currentMessageType) {
+ _currentMessageType = type;
+ // Update message level
+ emit messageTypeChanged();
+ }
+ // Update message count (all messages)
+ if(newCount != _messageCount) {
+ _messageCount = newCount;
+ emit messageCountChanged();
+ }
+ QString errMsg = pMh->getLatestError();
+ if(errMsg != _latestError) {
+ _latestError = errMsg;
+ emit latestErrorChanged();
+ }
+}
+
+void MavManager::resetMessages()
+{
+ // Reset Counts
+ int count = _currentMessageCount;
+ MessageType_t type = _currentMessageType;
+ _currentErrorCount = 0;
+ _currentWarningCount = 0;
+ _currentNormalCount = 0;
+ _currentMessageCount = 0;
+ _currentMessageType = MessageNone;
+ if(count != _currentMessageCount) {
+ emit newMessageCountChanged();
+ }
+ if(type != _currentMessageType) {
+ emit messageTypeChanged();
+ }
+}
diff --git a/src/QmlControls/MavManager.h b/src/QmlControls/MavManager.h
index 46b329a..87e6e1b 100644
--- a/src/QmlControls/MavManager.h
+++ b/src/QmlControls/MavManager.h
@@ -46,6 +46,13 @@ public:
explicit MavManager(QObject *parent = 0);
~MavManager();
+ typedef enum {
+ MessageNone,
+ MessageNormal,
+ MessageWarning,
+ MessageError
+ } MessageType_t;
+
enum {
ROLL_CHANGED,
PITCH_CHANGED,
@@ -58,10 +65,19 @@ public:
ALTITUDEAMSL_CHANGED
};
+ // Called when the message drop-down is invoked to clear current count
+ void resetMessages();
+
Q_INVOKABLE QString getMavIconColor();
Q_INVOKABLE void saveSetting (const QString &key, const QString& value);
Q_INVOKABLE QString loadSetting (const QString &key, const QString& defaultValue);
+ //-- System Messages
+ Q_PROPERTY(MessageType_t messageType READ messageType NOTIFY messageTypeChanged)
+ Q_PROPERTY(int newMessageCount READ newMessageCount NOTIFY newMessageCountChanged)
+ Q_PROPERTY(int messageCount READ messageCount NOTIFY messageCountChanged)
+ Q_PROPERTY(QString latestError READ latestError NOTIFY latestErrorChanged)
+ //-- UAV Stats
Q_PROPERTY(float roll READ roll NOTIFY rollChanged)
Q_PROPERTY(float pitch READ pitch NOTIFY pitchChanged)
Q_PROPERTY(float heading READ heading NOTIFY headingChanged)
@@ -87,8 +103,13 @@ public:
Q_PROPERTY(double waypointDistance READ waypointDistance NOTIFY waypointDistanceChanged)
Q_PROPERTY(uint16_t currentWaypoint READ currentWaypoint NOTIFY currentWaypointChanged)
Q_PROPERTY(unsigned int heartbeatTimeout READ heartbeatTimeout NOTIFY heartbeatTimeoutChanged)
+ //-- Waypoint management
Q_PROPERTY(QQmlListProperty waypoints READ waypoints NOTIFY waypointsChanged)
+ MessageType_t messageType () { return _currentMessageType; }
+ int newMessageCount () { return _currentMessageCount; }
+ int messageCount () { return _messageCount; }
+ QString latestError () { return _latestError; }
float roll () { return _roll; }
float pitch () { return _pitch; }
float heading () { return _heading; }
@@ -118,6 +139,10 @@ public:
QQmlListProperty waypoints() {return QQmlListProperty(this, _waypoints); }
signals:
+ void messageTypeChanged ();
+ void newMessageCountChanged ();
+ void messageCountChanged ();
+ void latestErrorChanged ();
void rollChanged ();
void pitchChanged ();
void headingChanged ();
@@ -147,6 +172,7 @@ signals:
void waypointsChanged ();
private slots:
+ void _handleTextMessage (int newCount);
/** @brief Attitude from main autopilot / system state */
void _updateAttitude (UASInterface* uas, double roll, double pitch, double yaw, quint64 timestamp);
/** @brief Attitude from one specific component / redundant autopilot */
@@ -182,6 +208,13 @@ private:
private:
UASInterface* _mav;
+ int _currentMessageCount;
+ int _messageCount;
+ int _currentErrorCount;
+ int _currentWarningCount;
+ int _currentNormalCount;
+ MessageType_t _currentMessageType;
+ QString _latestError;
float _roll;
float _pitch;
float _heading;
diff --git a/src/uas/UASMessageHandler.cc b/src/uas/UASMessageHandler.cc
index 0db8041..db2b1be 100644
--- a/src/uas/UASMessageHandler.cc
+++ b/src/uas/UASMessageHandler.cc
@@ -163,6 +163,17 @@ void UASMessageHandler::handleTextMessage(int, int compId, int severity, QString
message->_setFormatedText(QString("[%2 - COMP:%3]%4 %5
").arg(style).arg(dateString).arg(compId).arg(severityText).arg(text));
_messages.append(message);
int count = _messages.count();
+ switch (severity)
+ {
+ case MAV_SEVERITY_EMERGENCY:
+ case MAV_SEVERITY_ALERT:
+ case MAV_SEVERITY_CRITICAL:
+ case MAV_SEVERITY_ERROR:
+ _latestError = severityText + " " + text;
+ break;
+ default:
+ break;
+ }
_mutex.unlock();
emit textMessageReceived(message);
emit textMessageCountChanged(count);
diff --git a/src/uas/UASMessageHandler.h b/src/uas/UASMessageHandler.h
index 616ff3f..da1d2b4 100644
--- a/src/uas/UASMessageHandler.h
+++ b/src/uas/UASMessageHandler.h
@@ -107,6 +107,10 @@ public:
* @brief Get normal message count (Resets count once read)
*/
int getNormalCount();
+ /**
+ * @brief Get latest error message
+ */
+ QString getLatestError() { return _latestError; }
public slots:
/**
* @brief Set currently active UAS
@@ -140,6 +144,7 @@ private:
int _errorCount;
int _warningCount;
int _normalCount;
+ QString _latestError;
};
#endif // QGCMESSAGEHANDLER_H
diff --git a/src/ui/flightdisplay/FlightDisplay.qml b/src/ui/flightdisplay/FlightDisplay.qml
index 074f9a2..59e92af 100644
--- a/src/ui/flightdisplay/FlightDisplay.qml
+++ b/src/ui/flightdisplay/FlightDisplay.qml
@@ -487,6 +487,15 @@ Item {
z: 10
}
+ QGCHudMessage {
+ id: hudMessage
+ y: ScreenTools.pixelSizeFactor * (5)
+ width: (parent.width - 520 > 200) ? parent.width - 520 : 200
+ height: ScreenTools.pixelSizeFactor * (30)
+ anchors.horizontalCenter: parent.horizontalCenter
+ z: mapBackground.z + 1
+ }
+
QGCCompassInstrument {
id: compassInstrument
y: ScreenTools.pixelSizeFactor * (5)
@@ -494,7 +503,7 @@ Item {
size: ScreenTools.pixelSizeFactor * (160)
heading: isNaN(MavManager.heading) ? 0 : MavManager.heading
visible: mapBackground.visible && showCompass
- z: mapBackground.z + 1
+ z: mapBackground.z + 2
onResetRequested: {
y = ScreenTools.pixelSizeFactor * (5)
x = ScreenTools.pixelSizeFactor * (85)
@@ -514,7 +523,7 @@ Item {
visible: mapBackground.visible && showAttitudeIndicator
anchors.right: root.right
anchors.rightMargin: ScreenTools.pixelSizeFactor * (85)
- z: mapBackground.z + 1
+ z: mapBackground.z + 2
onResetRequested: {
y = ScreenTools.pixelSizeFactor * (5)
anchors.right = root.right
@@ -531,7 +540,6 @@ Item {
rollAngle: roll
pitchAngle: pitch
visible: !mapBackground.visible
- z: 10
}
QGCAttitudeWidget {
diff --git a/src/ui/qmlcommon/QGCHudMessage.qml b/src/ui/qmlcommon/QGCHudMessage.qml
new file mode 100644
index 0000000..5b3d396
--- /dev/null
+++ b/src/ui/qmlcommon/QGCHudMessage.qml
@@ -0,0 +1,93 @@
+/*=====================================================================
+
+QGroundControl Open Source Ground Control Station
+
+(c) 2009, 2015 QGROUNDCONTROL PROJECT
+
+This file is part of the QGROUNDCONTROL project
+
+ QGROUNDCONTROL is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ QGROUNDCONTROL is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with QGROUNDCONTROL. If not, see .
+
+======================================================================*/
+
+/**
+ * @file
+ * @brief QGC HUD Message
+ * @author Gus Grubba
+ */
+
+import QtQuick 2.4
+import QtQuick.Controls 1.3
+
+import QGroundControl.Controls 1.0
+import QGroundControl.ScreenTools 1.0
+import QGroundControl.MavManager 1.0
+
+Item {
+ id: root
+ visible: MavManager.latestError !== ''
+ Rectangle {
+ anchors.fill: parent
+ color: Qt.rgba(0,0,0,0.75)
+ border.color: Qt.rgba(1,1,1,0.75)
+ radius: 4
+ QGCLabel {
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.verticalCenter: parent.verticalCenter
+ antialiasing: true
+ font.weight: Font.DemiBold
+ text: MavManager.latestError
+ color: "#f84444"
+ }
+ OpacityAnimator {
+ id: vanish
+ target: root;
+ from: 1;
+ to: 0;
+ duration: 2000
+ running: false
+ }
+ }
+ Timer {
+ id: vanishTimer
+ interval: 30000
+ running: false
+ repeat: false
+ onTriggered: {
+ vanish.start();
+ }
+ }
+ MouseArea {
+ anchors.fill: parent
+ z: 1000
+ acceptedButtons: Qt.LeftButton
+ onClicked: {
+ if (mouse.button == Qt.LeftButton)
+ {
+ vanishTimer.stop();
+ vanish.stop();
+ root.opacity = 0;
+ }
+ }
+ }
+ Connections {
+ target: MavManager
+ onLatestErrorChanged: {
+ vanishTimer.stop();
+ vanish.stop();
+ vanishTimer.start();
+ root.opacity = 1;
+ }
+ }
+}
diff --git a/src/ui/qmlcommon/qmldir b/src/ui/qmlcommon/qmldir
index 389840c..6986e8a 100644
--- a/src/ui/qmlcommon/qmldir
+++ b/src/ui/qmlcommon/qmldir
@@ -15,3 +15,4 @@ QGCAttitudeInstrument 1.0 QGCAttitudeInstrument.qml
QGCCompassInstrument 1.0 QGCCompassInstrument.qml
QGCArtificialHorizon 1.0 QGCArtificialHorizon.qml
QGCWaypoint 1.0 QGCWaypoint.qml
+QGCHudMessage 1.0 QGCHudMessage.qml
diff --git a/src/ui/toolbar/MainToolBar.cc b/src/ui/toolbar/MainToolBar.cc
index d799d8b..7a6b2c6 100644
--- a/src/ui/toolbar/MainToolBar.cc
+++ b/src/ui/toolbar/MainToolBar.cc
@@ -32,9 +32,11 @@ This file is part of the QGROUNDCONTROL project
#include "MainToolBar.h"
#include "MainWindow.h"
-#include "UASMessageHandler.h"
#include "UASMessageView.h"
+#include "UASMessageHandler.h"
#include "FlightDisplay.h"
+#include "QGCApplication.h"
+#include "MavManager.h"
MainToolBar::MainToolBar(QWidget* parent)
: QGCQmlWidgetHolder(parent)
@@ -42,12 +44,6 @@ MainToolBar::MainToolBar(QWidget* parent)
, _toolBar(NULL)
, _currentView(ViewNone)
, _connectionCount(0)
- , _currentMessageCount(0)
- , _messageCount(0)
- , _currentErrorCount(0)
- , _currentWarningCount(0)
- , _currentNormalCount(0)
- , _currentMessageType(MessageNone)
, _showGPS(true)
, _showMav(true)
, _showMessages(true)
@@ -215,20 +211,8 @@ void MainToolBar::onEnterMessageArea(int x, int y)
// If not already there and messages are actually present
if(!_rollDownMessages && UASMessageHandler::instance()->messages().count())
{
- // Reset Counts
- int count = _currentMessageCount;
- MessageType_t type = _currentMessageType;
- _currentErrorCount = 0;
- _currentWarningCount = 0;
- _currentNormalCount = 0;
- _currentMessageCount = 0;
- _currentMessageType = MessageNone;
- if(count != _currentMessageCount) {
- emit newMessageCountChanged(0);
- }
- if(type != _currentMessageType) {
- emit messageTypeChanged(MessageNone);
- }
+ if(qgcApp()->getMavManager())
+ qgcApp()->getMavManager()->resetMessages();
// Show messages
int dialogWidth = 400;
x = x - (dialogWidth >> 1);
@@ -280,7 +264,6 @@ void MainToolBar::setCurrentView(int currentView)
void MainToolBar::_forgetUAS(UASInterface* uas)
{
if (_mav != NULL && _mav == uas) {
- disconnect(UASMessageHandler::instance(), &UASMessageHandler::textMessageCountChanged, this, &MainToolBar::_handleTextMessage);
disconnect(_mav, &UASInterface::remoteControlRSSIChanged, this, &MainToolBar::_remoteControlRSSIChanged);
disconnect(AutoPilotPluginManager::instance()->getInstanceForAutoPilotPlugin(_mav).data(), &AutoPilotPlugin::parameterListProgress, this, &MainToolBar::_setProgressBarValue);
_mav = NULL;
@@ -300,7 +283,6 @@ void MainToolBar::_setActiveUAS(UASInterface* active)
_mav = active;
if (_mav)
{
- connect(UASMessageHandler::instance(), &UASMessageHandler::textMessageCountChanged, this, &MainToolBar::_handleTextMessage);
connect(_mav, &UASInterface::remoteControlRSSIChanged, this, &MainToolBar::_remoteControlRSSIChanged);
connect(AutoPilotPluginManager::instance()->getInstanceForAutoPilotPlugin(_mav).data(), &AutoPilotPlugin::parameterListProgress, this, &MainToolBar::_setProgressBarValue);
}
@@ -401,67 +383,6 @@ void MainToolBar::_updateConnection(LinkInterface *disconnectedLink)
}
}
-void MainToolBar::_handleTextMessage(int newCount)
-{
- // Reset?
- if(!newCount) {
- _currentMessageCount = 0;
- _currentNormalCount = 0;
- _currentWarningCount = 0;
- _currentErrorCount = 0;
- _messageCount = 0;
- _currentMessageType = MessageNone;
- emit newMessageCountChanged(0);
- emit messageTypeChanged(MessageNone);
- emit messageCountChanged(0);
- return;
- }
-
- UASMessageHandler* pMh = UASMessageHandler::instance();
- Q_ASSERT(pMh);
- MessageType_t type = newCount ? _currentMessageType : MessageNone;
- int errorCount = _currentErrorCount;
- int warnCount = _currentWarningCount;
- int normalCount = _currentNormalCount;
- //-- Add current message counts
- errorCount += pMh->getErrorCount();
- warnCount += pMh->getWarningCount();
- normalCount += pMh->getNormalCount();
- //-- See if we have a higher level
- if(errorCount != _currentErrorCount) {
- _currentErrorCount = errorCount;
- type = MessageError;
- }
- if(warnCount != _currentWarningCount) {
- _currentWarningCount = warnCount;
- if(_currentMessageType != MessageError) {
- type = MessageWarning;
- }
- }
- if(normalCount != _currentNormalCount) {
- _currentNormalCount = normalCount;
- if(_currentMessageType != MessageError && _currentMessageType != MessageWarning) {
- type = MessageNormal;
- }
- }
- int count = _currentErrorCount + _currentWarningCount + _currentNormalCount;
- if(count != _currentMessageCount) {
- _currentMessageCount = count;
- // Display current total new messages count
- emit newMessageCountChanged(count);
- }
- if(type != _currentMessageType) {
- _currentMessageType = type;
- // Update message level
- emit messageTypeChanged(type);
- }
- // Update message count (all messages)
- if(newCount != _messageCount) {
- _messageCount = newCount;
- emit messageCountChanged(_messageCount);
- }
-}
-
void MainToolBar::_setProgressBarValue(float value)
{
_progressBarValue = value;
diff --git a/src/ui/toolbar/MainToolBar.h b/src/ui/toolbar/MainToolBar.h
index a9c26c8..0042b08 100644
--- a/src/ui/toolbar/MainToolBar.h
+++ b/src/ui/toolbar/MainToolBar.h
@@ -47,17 +47,7 @@ class MainToolBar : public QGCQmlWidgetHolder
{
Q_OBJECT
Q_ENUMS(ViewType_t)
- Q_ENUMS(MessageType_t)
public:
- MainToolBar(QWidget* parent = NULL);
- ~MainToolBar();
-
- typedef enum {
- MessageNone,
- MessageNormal,
- MessageWarning,
- MessageError
- } MessageType_t;
typedef enum {
ViewNone = -1,
@@ -67,6 +57,9 @@ public:
ViewSetup , // MainWindow::VIEW_SETUP
} ViewType_t;
+ MainToolBar(QWidget* parent = NULL);
+ ~MainToolBar();
+
Q_INVOKABLE void onSetupView();
Q_INVOKABLE void onPlanView();
Q_INVOKABLE void onFlyView();
@@ -78,9 +71,6 @@ public:
Q_PROPERTY(ViewType_t currentView MEMBER _currentView NOTIFY currentViewChanged)
Q_PROPERTY(QStringList configList MEMBER _linkConfigurations NOTIFY configListChanged)
- Q_PROPERTY(MessageType_t messageType MEMBER _currentMessageType NOTIFY messageTypeChanged)
- Q_PROPERTY(int newMessageCount MEMBER _currentMessageCount NOTIFY newMessageCountChanged)
- Q_PROPERTY(int messageCount MEMBER _messageCount NOTIFY messageCountChanged)
Q_PROPERTY(int connectionCount READ connectionCount NOTIFY connectionCountChanged)
Q_PROPERTY(QStringList connectedList MEMBER _connectedList NOTIFY connectedListChanged)
Q_PROPERTY(bool showGPS MEMBER _showGPS NOTIFY showGPSChanged)
@@ -104,9 +94,6 @@ signals:
void connectionCountChanged (int count);
void currentViewChanged ();
void configListChanged ();
- void messageTypeChanged (MessageType_t type);
- void newMessageCountChanged (int count);
- void messageCountChanged (int count);
void connectedListChanged (QStringList connectedList);
void showGPSChanged (bool value);
void showMavChanged (bool value);
@@ -124,7 +111,6 @@ private slots:
void _updateConfigurations ();
void _linkConnected (LinkInterface* link);
void _linkDisconnected (LinkInterface* link);
- void _handleTextMessage (int newCount);
void _leaveMessageView ();
void _setProgressBarValue (float value);
void _updatePixelSize ();
@@ -141,12 +127,6 @@ private:
ViewType_t _currentView;
QStringList _linkConfigurations;
int _connectionCount;
- int _currentMessageCount;
- int _messageCount;
- int _currentErrorCount;
- int _currentWarningCount;
- int _currentNormalCount;
- MessageType_t _currentMessageType;
QStringList _connectedList;
bool _showGPS;
bool _showMav;
diff --git a/src/ui/toolbar/MainToolBar.qml b/src/ui/toolbar/MainToolBar.qml
index ce6f62e..d961a97 100644
--- a/src/ui/toolbar/MainToolBar.qml
+++ b/src/ui/toolbar/MainToolBar.qml
@@ -64,20 +64,20 @@ Rectangle {
}
function getMessageColor() {
- if(mainToolBar.messageType === MainToolBar.MessageNone)
+ if(MavManager.messageType === MavManager.MessageNone)
return qgcPal.button;
- if(mainToolBar.messageType === MainToolBar.MessageNormal)
+ if(MavManager.messageType === MavManager.MessageNormal)
return colorBlue;
- if(mainToolBar.messageType === MainToolBar.MessageWarning)
+ if(MavManager.messageType === MavManager.MessageWarning)
return colorOrange;
- if(mainToolBar.messageType === MainToolBar.MessageError)
+ if(MavManager.messageType === MavManager.MessageError)
return colorRed;
// Cannot be so make make it obnoxious to show error
return "purple";
}
function getMessageIcon() {
- if(mainToolBar.messageType === MainToolBar.MessageNormal || mainToolBar.messageType === MainToolBar.MessageNone)
+ if(MavManager.messageType === MavManager.MessageNormal || MavManager.messageType === MavManager.MessageNone)
return "qrc:/res/Megaphone";
else
return "qrc:/res/Yield";
@@ -311,7 +311,7 @@ Rectangle {
Rectangle {
id: messages
- width: (mainToolBar.messageCount > 99) ? getProportionalDimmension(65) : getProportionalDimmension(60)
+ width: (MavManager.messageCount > 99) ? getProportionalDimmension(65) : getProportionalDimmension(60)
height: cellHeight
visible: (mainToolBar.connectionCount > 0) && (mainToolBar.showMessages)
anchors.verticalCenter: parent.verticalCenter
@@ -337,7 +337,7 @@ Rectangle {
width: messages.width - messageIcon.width
QGCLabel {
id: messageText
- text: (mainToolBar.messageCount > 0) ? mainToolBar.messageCount : ''
+ text: (MavManager.messageCount > 0) ? MavManager.messageCount : ''
font.pointSize: ScreenTools.fontPointFactor * (14);
font.weight: Font.DemiBold
anchors.verticalCenter: parent.verticalCenter
@@ -350,7 +350,7 @@ Rectangle {
Image {
id: dropDown
source: "QGroundControl/Controls/arrow-down.png"
- visible: (messages.showTriangle) && (mainToolBar.messageCount > 0)
+ visible: (messages.showTriangle) && (MavManager.messageCount > 0)
anchors.bottom: parent.bottom
anchors.right: parent.right
anchors.bottomMargin: getProportionalDimmension(3)