Commit 1b324cff authored by dogmaphobic's avatar dogmaphobic

Added latest error message to Main Flight Display

parent d70464d8
......@@ -112,40 +112,41 @@
<file alias="FlightDisplay.qml">src/ui/flightdisplay/FlightDisplay.qml</file>
<file alias="MapDisplay.qml">src/ui/mapdisplay/MapDisplay.qml</file>
<!-- QML Main UI Components -->
<file alias="QGroundControl/FlightControls/qmldir">src/ui/qmlcommon/qmldir</file>
<file alias="QGroundControl/FlightControls/QGCAltitudeWidget.qml">src/ui/qmlcommon/QGCAltitudeWidget.qml</file>
<file alias="QGroundControl/FlightControls/QGCAttitudeWidget.qml">src/ui/qmlcommon/QGCAttitudeWidget.qml</file>
<file alias="QGroundControl/FlightControls/QGCArtificialHorizon.qml">src/ui/qmlcommon/QGCArtificialHorizon.qml</file>
<file alias="QGroundControl/FlightControls/QGCAttitudeInstrument.qml">src/ui/qmlcommon/QGCAttitudeInstrument.qml</file>
<file alias="QGroundControl/FlightControls/QGCAttitudeWidget.qml">src/ui/qmlcommon/QGCAttitudeWidget.qml</file>
<file alias="QGroundControl/FlightControls/QGCCompass.qml">src/ui/qmlcommon/QGCCompass.qml</file>
<file alias="QGroundControl/FlightControls/QGCCompassInstrument.qml">src/ui/qmlcommon/QGCCompassInstrument.qml</file>
<file alias="QGroundControl/FlightControls/QGCCurrentAltitude.qml">src/ui/qmlcommon/QGCCurrentAltitude.qml</file>
<file alias="QGroundControl/FlightControls/QGCCurrentSpeed.qml">src/ui/qmlcommon/QGCCurrentSpeed.qml</file>
<file alias="QGroundControl/FlightControls/QGCHudMessage.qml">src/ui/qmlcommon/QGCHudMessage.qml</file>
<file alias="QGroundControl/FlightControls/QGCMapBackground.qml">src/ui/qmlcommon/QGCMapBackground.qml</file>
<file alias="QGroundControl/FlightControls/QGCMapToolButton.qml">src/ui/qmlcommon/QGCMapToolButton.qml</file>
<file alias="QGroundControl/FlightControls/QGCPitchWidget.qml">src/ui/qmlcommon/QGCPitchWidget.qml</file>
<file alias="QGroundControl/FlightControls/QGCSpeedWidget.qml">src/ui/qmlcommon/QGCSpeedWidget.qml</file>
<file alias="QGroundControl/FlightControls/QGCSlider.qml">src/ui/qmlcommon/QGCSlider.qml</file>
<file alias="QGroundControl/FlightControls/QGCSpeedWidget.qml">src/ui/qmlcommon/QGCSpeedWidget.qml</file>
<file alias="QGroundControl/FlightControls/QGCWaypointEditor.qml">src/ui/qmlcommon/QGCWaypointEditor.qml</file>
<file alias="QGroundControl/FlightControls/QGCMapToolButton.qml">src/ui/qmlcommon/QGCMapToolButton.qml</file>
<file alias="QGroundControl/FlightControls/QGCArtificialHorizon.qml">src/ui/qmlcommon/QGCArtificialHorizon.qml</file>
<file alias="QGroundControl/FlightControls/qmldir">src/ui/qmlcommon/qmldir</file>
<!-- QML Map Resources -->
<file alias="QGroundControl/FlightControls/QGCWaypoint.qml">src/ui/qmlcommon/QGCWaypoint.qml</file>
<!-- QML Main UI Resources -->
<file alias="attitudeDial.svg">src/ui/qmlcommon/attitudeDial.svg</file>
<file alias="attitudeInstrument.svg">src/ui/qmlcommon/attitudeInstrument.svg</file>
<file alias="attitudePointer.svg">src/ui/qmlcommon/attitudePointer.svg</file>
<file alias="buttonHome.svg">src/ui/qmlcommon/buttonHome.svg</file>
<file alias="buttonLeft.svg">src/ui/qmlcommon/buttonLeft.svg</file>
<file alias="buttonMore.svg">src/ui/qmlcommon/buttonMore.svg</file>
<file alias="buttonRight.svg">src/ui/qmlcommon/buttonRight.svg</file>
<file alias="compass.svg">src/ui/qmlcommon/compass.svg</file>
<file alias="compassInstrumentAirplane.svg">src/ui/qmlcommon/compassInstrumentAirplane.svg</file>
<file alias="compassInstrumentDial.svg">src/ui/qmlcommon/compassInstrumentDial.svg</file>
<file alias="compassNeedle.svg">src/ui/qmlcommon/compassNeedle.svg</file>
<file alias="crossHair.svg">src/ui/qmlcommon/crossHair.svg</file>
<file alias="rollDialWhite.svg">src/ui/qmlcommon/rollDialWhite.svg</file>
<file alias="rollPointerWhite.svg">src/ui/qmlcommon/rollPointerWhite.svg</file>
<file alias="scale.png">src/ui/qmlcommon/scale.png</file>
<file alias="scale_end.png">src/ui/qmlcommon/scale_end.png</file>
<file alias="buttonLeft.svg">src/ui/qmlcommon/buttonLeft.svg</file>
<file alias="buttonRight.svg">src/ui/qmlcommon/buttonRight.svg</file>
<file alias="buttonHome.svg">src/ui/qmlcommon/buttonHome.svg</file>
<file alias="buttonMore.svg">src/ui/qmlcommon/buttonMore.svg</file>
<file alias="attitudeInstrument.svg">src/ui/qmlcommon/attitudeInstrument.svg</file>
<file alias="attitudeDial.svg">src/ui/qmlcommon/attitudeDial.svg</file>
<file alias="attitudePointer.svg">src/ui/qmlcommon/attitudePointer.svg</file>
<file alias="compassInstrumentAirplane.svg">src/ui/qmlcommon/compassInstrumentAirplane.svg</file>
<file alias="compassInstrumentDial.svg">src/ui/qmlcommon/compassInstrumentDial.svg</file>
</qresource>
<qresource prefix="/AutoPilotPlugins/PX4">
......
......@@ -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<ScreenTools>("QGroundControl.ScreenTools", 1, 0, "ScreenTools", screenToolsSingletonFactory);
qmlRegisterSingletonType<MavManager>("QGroundControl.MavManager", 1, 0, "MavManager", mavManagerSingletonFactory);
//-- Register Waypoint Interface
qmlRegisterInterface<Waypoint>("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;
}
......@@ -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;
};
......
......@@ -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();
}
}
......@@ -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<Waypoint> 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<Waypoint> waypoints() {return QQmlListProperty<Waypoint>(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;
......
......@@ -163,6 +163,17 @@ void UASMessageHandler::handleTextMessage(int, int compId, int severity, QString
message->_setFormatedText(QString("<p style=\"color:#CCCCCC\">[%2 - COMP:%3]<font style=\"%1\">%4 %5</font></p>").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);
......
......@@ -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
......@@ -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 {
......
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
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 <http://www.gnu.org/licenses/>.
======================================================================*/
/**
* @file
* @brief QGC HUD Message
* @author Gus Grubba <mavlink@grubba.com>
*/
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;
}
}
}
......@@ -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
......@@ -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;
......
......@@ -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;
......
......@@ -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)
......
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