Commit 5e9fb55d authored by Gus Grubba's avatar Gus Grubba

Merge pull request #2364 from dogmaphobic/messageBox

Message box
parents c990e079 16dc79fc
...@@ -103,6 +103,7 @@ ...@@ -103,6 +103,7 @@
<qresource prefix="/res"> <qresource prefix="/res">
<file alias="AntennaRC">resources/Antenna_RC.svg</file> <file alias="AntennaRC">resources/Antenna_RC.svg</file>
<file alias="AntennaT">resources/Antenna_T.svg</file> <file alias="AntennaT">resources/Antenna_T.svg</file>
<file alias="ArrowDown.svg">resources/ArrowDown.svg</file>
<file alias="buttonLeft.svg">resources/buttonLeft.svg</file> <file alias="buttonLeft.svg">resources/buttonLeft.svg</file>
<file alias="buttonRight.svg">resources/buttonRight.svg</file> <file alias="buttonRight.svg">resources/buttonRight.svg</file>
<file alias="JoystickBezel.png">resources/JoystickBezel.png</file> <file alias="JoystickBezel.png">resources/JoystickBezel.png</file>
......
<?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="0 0 72 72" style="enable-background:new 0 0 72 72;" xml:space="preserve">
<style type="text/css">
.st0{fill:none;stroke:#FFFFFF;stroke-width:14.3358;stroke-miterlimit:10;}
.st1{fill:#FFFFFF;}
</style>
<g>
<g>
<line class="st0" x1="36" y1="37.4" x2="35.8" y2="8.9"/>
<g>
<polygon class="st1" points="53.8,32 36.2,63.1 18.1,32.3 "/>
</g>
</g>
</g>
</svg>
...@@ -39,7 +39,7 @@ MapQuickItem { ...@@ -39,7 +39,7 @@ MapQuickItem {
anchorPoint.x: vehicleIcon.width / 2 anchorPoint.x: vehicleIcon.width / 2
anchorPoint.y: vehicleIcon.height / 2 anchorPoint.y: vehicleIcon.height / 2
visible: vehicle.coordinateValid visible: vehicle && vehicle.coordinateValid
sourceItem: Image { sourceItem: Image {
id: vehicleIcon id: vehicleIcon
...@@ -51,7 +51,7 @@ MapQuickItem { ...@@ -51,7 +51,7 @@ MapQuickItem {
transform: Rotation { transform: Rotation {
origin.x: vehicleIcon.width / 2 origin.x: vehicleIcon.width / 2
origin.y: vehicleIcon.height / 2 origin.y: vehicleIcon.height / 2
angle: vehicle.heading angle: vehicle ? vehicle.heading : 0
} }
} }
} }
...@@ -710,7 +710,7 @@ void QGCApplication::showMessage(const QString& message) ...@@ -710,7 +710,7 @@ void QGCApplication::showMessage(const QString& message)
{ {
MainWindow* mainWindow = MainWindow::instance(); MainWindow* mainWindow = MainWindow::instance();
if (mainWindow) { if (mainWindow) {
mainWindow->showToolbarMessage(message); mainWindow->showMessage(message);
} else { } else {
qWarning() << "showMessage with no mainWindow" << message; qWarning() << "showMessage with no mainWindow" << message;
} }
......
...@@ -135,18 +135,17 @@ void UASMessageHandler::handleTextMessage(int, int compId, int severity, QString ...@@ -135,18 +135,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:
//Use set RGB values from given color from QGC style = QString("color: #f95e5e; font-weight:bold");
style = QString("color: rgb(%1, %2, %3); font-weight:bold").arg(QGC::colorRed.red()).arg(QGC::colorRed.green()).arg(QGC::colorRed.blue());
_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: rgb(%1, %2, %3); font-weight:bold").arg(QGC::colorOrange.red()).arg(QGC::colorOrange.green()).arg(QGC::colorOrange.blue()); style = QString("color: #f9b55e; font-weight:bold");
_warningCount++; _warningCount++;
break; break;
default: default:
style = QString("color:white; font-weight:bold"); style = QString("color: #ffffff; font-weight:bold");
_normalCount++; _normalCount++;
break; break;
} }
...@@ -187,7 +186,7 @@ void UASMessageHandler::handleTextMessage(int, int compId, int severity, QString ...@@ -187,7 +186,7 @@ void UASMessageHandler::handleTextMessage(int, int compId, int severity, QString
// Finally preppend the properly-styled text with a timestamp. // Finally preppend the properly-styled text with a timestamp.
QString dateString = QDateTime::currentDateTime().toString("hh:mm:ss.zzz"); QString dateString = QDateTime::currentDateTime().toString("hh:mm:ss.zzz");
UASMessage* message = new UASMessage(compId, severity, text); UASMessage* message = new UASMessage(compId, severity, text);
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)); message->_setFormatedText(QString("<p style=\"color:#e0e0f0\">[%2 - COMP:%3]<font style=\"%1\">%4 %5</font></p>").arg(style).arg(dateString).arg(compId).arg(severityText).arg(text));
_messages.append(message); _messages.append(message);
int count = _messages.count(); int count = _messages.count();
if (message->severityIsError()) { if (message->severityIsError()) {
......
...@@ -671,3 +671,8 @@ void MainWindow::_storeVisibleWidgetsSettings(void) ...@@ -671,3 +671,8 @@ void MainWindow::_storeVisibleWidgetsSettings(void)
settings.setValue(_visibleWidgetsKey, widgetNames); settings.setValue(_visibleWidgetsKey, widgetNames);
} }
#endif #endif
void MainWindow::showMessage(const QString message)
{
emit showCriticalMessage(message);
}
...@@ -91,6 +91,9 @@ public: ...@@ -91,6 +91,9 @@ public:
/// @brief Saves the last used connection /// @brief Saves the last used connection
void saveLastUsedConnection(const QString connection); void saveLastUsedConnection(const QString connection);
/// @brief Show message in lower message window
void showMessage(const QString message);
// Called from MainWindow.qml when the user accepts the window close dialog // Called from MainWindow.qml when the user accepts the window close dialog
Q_INVOKABLE void acceptWindowClose(void); Q_INVOKABLE void acceptWindowClose(void);
...@@ -142,7 +145,7 @@ signals: ...@@ -142,7 +145,7 @@ signals:
void showPlanView(void); void showPlanView(void);
void showSetupView(void); void showSetupView(void);
void showToolbarMessage(const QString& message); void showCriticalMessage(const QString& message);
void showWindowCloseMessage(void); void showWindowCloseMessage(void);
// These are used for unit testing // These are used for unit testing
......
...@@ -94,7 +94,7 @@ Item { ...@@ -94,7 +94,7 @@ Item {
planViewLoader.visible = false planViewLoader.visible = false
} }
onShowToolbarMessage: toolBar.showToolbarMessage(message) onShowCriticalMessage: showCriticalMessage(message)
onShowWindowCloseMessage: windowCloseDialog.open() onShowWindowCloseMessage: windowCloseDialog.open()
...@@ -127,6 +127,18 @@ Item { ...@@ -127,6 +127,18 @@ Item {
} }
} }
property var messageQueue: []
function showCriticalMessage(message) {
if(criticalMmessageArea.visible) {
messageQueue.push(message)
} else {
criticalMessageText.text = message
criticalMmessageArea.visible = true
mainWindow.setMapInteractive(false)
}
}
function showLeftMenu() { function showLeftMenu() {
if(!leftPanel.visible && !leftPanel.item.animateShowDialog.running) { if(!leftPanel.visible && !leftPanel.item.animateShowDialog.running) {
leftPanel.visible = true leftPanel.visible = true
...@@ -278,7 +290,7 @@ Item { ...@@ -278,7 +290,7 @@ Item {
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.75) color: Qt.rgba(0,0,0,0.8)
visible: false visible: false
radius: ScreenTools.defaultFontPixelHeight * 0.5 radius: ScreenTools.defaultFontPixelHeight * 0.5
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
...@@ -319,5 +331,94 @@ Item { ...@@ -319,5 +331,94 @@ Item {
} }
} }
} }
//-------------------------------------------------------------------------
//-- Critical Message Area
Rectangle {
id: criticalMmessageArea
function close() {
//-- Are there messages in the waiting queue?
if(mainWindow.messageQueue.length) {
criticalMessageText.text = ""
//-- Show all messages in queue
for (var i = 0; i < mainWindow.messageQueue.length; i++) {
criticalMessageText.append(mainWindow.messageQueue[i])
}
//-- Clear it
mainWindow.messageQueue = []
} else {
criticalMessageText.text = ""
mainWindow.setMapInteractive(true)
criticalMmessageArea.visible = false
}
}
width: mainWindow.width * 0.55
height: ScreenTools.defaultFontPixelHeight * ScreenTools.fontHRatio * 6
color: Qt.rgba(0,0,0,0.8)
visible: false
radius: ScreenTools.defaultFontPixelHeight * 0.5
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom
anchors.bottomMargin: ScreenTools.defaultFontPixelHeight
Flickable {
id: criticalMessageFlick
anchors.margins: ScreenTools.defaultFontPixelHeight
anchors.fill: parent
contentHeight: criticalMessageText.height
contentWidth: criticalMessageText.width
boundsBehavior: Flickable.StopAtBounds
pixelAligned: true
clip: true
TextEdit {
id: criticalMessageText
width: criticalMmessageArea.width - criticalClose.width - (ScreenTools.defaultFontPixelHeight * 2)
anchors.left: parent.left
readOnly: true
textFormat: TextEdit.RichText
font.weight: Font.DemiBold
wrapMode: TextEdit.WordWrap
color: "#fdfd3b"
}
}
//-- Dismiss Critical Message
Image {
id: criticalClose
anchors.margins: ScreenTools.defaultFontPixelHeight
anchors.top: parent.top
anchors.right: parent.right
width: ScreenTools.defaultFontPixelHeight * 1.5
height: ScreenTools.defaultFontPixelHeight * 1.5
source: "/res/XDelete.svg"
fillMode: Image.PreserveAspectFit
mipmap: true
smooth: true
MouseArea {
anchors.fill: parent
onClicked: {
criticalMmessageArea.close()
}
}
}
//-- More text below indicator
Image {
anchors.margins: ScreenTools.defaultFontPixelHeight
anchors.bottom: parent.bottom
anchors.right: parent.right
width: ScreenTools.defaultFontPixelHeight * 1.5
height: ScreenTools.defaultFontPixelHeight * 1.5
source: "/res/ArrowDown.svg"
fillMode: Image.PreserveAspectFit
mipmap: true
smooth: true
visible: criticalMessageText.lineCount > 5
MouseArea {
anchors.fill: parent
onClicked: {
criticalMessageFlick.flick(0,-500)
}
}
}
}
} }
...@@ -147,11 +147,6 @@ Rectangle { ...@@ -147,11 +147,6 @@ Rectangle {
MainToolBarController { id: _controller } MainToolBarController { id: _controller }
function showToolbarMessage(message) {
toolBarMessage.text = message
toolBarMessageArea.visible = true
}
function getBatteryColor() { function getBatteryColor() {
if(activeVehicle) { if(activeVehicle) {
if(activeVehicle.batteryPercent > 75) { if(activeVehicle.batteryPercent > 75) {
...@@ -595,44 +590,4 @@ Rectangle { ...@@ -595,44 +590,4 @@ Rectangle {
color: colorGreen color: colorGreen
} }
// Toolbar message area }
Rectangle {
id: toolBarMessageArea
x: toolBar.parent.width * 0.225
y: toolBar.parent.height - (ScreenTools.defaultFontPixelHeight * ScreenTools.fontHRatio * 6)
width: toolBar.parent.width * 0.55
height: ScreenTools.defaultFontPixelHeight * ScreenTools.fontHRatio * 6
color: Qt.rgba(0,0,0,0.65)
visible: false
ScrollView {
width: toolBarMessageArea.width - toolBarMessageCloseButton.width
anchors.top: parent.top
anchors.bottom: parent.bottom
frameVisible: false
horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff
verticalScrollBarPolicy: Qt.ScrollBarAlwaysOff
QGCLabel {
id: toolBarMessage
width: toolBarMessageArea.width - toolBarMessageCloseButton.width
wrapMode: Text.WordWrap
color: "#e4e428"
lineHeightMode: Text.ProportionalHeight
lineHeight: 1.15
anchors.margins: mainWindow.tbSpacing
}
}
QGCButton {
id: toolBarMessageCloseButton
primary: true
text: "Close"
anchors.right: parent.right
anchors.bottom: parent.bottom
anchors.margins: mainWindow.tbSpacing
onClicked: {
toolBarMessageArea.visible = false
_controller.onToolBarMessageClosed()
}
}
}
} // Rectangle
...@@ -46,15 +46,12 @@ MainToolBarController::MainToolBarController(QObject* parent) ...@@ -46,15 +46,12 @@ MainToolBarController::MainToolBarController(QObject* parent)
, _progressBarValue(0.0f) , _progressBarValue(0.0f)
, _telemetryRRSSI(0) , _telemetryRRSSI(0)
, _telemetryLRSSI(0) , _telemetryLRSSI(0)
, _toolbarMessageVisible(false)
{ {
_activeVehicleChanged(qgcApp()->toolbox()->multiVehicleManager()->activeVehicle()); _activeVehicleChanged(qgcApp()->toolbox()->multiVehicleManager()->activeVehicle());
// RSSI (didn't like standard connection) // RSSI (didn't like standard connection)
connect(qgcApp()->toolbox()->mavlinkProtocol(), connect(qgcApp()->toolbox()->mavlinkProtocol(),
SIGNAL(radioStatusChanged(LinkInterface*, unsigned, unsigned, int, int, unsigned, unsigned, unsigned)), this, SIGNAL(radioStatusChanged(LinkInterface*, unsigned, unsigned, int, int, unsigned, unsigned, unsigned)), this,
SLOT(_telemetryChanged(LinkInterface*, unsigned, unsigned, int, int, unsigned, unsigned, unsigned))); SLOT(_telemetryChanged(LinkInterface*, unsigned, unsigned, int, int, unsigned, unsigned, unsigned)));
connect(qgcApp()->toolbox()->multiVehicleManager(), &MultiVehicleManager::activeVehicleChanged, this, &MainToolBarController::_activeVehicleChanged); connect(qgcApp()->toolbox()->multiVehicleManager(), &MultiVehicleManager::activeVehicleChanged, this, &MainToolBarController::_activeVehicleChanged);
} }
...@@ -134,46 +131,6 @@ void MainToolBarController::_setProgressBarValue(float value) ...@@ -134,46 +131,6 @@ void MainToolBarController::_setProgressBarValue(float value)
emit progressBarValueChanged(value); emit progressBarValueChanged(value);
} }
void MainToolBarController::showToolBarMessage(const QString& message)
{
_toolbarMessageQueueMutex.lock();
if (_toolbarMessageQueue.count() == 0 && !_toolbarMessageVisible) {
QTimer::singleShot(500, this, &MainToolBarController::_delayedShowToolBarMessage);
}
_toolbarMessageQueue += message;
_toolbarMessageQueueMutex.unlock();
}
void MainToolBarController::_delayedShowToolBarMessage(void)
{
QString messages;
if (!_toolbarMessageVisible) {
_toolbarMessageQueueMutex.lock();
foreach (QString message, _toolbarMessageQueue) {
messages += message + "\n";
}
_toolbarMessageQueue.clear();
_toolbarMessageQueueMutex.unlock();
if (!messages.isEmpty()) {
_toolbarMessageVisible = true;
emit showMessage(messages);
}
}
}
void MainToolBarController::onToolBarMessageClosed(void)
{
_toolbarMessageVisible = false;
_delayedShowToolBarMessage();
}
void MainToolBarController::showSettings(void) void MainToolBarController::showSettings(void)
{ {
MainWindow::instance()->showSettings(); MainWindow::instance()->showSettings();
......
...@@ -53,7 +53,6 @@ public: ...@@ -53,7 +53,6 @@ public:
Q_INVOKABLE void onSetupView(); Q_INVOKABLE void onSetupView();
Q_INVOKABLE void onPlanView(); Q_INVOKABLE void onPlanView();
Q_INVOKABLE void onFlyView(); Q_INVOKABLE void onFlyView();
Q_INVOKABLE void onToolBarMessageClosed(void);
Q_INVOKABLE void showSettings(void); Q_INVOKABLE void showSettings(void);
Q_INVOKABLE void manageLinks(void); Q_INVOKABLE void manageLinks(void);
...@@ -77,8 +76,6 @@ public: ...@@ -77,8 +76,6 @@ public:
unsigned int telemetryLNoise () { return _telemetryLNoise; } unsigned int telemetryLNoise () { return _telemetryLNoise; }
unsigned int telemetryRNoise () { return _telemetryRNoise; } unsigned int telemetryRNoise () { return _telemetryRNoise; }
void showToolBarMessage(const QString& message);
signals: signals:
void progressBarValueChanged (float value); void progressBarValueChanged (float value);
void telemetryRRSSIChanged (int value); void telemetryRRSSIChanged (int value);
...@@ -90,14 +87,10 @@ signals: ...@@ -90,14 +87,10 @@ signals:
void telemetryLNoiseChanged (unsigned int value); void telemetryLNoiseChanged (unsigned int value);
void telemetryRNoiseChanged (unsigned int value); void telemetryRNoiseChanged (unsigned int value);
/// Shows a non-modal message below the toolbar
void showMessage(const QString& message);
private slots: private slots:
void _activeVehicleChanged (Vehicle* vehicle); void _activeVehicleChanged (Vehicle* vehicle);
void _setProgressBarValue (float value); void _setProgressBarValue (float value);
void _telemetryChanged (LinkInterface* link, unsigned rxerrors, unsigned fixed, int rssi, int remrssi, unsigned txbuf, unsigned noise, unsigned remnoise); void _telemetryChanged (LinkInterface* link, unsigned rxerrors, unsigned fixed, int rssi, int remrssi, unsigned txbuf, unsigned noise, unsigned remnoise);
void _delayedShowToolBarMessage (void);
private: private:
Vehicle* _vehicle; Vehicle* _vehicle;
...@@ -114,7 +107,6 @@ private: ...@@ -114,7 +107,6 @@ private:
double _toolbarHeight; double _toolbarHeight;
bool _toolbarMessageVisible;
QStringList _toolbarMessageQueue; QStringList _toolbarMessageQueue;
QMutex _toolbarMessageQueueMutex; QMutex _toolbarMessageQueueMutex;
}; };
......
...@@ -58,11 +58,13 @@ Row { ...@@ -58,11 +58,13 @@ Row {
return colorOrange; return colorOrange;
if (activeVehicle.messageTypeError) if (activeVehicle.messageTypeError)
return colorRed; return colorRed;
}
// Cannot be so make make it obnoxious to show error // Cannot be so make make it obnoxious to show error
console.log("Invalid vehicle message type") console.log("Invalid vehicle message type")
return "purple"; return "purple";
} }
//-- It can only get here when closing (vehicle gone while window active)
return "white";
}
function getBatteryVoltageText() { function getBatteryVoltageText() {
if (activeVehicle.batteryVoltage > 0) { if (activeVehicle.batteryVoltage > 0) {
......
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