Commit 39913696 authored by Gus Grubba's avatar Gus Grubba

Merge pull request #3344 from dogmaphobic/messageWindow

Message window
parents 9b2ce21c cfe2cf55
...@@ -126,8 +126,6 @@ ...@@ -126,8 +126,6 @@
<file alias="MapSyncChanged.svg">src/FlightMap/Images/MapSyncChanged.svg</file> <file alias="MapSyncChanged.svg">src/FlightMap/Images/MapSyncChanged.svg</file>
<file alias="MapType.svg">src/FlightMap/Images/MapType.svg</file> <file alias="MapType.svg">src/FlightMap/Images/MapType.svg</file>
<file alias="MapTypeBlack.svg">src/FlightMap/Images/MapTypeBlack.svg</file> <file alias="MapTypeBlack.svg">src/FlightMap/Images/MapTypeBlack.svg</file>
<file alias="TrashDelete.svg">src/FlightMap/Images/TrashDelete.svg</file>
<file alias="TrashDeleteBlack.svg">src/FlightMap/Images/TrashDeleteBlack.svg</file>
<file alias="Armed.svg">src/ui/toolbar/Images/Armed.svg</file> <file alias="Armed.svg">src/ui/toolbar/Images/Armed.svg</file>
<file alias="Battery.svg">src/ui/toolbar/Images/Battery.svg</file> <file alias="Battery.svg">src/ui/toolbar/Images/Battery.svg</file>
<file alias="Connect.svg">src/ui/toolbar/Images/Connect.svg</file> <file alias="Connect.svg">src/ui/toolbar/Images/Connect.svg</file>
...@@ -174,6 +172,7 @@ ...@@ -174,6 +172,7 @@
<file alias="QGroundControlConnect">resources/QGroundControlConnect.svg</file> <file alias="QGroundControlConnect">resources/QGroundControlConnect.svg</file>
<file alias="SplashScreen">resources/SplashScreen.png</file> <file alias="SplashScreen">resources/SplashScreen.png</file>
<file alias="Stop">resources/Stop.svg</file> <file alias="Stop">resources/Stop.svg</file>
<file alias="TrashDelete.svg">resources/TrashDelete.svg</file>
<file alias="XDelete.svg">resources/XDelete.svg</file> <file alias="XDelete.svg">resources/XDelete.svg</file>
<file alias="XDeleteBlack.svg">resources/XDeleteBlack.svg</file> <file alias="XDeleteBlack.svg">resources/XDeleteBlack.svg</file>
</qresource> </qresource>
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 19.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> <!-- Generator: Adobe Illustrator 19.2.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="-89 46 72 72" enable-background="new -89 46 72 72" xml:space="preserve"> viewBox="-89 46 72 72" enable-background="new -89 46 72 72" xml:space="preserve">
<g> <rect x="-78.911" y="46" fill="#FFFFFF" width="51.822" height="10.66"/>
<path fill="none" d="M-71.309,68.986"/> <path fill="#FFFFFF" d="M-27.089,59.781h-51.822V118h51.822L-27.089,59.781L-27.089,59.781z M-33.927,110.332h-7.17V68.068h7.17
</g> V110.332z M-49.416,110.332h-7.17V68.068h7.17V110.332z M-64.245,110.332h-7.17V68.068h7.17V110.332z"/>
<rect x="-64.709" y="65.8" fill="#FFFFFF" width="23.417" height="4.797"/> </svg>
<path fill="#FFFFFF" d="M-41.291,72.001h-23.417V98.2h23.417L-41.291,72.001L-41.291,72.001z M-44.381,94.749h-3.24V75.731h3.24
V94.749z M-51.38,94.749h-3.24V75.731h3.24V94.749z M-58.081,94.749h-3.24V75.731h3.24V94.749z"/>
</svg>
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 19.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="-89 46 72 72" enable-background="new -89 46 72 72" xml:space="preserve">
<g>
<path fill="none" d="M-71.309,68.986"/>
</g>
<rect x="-64.709" y="65.8" fill="#231F20" width="23.417" height="4.797"/>
<path fill="#231F20" d="M-41.291,72.001h-23.417V98.2h23.417L-41.291,72.001L-41.291,72.001z M-44.381,94.749h-3.24V75.731h3.24
V94.749z M-51.38,94.749h-3.24V75.731h3.24V94.749z M-58.081,94.749h-3.24V75.731h3.24V94.749z"/>
</svg>
...@@ -922,6 +922,11 @@ QString Vehicle::formatedMessages() ...@@ -922,6 +922,11 @@ QString Vehicle::formatedMessages()
return messages; return messages;
} }
void Vehicle::clearMessages()
{
qgcApp()->toolbox()->uasMessageHandler()->clearMessages();
}
void Vehicle::_handletextMessageReceived(UASMessage* message) void Vehicle::_handletextMessageReceived(UASMessage* message)
{ {
if(message) if(message)
......
...@@ -363,6 +363,9 @@ public: ...@@ -363,6 +363,9 @@ public:
/// Reboot vehicle /// Reboot vehicle
Q_INVOKABLE void rebootVehicle(); Q_INVOKABLE void rebootVehicle();
/// Clear Messages
Q_INVOKABLE void clearMessages();
bool guidedModeSupported(void) const; bool guidedModeSupported(void) const;
bool pauseVehicleSupported(void) const; bool pauseVehicleSupported(void) const;
......
...@@ -145,17 +145,17 @@ void UASMessageHandler::handleTextMessage(int, int compId, int severity, QString ...@@ -145,17 +145,17 @@ void UASMessageHandler::handleTextMessage(int, int compId, int severity, QString
case MAV_SEVERITY_ALERT: case MAV_SEVERITY_ALERT:
case MAV_SEVERITY_CRITICAL: case MAV_SEVERITY_CRITICAL:
case MAV_SEVERITY_ERROR: case MAV_SEVERITY_ERROR:
style = QString("color: #f95e5e; font-weight:bold"); style = QString("<#E>");
_errorCount++; _errorCount++;
_errorCountTotal++; _errorCountTotal++;
break; break;
case MAV_SEVERITY_NOTICE: case MAV_SEVERITY_NOTICE:
case MAV_SEVERITY_WARNING: case MAV_SEVERITY_WARNING:
style = QString("color: #f9b55e; font-weight:bold"); style = QString("<#I>");
_warningCount++; _warningCount++;
break; break;
default: default:
style = QString("color: #ffffff; font-weight:bold"); style = QString("<#N>");
_normalCount++; _normalCount++;
break; break;
} }
...@@ -200,7 +200,7 @@ void UASMessageHandler::handleTextMessage(int, int compId, int severity, QString ...@@ -200,7 +200,7 @@ void UASMessageHandler::handleTextMessage(int, int compId, int severity, QString
if (_multiComp) { if (_multiComp) {
compString = QString(" COMP:%1").arg(compId); compString = QString(" COMP:%1").arg(compId);
} }
message->_setFormatedText(QString("<p><font style=\"%1\">[%2%3]%4 %5</font></p>").arg(style).arg(dateString).arg(compString).arg(severityText).arg(text)); message->_setFormatedText(QString("<font style=\"%1\">[%2%3]%4 %5</font><br/>").arg(style).arg(dateString).arg(compString).arg(severityText).arg(text));
if (message->severityIsError()) { if (message->severityIsError()) {
_latestError = severityText + " " + text; _latestError = severityText + " " + text;
......
...@@ -229,9 +229,16 @@ Item { ...@@ -229,9 +229,16 @@ Item {
} }
} }
function formatMessage(message) {
message = message.replace(new RegExp("<#E>", "g"), "color: #f95e5e; font: " + (ScreenTools.defaultFontPointSize.toFixed(0) - 1) + "pt monospace;");
message = message.replace(new RegExp("<#I>", "g"), "color: #f9b55e; font: " + (ScreenTools.defaultFontPointSize.toFixed(0) - 1) + "pt monospace;");
message = message.replace(new RegExp("<#N>", "g"), "color: #ffffff; font: " + (ScreenTools.defaultFontPointSize.toFixed(0) - 1) + "pt monospace;");
return message;
}
onFormatedMessageChanged: { onFormatedMessageChanged: {
if(messageArea.visible) { if(messageArea.visible) {
messageText.append(formatedMessage) messageText.append(formatMessage(formatedMessage))
//-- Hack to scroll down //-- Hack to scroll down
messageFlick.flick(0,-500) messageFlick.flick(0,-500)
} }
...@@ -242,7 +249,7 @@ Item { ...@@ -242,7 +249,7 @@ Item {
currentPopUp.close() currentPopUp.close()
} }
if(QGroundControl.multiVehicleManager.activeVehicleAvailable) { if(QGroundControl.multiVehicleManager.activeVehicleAvailable) {
messageText.text = activeVehicle.formatedMessages messageText.text = formatMessage(activeVehicle.formatedMessages)
//-- Hack to scroll to last message //-- Hack to scroll to last message
for (var i = 0; i < activeVehicle.messageCount; i++) for (var i = 0; i < activeVehicle.messageCount; i++)
messageFlick.flick(0,-5000) messageFlick.flick(0,-5000)
...@@ -342,13 +349,11 @@ Item { ...@@ -342,13 +349,11 @@ Item {
//-- System Message Area //-- System Message Area
Rectangle { Rectangle {
id: messageArea id: messageArea
function close() { function close() {
currentPopUp = null currentPopUp = null
messageText.text = "" messageText.text = ""
messageArea.visible = false messageArea.visible = false
} }
width: mainWindow.width * 0.5 width: mainWindow.width * 0.5
height: mainWindow.height * 0.5 height: mainWindow.height * 0.5
color: Qt.rgba(0,0,0,0.8) color: Qt.rgba(0,0,0,0.8)
...@@ -359,6 +364,13 @@ Item { ...@@ -359,6 +364,13 @@ Item {
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top anchors.top: parent.top
anchors.topMargin: tbHeight + ScreenTools.defaultFontPixelHeight anchors.topMargin: tbHeight + ScreenTools.defaultFontPixelHeight
MouseArea {
// This MouseArea prevents the Map below it from getting Mouse events. Without this
// things like mousewheel will scroll the Flickable and then scroll the map as well.
anchors.fill: parent
preventStealing: true
onWheel: wheel.accepted = true
}
QGCFlickable { QGCFlickable {
id: messageFlick id: messageFlick
anchors.margins: ScreenTools.defaultFontPixelHeight anchors.margins: ScreenTools.defaultFontPixelHeight
...@@ -372,13 +384,11 @@ Item { ...@@ -372,13 +384,11 @@ Item {
readOnly: true readOnly: true
textFormat: TextEdit.RichText textFormat: TextEdit.RichText
color: "white" color: "white"
font.family: ScreenTools.normalFontFamily
font.pointSize: ScreenTools.defaultFontPointSize
} }
} }
//-- Dismiss System Message //-- Dismiss System Message
Image { Image {
anchors.margins: ScreenTools.defaultFontPixelHeight anchors.margins: ScreenTools.defaultFontPixelHeight * 0.5
anchors.top: parent.top anchors.top: parent.top
anchors.right: parent.right anchors.right: parent.right
width: ScreenTools.isTinyScreen ? ScreenTools.defaultFontPixelHeight * 1.5 : ScreenTools.defaultFontPixelHeight width: ScreenTools.isTinyScreen ? ScreenTools.defaultFontPixelHeight * 1.5 : ScreenTools.defaultFontPixelHeight
...@@ -395,7 +405,30 @@ Item { ...@@ -395,7 +405,30 @@ Item {
} }
} }
} }
//-- Clear Messages
Image {
anchors.bottom: parent.bottom
anchors.right: parent.right
anchors.margins: ScreenTools.defaultFontPixelHeight * 0.5
height: ScreenTools.isTinyScreen ? ScreenTools.defaultFontPixelHeight * 1.5 : ScreenTools.defaultFontPixelHeight
width: height
sourceSize.height: height
source: "/res/TrashDelete.svg"
fillMode: Image.PreserveAspectFit
mipmap: true
smooth: true
MouseArea {
anchors.fill: parent
onClicked: {
if(QGroundControl.multiVehicleManager.activeVehicleAvailable) {
activeVehicle.clearMessages();
messageArea.close()
}
}
}
}
} }
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
//-- Critical Message Area //-- Critical Message Area
Rectangle { Rectangle {
...@@ -463,7 +496,7 @@ Item { ...@@ -463,7 +496,7 @@ Item {
//-- Dismiss Critical Message //-- Dismiss Critical Message
QGCColoredImage { QGCColoredImage {
id: criticalClose id: criticalClose
anchors.margins: ScreenTools.defaultFontPixelHeight anchors.margins: ScreenTools.defaultFontPixelHeight * 0.5
anchors.top: parent.top anchors.top: parent.top
anchors.right: parent.right anchors.right: parent.right
width: ScreenTools.isTinyScreen ? ScreenTools.defaultFontPixelHeight * 1.5 : ScreenTools.defaultFontPixelHeight width: ScreenTools.isTinyScreen ? ScreenTools.defaultFontPixelHeight * 1.5 : ScreenTools.defaultFontPixelHeight
...@@ -482,7 +515,7 @@ Item { ...@@ -482,7 +515,7 @@ Item {
//-- More text below indicator //-- More text below indicator
QGCColoredImage { QGCColoredImage {
anchors.margins: ScreenTools.defaultFontPixelHeight anchors.margins: ScreenTools.defaultFontPixelHeight * 0.5
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.right: parent.right anchors.right: parent.right
width: ScreenTools.isTinyScreen ? ScreenTools.defaultFontPixelHeight * 1.5 : ScreenTools.defaultFontPixelHeight width: ScreenTools.isTinyScreen ? ScreenTools.defaultFontPixelHeight * 1.5 : ScreenTools.defaultFontPixelHeight
......
...@@ -87,7 +87,11 @@ void UASMessageViewWidget::handleTextMessage(UASMessage *message) ...@@ -87,7 +87,11 @@ void UASMessageViewWidget::handleTextMessage(UASMessage *message)
// Turn off updates while we're appending content to avoid breaking the autoscroll behavior // Turn off updates while we're appending content to avoid breaking the autoscroll behavior
msgWidget->setUpdatesEnabled(false); msgWidget->setUpdatesEnabled(false);
QScrollBar *scroller = msgWidget->verticalScrollBar(); QScrollBar *scroller = msgWidget->verticalScrollBar();
msgWidget->appendHtml(message->getFormatedText()); QString messages = message->getFormatedText();
messages = messages.replace("<#E>", "color: #f95e5e; font: monospace;");
messages = messages.replace("<#I>", "color: #f9b55e; font: monospace;");
messages = messages.replace("<#N>", "color: #ffffff; font: monospace;");
msgWidget->appendHtml(messages);
// Ensure text area scrolls correctly // Ensure text area scrolls correctly
scroller->setValue(scroller->maximum()); scroller->setValue(scroller->maximum());
msgWidget->setUpdatesEnabled(true); msgWidget->setUpdatesEnabled(true);
......
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