Browse Source

New user model for critical vehicle messages

* Popup smaller
* Text indicates these are Vehicle Messages
* If there are additional messages which come in after display closing the popup will dropdown the Message Indicator in the toolbar
QGC4.4
Don Gagne 2 years ago committed by Philipp Borgers
parent
commit
2270c2a37e
  1. 129
      src/ui/MainRootWindow.qml
  2. 6
      src/ui/toolbar/MainToolBar.qml
  3. 15
      src/ui/toolbar/MainToolBarIndicators.qml
  4. 8
      src/ui/toolbar/MessageIndicator.qml

129
src/ui/MainRootWindow.qml

@ -506,15 +506,15 @@ ApplicationWindow {
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
//-- Critical Vehicle Message Popup //-- Critical Vehicle Message Popup
property var _vehicleMessageQueue: []
property string _vehicleMessage: ""
function showCriticalVehicleMessage(message) { function showCriticalVehicleMessage(message) {
indicatorPopup.close() indicatorPopup.close()
if (criticalVehicleMessagePopup.visible || QGroundControl.videoManager.fullScreen) { if (criticalVehicleMessagePopup.visible || QGroundControl.videoManager.fullScreen) {
_vehicleMessageQueue.push(message) // We received additional wanring message while an older warning message was still displayed.
// When the user close the older one drop the message indicator tool so they can see the rest of them.
criticalVehicleMessagePopup.dropMessageIndicatorOnClose = true
} else { } else {
_vehicleMessage = message criticalVehicleMessagePopup.criticalVehicleMessage = message
criticalVehicleMessagePopup.dropMessageIndicatorOnClose = false
criticalVehicleMessagePopup.open() criticalVehicleMessagePopup.open()
} }
} }
@ -524,100 +524,85 @@ ApplicationWindow {
y: ScreenTools.defaultFontPixelHeight y: ScreenTools.defaultFontPixelHeight
x: Math.round((mainWindow.width - width) * 0.5) x: Math.round((mainWindow.width - width) * 0.5)
width: mainWindow.width * 0.55 width: mainWindow.width * 0.55
height: ScreenTools.defaultFontPixelHeight * 6 height: criticalVehicleMessageText.contentHeight + ScreenTools.defaultFontPixelHeight * 2
modal: false modal: false
focus: true focus: true
closePolicy: Popup.CloseOnEscape closePolicy: Popup.CloseOnEscape
property alias criticalVehicleMessage: criticalVehicleMessageText.text
property bool dropMessageIndicatorOnClose: false
background: Rectangle { background: Rectangle {
anchors.fill: parent anchors.fill: parent
color: qgcPal.alertBackground color: qgcPal.alertBackground
radius: ScreenTools.defaultFontPixelHeight * 0.5 radius: ScreenTools.defaultFontPixelHeight * 0.5
border.color: qgcPal.alertBorder border.color: qgcPal.alertBorder
border.width: 2 border.width: 2
}
onOpened: { Rectangle {
criticalVehicleMessageText.text = mainWindow._vehicleMessage anchors.horizontalCenter: parent.horizontalCenter
} anchors.top: parent.top
anchors.topMargin: -(height / 2)
color: qgcPal.alertBackground
radius: ScreenTools.defaultFontPixelHeight * 0.25
border.color: qgcPal.alertBorder
border.width: 1
width: vehicleWarningLabel.contentWidth + _margins
height: vehicleWarningLabel.contentHeight + _margins
onClosed: { property real _margins: ScreenTools.defaultFontPixelHeight * 0.25
//-- Are there messages in the waiting queue?
if(mainWindow._vehicleMessageQueue.length) {
mainWindow._vehicleMessage = ""
//-- Show all messages in queue
for (var i = 0; i < mainWindow._vehicleMessageQueue.length; i++) {
var text = mainWindow._vehicleMessageQueue[i]
if(i) mainWindow._vehicleMessage += "<br>"
mainWindow._vehicleMessage += text
}
//-- Clear it
mainWindow._vehicleMessageQueue = []
criticalVehicleMessagePopup.open()
} else {
mainWindow._vehicleMessage = ""
}
}
Flickable { QGCLabel {
id: criticalVehicleMessageFlick id: vehicleWarningLabel
anchors.margins: ScreenTools.defaultFontPixelHeight * 0.5
anchors.fill: parent
contentHeight: criticalVehicleMessageText.height
contentWidth: criticalVehicleMessageText.width
boundsBehavior: Flickable.StopAtBounds
pixelAligned: true
clip: true
TextEdit {
id: criticalVehicleMessageText
width: criticalVehicleMessagePopup.width - criticalVehicleMessageClose.width - (ScreenTools.defaultFontPixelHeight * 2)
anchors.centerIn: parent anchors.centerIn: parent
readOnly: true text: qsTr("Vehicle Error")
textFormat: TextEdit.RichText font.pointSize: ScreenTools.smallFontPointSize
font.pointSize: ScreenTools.defaultFontPointSize
font.family: ScreenTools.demiboldFontFamily
wrapMode: TextEdit.WordWrap
color: qgcPal.alertText color: qgcPal.alertText
} }
} }
//-- Dismiss Vehicle Message Rectangle {
QGCColoredImage { id: additionalErrorsIndicator
id: criticalVehicleMessageClose anchors.horizontalCenter: parent.horizontalCenter
anchors.margins: ScreenTools.defaultFontPixelHeight * 0.5 anchors.bottom: parent.bottom
anchors.top: parent.top anchors.bottomMargin: -(height / 2)
anchors.right: parent.right color: qgcPal.alertBackground
width: ScreenTools.isMobile ? ScreenTools.defaultFontPixelHeight * 1.5 : ScreenTools.defaultFontPixelHeight radius: ScreenTools.defaultFontPixelHeight * 0.25
height: width border.color: qgcPal.alertBorder
sourceSize.height: width border.width: 1
source: "/res/XDelete.svg" width: additionalErrorsLabel.contentWidth + _margins
fillMode: Image.PreserveAspectFit height: additionalErrorsLabel.contentHeight + _margins
visible: criticalVehicleMessagePopup.dropMessageIndicatorOnClose
property real _margins: ScreenTools.defaultFontPixelHeight * 0.25
QGCLabel {
id: additionalErrorsLabel
anchors.centerIn: parent
text: qsTr("Additional errors received")
font.pointSize: ScreenTools.smallFontPointSize
color: qgcPal.alertText color: qgcPal.alertText
MouseArea {
anchors.fill: parent
anchors.margins: -ScreenTools.defaultFontPixelHeight
onClicked: {
criticalVehicleMessagePopup.close()
} }
} }
} }
//-- More text below indicator QGCLabel {
QGCColoredImage { id: criticalVehicleMessageText
anchors.margins: ScreenTools.defaultFontPixelHeight * 0.5 width: criticalVehicleMessagePopup.width - ScreenTools.defaultFontPixelHeight
anchors.bottom: parent.bottom anchors.centerIn: parent
anchors.right: parent.right wrapMode: Text.WordWrap
width: ScreenTools.isMobile ? ScreenTools.defaultFontPixelHeight * 1.5 : ScreenTools.defaultFontPixelHeight
height: width
sourceSize.height: width
source: "/res/ArrowDown.svg"
fillMode: Image.PreserveAspectFit
visible: criticalVehicleMessageText.lineCount > 5
color: qgcPal.alertText color: qgcPal.alertText
}
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
onClicked: { onClicked: {
criticalVehicleMessageFlick.flick(0,-500) criticalVehicleMessagePopup.close()
console.log("Clicked", criticalVehicleMessagePopup.dropMessageIndicatorOnClose);
if (criticalVehicleMessagePopup.dropMessageIndicatorOnClose) {
criticalVehicleMessagePopup.dropMessageIndicatorOnClose = false;
QGroundControl.multiVehicleManager.activeVehicle.resetErrorLevelMessages();
toolbar.dropMessageIndicatorTool();
} }
} }
} }

