From cfe2cf55b473e199801eb8b06a74508560e3556a Mon Sep 17 00:00:00 2001 From: dogmaphobic Date: Fri, 6 May 2016 16:17:57 -0400 Subject: [PATCH] Message Window Cleanup --- qgcresources.qrc | 3 +- resources/TrashDelete.svg | 8 +++++ src/FlightMap/Images/TrashDelete.svg | 11 ------- src/FlightMap/Images/TrashDeleteBlack.svg | 11 ------- src/Vehicle/Vehicle.cc | 5 +++ src/Vehicle/Vehicle.h | 3 ++ src/ui/MainWindowInner.qml | 38 ++++++++++++++++++++--- src/ui/uas/UASMessageView.cc | 6 +++- 8 files changed, 55 insertions(+), 30 deletions(-) create mode 100644 resources/TrashDelete.svg delete mode 100644 src/FlightMap/Images/TrashDelete.svg delete mode 100644 src/FlightMap/Images/TrashDeleteBlack.svg diff --git a/qgcresources.qrc b/qgcresources.qrc index 36f728b9b..3dba5b619 100644 --- a/qgcresources.qrc +++ b/qgcresources.qrc @@ -126,8 +126,6 @@ src/FlightMap/Images/MapSyncChanged.svg src/FlightMap/Images/MapType.svg src/FlightMap/Images/MapTypeBlack.svg - src/FlightMap/Images/TrashDelete.svg - src/FlightMap/Images/TrashDeleteBlack.svg src/ui/toolbar/Images/Armed.svg src/ui/toolbar/Images/Battery.svg src/ui/toolbar/Images/Connect.svg @@ -174,6 +172,7 @@ resources/QGroundControlConnect.svg resources/SplashScreen.png resources/Stop.svg + resources/TrashDelete.svg resources/XDelete.svg resources/XDeleteBlack.svg diff --git a/resources/TrashDelete.svg b/resources/TrashDelete.svg new file mode 100644 index 000000000..cb4c5a3d7 --- /dev/null +++ b/resources/TrashDelete.svg @@ -0,0 +1,8 @@ + + + + + + diff --git a/src/FlightMap/Images/TrashDelete.svg b/src/FlightMap/Images/TrashDelete.svg deleted file mode 100644 index 1b0826ba0..000000000 --- a/src/FlightMap/Images/TrashDelete.svg +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - diff --git a/src/FlightMap/Images/TrashDeleteBlack.svg b/src/FlightMap/Images/TrashDeleteBlack.svg deleted file mode 100644 index 17effa145..000000000 --- a/src/FlightMap/Images/TrashDeleteBlack.svg +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - diff --git a/src/Vehicle/Vehicle.cc b/src/Vehicle/Vehicle.cc index 30d5f7423..858a140ef 100644 --- a/src/Vehicle/Vehicle.cc +++ b/src/Vehicle/Vehicle.cc @@ -922,6 +922,11 @@ QString Vehicle::formatedMessages() return messages; } +void Vehicle::clearMessages() +{ + qgcApp()->toolbox()->uasMessageHandler()->clearMessages(); +} + void Vehicle::_handletextMessageReceived(UASMessage* message) { if(message) diff --git a/src/Vehicle/Vehicle.h b/src/Vehicle/Vehicle.h index 2f82e2498..d35c69e63 100644 --- a/src/Vehicle/Vehicle.h +++ b/src/Vehicle/Vehicle.h @@ -363,6 +363,9 @@ public: /// Reboot vehicle Q_INVOKABLE void rebootVehicle(); + /// Clear Messages + Q_INVOKABLE void clearMessages(); + bool guidedModeSupported(void) const; bool pauseVehicleSupported(void) const; diff --git a/src/ui/MainWindowInner.qml b/src/ui/MainWindowInner.qml index b3bcb769c..dd646c8fa 100644 --- a/src/ui/MainWindowInner.qml +++ b/src/ui/MainWindowInner.qml @@ -349,13 +349,11 @@ Item { //-- System Message Area Rectangle { id: messageArea - function close() { currentPopUp = null messageText.text = "" messageArea.visible = false } - width: mainWindow.width * 0.5 height: mainWindow.height * 0.5 color: Qt.rgba(0,0,0,0.8) @@ -366,6 +364,13 @@ Item { anchors.horizontalCenter: parent.horizontalCenter anchors.top: parent.top 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 { id: messageFlick anchors.margins: ScreenTools.defaultFontPixelHeight @@ -383,7 +388,7 @@ Item { } //-- Dismiss System Message Image { - //anchors.margins: ScreenTools.defaultFontPixelHeight + anchors.margins: ScreenTools.defaultFontPixelHeight * 0.5 anchors.top: parent.top anchors.right: parent.right width: ScreenTools.isTinyScreen ? ScreenTools.defaultFontPixelHeight * 1.5 : ScreenTools.defaultFontPixelHeight @@ -400,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 Rectangle { @@ -468,7 +496,7 @@ Item { //-- Dismiss Critical Message QGCColoredImage { id: criticalClose - anchors.margins: ScreenTools.defaultFontPixelHeight + anchors.margins: ScreenTools.defaultFontPixelHeight * 0.5 anchors.top: parent.top anchors.right: parent.right width: ScreenTools.isTinyScreen ? ScreenTools.defaultFontPixelHeight * 1.5 : ScreenTools.defaultFontPixelHeight @@ -487,7 +515,7 @@ Item { //-- More text below indicator QGCColoredImage { - anchors.margins: ScreenTools.defaultFontPixelHeight + anchors.margins: ScreenTools.defaultFontPixelHeight * 0.5 anchors.bottom: parent.bottom anchors.right: parent.right width: ScreenTools.isTinyScreen ? ScreenTools.defaultFontPixelHeight * 1.5 : ScreenTools.defaultFontPixelHeight diff --git a/src/ui/uas/UASMessageView.cc b/src/ui/uas/UASMessageView.cc index 763f6da90..72c2fee1a 100644 --- a/src/ui/uas/UASMessageView.cc +++ b/src/ui/uas/UASMessageView.cc @@ -87,7 +87,11 @@ void UASMessageViewWidget::handleTextMessage(UASMessage *message) // Turn off updates while we're appending content to avoid breaking the autoscroll behavior msgWidget->setUpdatesEnabled(false); 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 scroller->setValue(scroller->maximum()); msgWidget->setUpdatesEnabled(true); -- 2.22.0