6
src/ui/toolbar/MainToolBar.qml

@ -33,6 +33,12 @@ Rectangle {
property bool _communicationLost: _activeVehicle ? _activeVehicle.vehicleLinkManager.communicationLost : false property bool _communicationLost: _activeVehicle ? _activeVehicle.vehicleLinkManager.communicationLost : false
property color _mainStatusBGColor: qgcPal.brandingPurple property color _mainStatusBGColor: qgcPal.brandingPurple
function dropMessageIndicatorTool() {
if (currentToolbar === flyViewToolbar) {
indicatorLoader.item.dropMessageIndicatorTool();
}
}
QGCPalette { id: qgcPal } QGCPalette { id: qgcPal }
/// Bottom single pixel divider /// Bottom single pixel divider

15
src/ui/toolbar/MainToolBarIndicators.qml

@ -24,6 +24,10 @@ Row {
property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
property real _toolIndicatorMargins: ScreenTools.defaultFontPixelHeight * 0.66 property real _toolIndicatorMargins: ScreenTools.defaultFontPixelHeight * 0.66
function dropMessageIndicatorTool() {
toolIndicatorsRepeater.dropMessageIndicatorTool();
}
Repeater { Repeater {
id: appRepeater id: appRepeater
model: QGroundControl.corePlugin.toolBarIndicators model: QGroundControl.corePlugin.toolBarIndicators
@ -36,7 +40,18 @@ Row {
} }
Repeater { Repeater {
id: toolIndicatorsRepeater
model: _activeVehicle ? _activeVehicle.toolIndicators : [] model: _activeVehicle ? _activeVehicle.toolIndicators : []
function dropMessageIndicatorTool() {
for (var i=0; i<count; i++) {
var thisTool = itemAt(i);
if (thisTool.item.dropMessageIndicator) {
thisTool.item.dropMessageIndicator();
}
}
}
Loader { Loader {
anchors.top: parent.top anchors.top: parent.top
anchors.bottom: parent.bottom anchors.bottom: parent.bottom

8
src/ui/toolbar/MessageIndicator.qml

@ -31,6 +31,10 @@ Item {
property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
property bool _isMessageImportant: _activeVehicle ? !_activeVehicle.messageTypeNormal && !_activeVehicle.messageTypeNone : false property bool _isMessageImportant: _activeVehicle ? !_activeVehicle.messageTypeNormal && !_activeVehicle.messageTypeNone : false
function dropMessageIndicator() {
mainWindow.showIndicatorPopup(_root, vehicleMessagesPopup);
}
function getMessageColor() { function getMessageColor() {
if (_activeVehicle) { if (_activeVehicle) {
if (_activeVehicle.messageTypeNone) if (_activeVehicle.messageTypeNone)
@ -70,7 +74,7 @@ Item {
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
onClicked: mainWindow.showIndicatorPopup(_root, vehicleMessagesPopup) onClicked: dropMessageIndicator()
} }
Component { Component {
@ -95,7 +99,7 @@ Item {
//-- 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)
_activeVehicle.resetMessages() _activeVehicle.resetAllMessages()
} }
Connections { Connections {

Loading…
Cancel
Save